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. When you start a new session, your task list is gone.
This command implements the pattern described in Anthropic's Effective Harnesses for Long-Running Agents:
"Every subsequent session asks the model to make incremental progress, then leave structured updates."
| 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