Claude
Skills
Sign in
Back

save-memory

Included with Lifetime
$97 forever

Save current session progress and context to memory

General

What this skill does


# Save Memory

This skill saves the current session's progress and context to the personal memory system.

## Instructions for Agent

### 1. Collect Session Context

Gather the following information:
- **Current working directory**: Use `pwd` or `Get-Location`
- **Repository details** (if in a git repo):
  - Repository root: `git rev-parse --show-toplevel`
  - Current branch: `git branch --show-current`
  - Latest commit: `git rev-parse HEAD`
  - Worktree (if applicable): check if cwd is different from repo root
- **Machine identifier**: `hostname` (lowercase)
- **OS environment**:
  - Windows: `$env:OS` contains "Windows"
  - WSL: check `/proc/version` for "microsoft"
  - Linux: `uname -s`

### 2. Generate Summary

Analyze the recent conversation history to extract:
- **Goals**: What was the user trying to accomplish?
- **Activities**: What work was performed?
- **Progress**: What was completed?
- **Next steps**: What remains to be done?
- **Keywords**: Important terms, technologies, features
- **Tags**: Categorize the work (from user parameter or inferred)

Use the specified `detail_level` parameter (or default to "normal").

### 3. Call Python Script

Execute the manage_memory.py script:

```bash
cd "${CLAUDE_PLUGIN_ROOT}"

# Detect Python command (python3 on Linux, python on Windows)
PYTHON_CMD=$(command -v python3 || command -v python)

# Try to use venv if available, create if needed, skip if venv creation fails
if [ -d "venv" ]; then
  # Activate venv (cross-platform)
  if [ -f "venv/bin/activate" ]; then
    source venv/bin/activate
  elif [ -f "venv/Scripts/activate" ]; then
    source venv/Scripts/activate
  fi
elif $PYTHON_CMD -m venv venv 2>/dev/null; then
  echo "Setting up Python environment (first time)..."
  if [ -f "venv/bin/activate" ]; then
    source venv/bin/activate
  elif [ -f "venv/Scripts/activate" ]; then
    source venv/Scripts/activate
  fi
  pip install -r requirements.txt
else
  echo "Note: Using system Python (venv creation not available)"
fi

$PYTHON_CMD scripts/manage_memory.py save \
  --config-repo "$YW_CONFIG_REPO_PATH" \
  --detail-level {detail_level} \
  --repo-path {repo_path} \
  --branch {branch} \
  --commit {commit} \
  --machine {machine} \
  --os {os} \
  --summary "{summary}" \
  --keywords "{keywords}" \
  --tags "{tags}"
```

### 4. Handle Result

Parse the JSON output:
```json
{
  "success": true,
  "episode_id": "ep-12345abcd",
  "filepath": "memory/episodes/2026-01-31_work-main_windows_repo-name_ep-12345.md",
  "synced": true
}
```

Return a concise confirmation to the user:
```
Memory saved successfully!
- Episode ID: ep-12345abcd
- Location: memory/episodes/...
- Synced to remote: Yes
```

### 5. Error Handling

If the script fails:
- Display the error message clearly
- Suggest remediation steps (e.g., check git repo, verify paths)
- Do not retry automatically

## Example Usage

**User:** "hey remember the progress in this session"

**Agent:**
1. Collects context (repo, branch, machine, OS)
2. Generates summary from conversation
3. Calls manage_memory.py script
4. Returns confirmation with episode ID

Related in General