Save your current session state before ending work. Creates both machine-readable and human-readable progress files.
Claude Code's native --resume flag restores conversation history, but TodoWrite state does not persist between sessions by design. Claude Code treats each session as isolated—the philosophy is that persistent state belongs in files you control, not in Claude's internal state.
TodoWrite tasks are stored at ~/.claude/todos/[session-id].json and deleted when the session ends. This is intentional, not a bug.
This command bridges the gap by implementing the pattern from Anthropic's Effective Harnesses for Long-Running Agents:
"Every subsequent session asks the model to make incremental progress, then leave structured updates."
| Claude Code Feature | Persists? | Location |
|---|---|---|
| Conversation history | Yes | Internal (use --resume) |
| CLAUDE.md context | Yes | ./CLAUDE.md |
| TodoWrite tasks | No | Deleted on session end |
| Plan Mode state | No | In-memory only |
/save Fills| Feature | Native --resume |
/save + /load |
|---|---|---|
| Conversation history | Yes | No |
| TodoWrite tasks | No | Yes |
| Git context | No | Yes |
| Human-readable summary | No | Yes |
| Git-trackable | No | Yes |
| Works across machines | No | Yes (if committed) |
| Team sharing | No | Yes |
/compact$ARGUMENTS
If no arguments, save current TodoWrite state and git context.
Capture Current State
Write State Files
.claude/claude-state.json - Machine-readable state.claude/claude-progress.md - Human-readable summaryOptional Git Commit
--commit flag: commit state files with message{
"version": "1.0",
"timestamp": "<ISO timestamp>",
"completed": ["task1", "task2"],
"in_progress": ["task3"],
"pending": ["task4", "task5"],
"context": {
"branch": "<current branch>",
"last_commit": "<commit hash>",
"last_commit_message": "<message>",
"modified_files": ["file1.ts", "file2.ts"],
"notes": "<any user-provided notes>"
}
}
# Session Progress
**Last Updated**: <timestamp>
**Branch**: <branch name>
## Completed
- [x] Task 1
- [x] Task 2
## In Progress
- [ ] Task 3
- Notes: <context>
## Next Steps
- Task 4
- Task 5
## Context
- Last commit: <hash> "<message>"
- Uncommitted: <count> files
# Basic save
/save
# Save with notes
/save "Stopped mid-refactor, auth module needs testing"
# Save and commit
/save --commit
# Save with notes and commit
/save "Ready for review" --commit
# Get git info
git branch --show-current
git log -1 --format="%H %s"
git status --porcelain
Access the current TodoWrite state from the conversation context. Map statuses:
completed → Completed sectionin_progress → In Progress sectionpending → Next Steps sectionmkdir -p .claude
Create .claude/claude-state.json with:
Create .claude/claude-progress.md with human-readable format:
If --commit flag present:
git add .claude/claude-state.json .claude/claude-progress.md
git commit -m "chore: save session state"
After creating files, report:
✓ Session saved
State saved to:
• .claude/claude-state.json
• .claude/claude-progress.md
Summary:
• Completed: X tasks
• In Progress: Y tasks
• Pending: Z tasks
• Uncommitted files: N
Load with: /load
| Flag | Effect |
|---|---|
--commit |
Git commit the state files after creating |
--force |
Overwrite existing state without confirmation |
/load to restore state in a new session