← KNOWLEDGE / NOTE
Closing out a Claude coding session
Bottom line
What needs to survive a session, how to read context instead of counting prompts, and what to prune versus leave alone.
Consolidate before you close
A new Claude Code session starts with none of a previous session’s conversation history. The only thing that survives automatically is auto memory (MEMORY.md), and it’s capped at the first 200 lines or 25KB. So before ending a multi-chat stretch of work, run a pass that folds the decisions, gotchas, and context from those chats into files that live in the repo — CLAUDE.md, docs, code comments. That’s not overhead tacked onto closing a session; it is closing a session correctly.
Watch context, not a prompt count
Every request resends the entire transcript so far — system prompt, files, every prior message and tool result — because the model has no memory between calls. Cost and answer quality both degrade as that transcript grows, but continuously, not at a fixed threshold like “prompt 16.” A raw prompt count is a proxy for a signal you can look at directly: run /context (or watch the live status bar) for actual token usage, and act when it’s climbing rather than on a fixed schedule.
Compact, clear, or new chat
| Command | When to use |
|---|---|
/compact [focus] | Mid-task, context climbing, still working the same thing. Lossy — summarizes old tool output and conversation, so give it a focus (/compact keep the API decisions) to control what survives. |
/clear or a new chat | At a genuine task boundary — one thing’s done, the next is unrelated. Full reset, nothing carried forward. |
Neither guarantees an early fact survives compaction or a reset — that’s exactly what consolidating into the repo first is for.
What to prune vs. leave alone
Leave alone — chat transcripts. Claude Code auto-deletes sessions older than 30 days by default. Once you’ve consolidated the useful parts, the originals cost nothing just sitting on disk.
Prune actively — CLAUDE.md, roadmap/status files, auto memory. These reload every session, forever, so a stale “pending” item or an outdated instruction isn’t neutral clutter — it’s a recurring cost and it can actively mislead a future session. Update them, don’t just append: mark things resolved instead of leaving them listed as still pending.
Close-out checklist
- [ ] Decisions and gotchas from the session(s) folded into CLAUDE.md, docs, or code comments
- [ ] Roadmap/status files updated — resolved items marked done, not just left pending
- [ ] `/context` checked if the session ran long; compacted with a focus or cleared at a real task boundary
- [ ] Infra cleanup done if the work touched it (old deploys, stale config) — separate concern, same instinct as pruning docs
- [ ] Chat transcripts left alone — no manual cleanup needed