End-of-session ritual. Captures session state, updates auto-memory, writes a session summary, then exits the session cleanly.
Preserve the work. Carry the thread forward.
When invoked, perform ALL of the following steps in order:
Review the full conversation and identify:
Update ~/.claude/projects/{project-key}/memory/MEMORY.md with any new stable knowledge from this session.
Save if:
Don't save:
Use Edit tool to append or update relevant sections. Create topic files if a section grows too large.
Write a summary file to: ~/.claude/projects/{project-key}/sessions/{date}-{slug}.md
Format:
# Session: {date} -- {2-4 word description}
## Work Done
- {bullet list of completed items}
## Current State
- {what's working, what's running, what's deployed}
## Open Threads
- {unfinished work with enough context to resume}
## Key Files Modified
- `{path}` -- {what changed}
## Decisions & Context
- {important choices made, with rationale}
## Next Steps
- {prioritized list of what to do next}
If you have a notification channel configured (WhatsApp, Slack, etc.), send a consolidated session summary:
Session closed
{2-3 sentence summary of work done}
State: {brief current state}
Next: {top 1-2 priorities}
Repo: {https-url} ({branch} @ {short-hash})
Omit the Repo: line if not in a git repo or no remote is configured.
If the session contained a repeatable workflow or novel pattern, ask:
"This session had [pattern]. Want me to distill it into a reusable skill before closing?"
Only offer if there's something genuinely worth distilling. Don't force it.
Rename the current session's .jsonl transcript from its UUID to a human-readable name.
Location: ~/.claude/projects/{project-key}/
Format: {date}-{slug}.jsonl
{date} = YYYY-MM-DD{slug} = 2-4 word kebab-case description matching the session summary slugProcedure:
ls -t ~/.claude/projects/{project-key}/*.jsonl | head -1mv {uuid}.jsonl {date}-{slug}.jsonlNote: This breaks --resume for the old UUID, which is fine since the session is closing. The renamed file remains searchable via Grep for future context lookups.
After all steps complete, tell the user:
Session closed. All state preserved. You can exit with /exit or Ctrl+C.
Then stop responding. Do not continue the conversation. The session is done.
Part of Claude Code Skills -- reusable skills extracted from real AI-assisted development sessions.