Use when ending a session, pausing work on a branch, or switching to a new topic
Wraps up a session cleanly so the next session can start immediately without reconstruction overhead.
Is the user continuing in this session right now?
/compact, stop here. No handoff needed yet.Is there in-progress work on a branch? (uncommitted changes, unmerged branch, open PR)
/clearNote: "no work in flight" is not the same as "nothing happened." A session with architectural decisions, research, or answered questions still warrants a memory check even without code changes.
Review the conversation for anything non-obvious and cross-session relevant:
~/.claude/session-notes/ (permanent record, never delete)Do NOT write memory for task state or current progress — that goes in the handoff doc.
Project key = git repo root path with every / and . replaced by -, including the leading slash.
Use git rev-parse --show-toplevel to get the repo root — do NOT use the current working directory (worktrees would produce a wrong key).
Example: /Users/shelbyrackley/work/my-app → -Users-shelbyrackley-work-my-app
Example with dot: /Users/shelbyrackley/.claude → -Users-shelbyrackley--claude (. becomes -, giving --)
If unsure, verify by checking ~/.claude/projects/ — the actual directories Claude Code created are the source of truth.
Memory files: ~/.claude/projects/<project-key>/memory/
First, resolve the branch name: git -C <repo-root> branch --show-current. If empty (detached HEAD), use the short commit SHA instead and note it in the doc.
Path: ~/.claude/projects/<project-key>/memory/handoffs/<branch-name>.md
Branch name: replace / with -. Example: feat/new-dashboard → feat-new-dashboard.md
One file per branch. Overwrite each session. Delete once merged.
# Handoff: <branch>
**Date:** YYYY-MM-DD
**Status:** In progress | Ready to commit | Ready to PR | Done
## What was done
- <bullet summary>
## Next steps
1. <first action>
## Context / gotchas
<Decisions, workarounds, known issues worth rediscovering>
Always print it explicitly:
Handoff written to:
~/.claude/projects/<project-key>/memory/handoffs/<name>.md
Output a ready-to-paste prompt:
Continue work on branch `<branch>`.
Previous session (<date>): <one-sentence summary>.
Handoff doc: ~/.claude/projects/<project-key>/memory/handoffs/<name>.md
Next: <first action from next steps>
Recommend /clear — the handoff doc is the continuity mechanism, not the context window.
git rev-parse --show-toplevel/clear