Closing a Claude Code session well

/compact and /init aren't a session-close ritual. Here's what each one actually does, and what you need around them.

May 15, 2026 · ~5 min read

The simple version

Picture a workshop. You spend the day at one bench making something. By evening the bench is covered in tools, off-cuts, sketches, notes.

/compact is like sweeping the bench mid-day. You push the mess into a tidy pile so you have room to keep working. The pile is still on your bench. The moment you leave the workshop, that pile is gone.

/init is like writing a manual for the workshop. Someone walks around and writes "the chisels live here, the saws live there." It's not for today's project. It's for next week, when you've forgotten where everything is.

Neither one closes the workshop. To actually close up for the night you have to put the tools back (commit), lock the door (push), update the wall map with what changed today (edit CLAUDE.md by hand), and write tomorrow's to-do list (Todoist or similar). Then you leave.

/compact

Summarises the current conversation to free up Claude's context window. Lives in this session only.

Nothing gets written to disk. The summary disappears when the session ends.

in-session

/init

Analyses the codebase and generates a CLAUDE.md describing stack, commands, architecture.

Writes to disk. But it rewrites — it doesn't know about your hand-edited notes.

on-disk

How it actually works

/compact — context, not persistence

/compact is a mid-session move. As you work, your conversation grows. Every exchange — every file read, every tool call, every reply — eats into Claude's context window. Past a threshold, responses slow down and the model starts compacting for you.

/compact lets you do it deliberately. The conversation up to that point gets summarised into a smaller blob, freeing space for new work. It is purely in-session optimisation. Nothing reaches disk. The summary lives in the conversation and dies when the conversation ends.

When it helps:

When it doesn't:

/init — analysis, not journal

/init reads your codebase (file tree, manifests, key entry points) and writes a CLAUDE.md describing what it found: stack, commands, architecture, file purposes. It's a code-shape document, not a conversation log.

That's where the trap is. If your CLAUDE.md has hand-written sections — status, decisions, gotchas, "we tried X but pivoted to Y" — /init doesn't know about those. Re-running it can wipe out the most valuable parts of the file.

When it's right:

When it's wrong:

Session-close ritual
1 commit code state 2 push off this machine 3 edit CLAUDE.md today's deltas 4 task tracker what's next 5 close session fresh next time

What actually persists

Nothing in Claude Code auto-saves your conversation to a permanent place. If today's session decided to switch from Postgres to SQLite, that decision exists only in the code you wrote and whatever you explicitly captured. Close the session without writing it down and the next session won't know.

Session-end persistence is a checklist, not a command:

1. git add + commit + push
   → code state is durable, off this machine
2. Hand-edit CLAUDE.md
   → status changes, decisions, gotchas discovered
3. Capture cross-project learnings to memory
   → things bigger than this one project
4. Update task tracker (Todoist, Linear, GitHub issues)
   → what's next, what's blocked
5. Close the session

Step five matters. Long-lived sessions feel efficient but rarely are — context decay never gets captured, the conversation gets expensive to re-process, and you tend to keep tweaking instead of shipping.

Why close instead of keeping it open

A fresh session forces three useful behaviours:

The exception is loop-style work — scheduled tasks, polling, long-running monitors — where the session lifetime is the loop. For normal feature work or research, close at the natural finish line, not "when the screen gets full."

Key takeaways