Skip to main content

Steve Kinney

Compacting Claude Code Sessions

When a Claude Code session gets long enough that nobody can remember which decision mattered, compaction starts to look attractive. It summarizes the session so work can continue with less context. That helps, but it is still compression. Details can be lost.

What to Preserve Before Compacting

Before a long task compacts, make sure the important state is in the filesystem:

  • The plan is written in a file or reflected in tests.
  • The branch diff is coherent.
  • Verification commands are known.
  • Blockers are documented with command output.
  • Decisions are captured in CLAUDE.md, rules, skills, or project documentation when they need to persist.

If a future session needs to remember a subtle decision, put that decision in a file before compaction.

Manual Compaction

Use compaction when the session is still on the same goal but the context is getting noisy. After compaction, ask Claude to restate:

Restate the goal, files changed, remaining tasks, and verification commands.
Do not edit files.

Compare that answer with git diff and the task plan before continuing.

Hooks Around Compaction

Claude Code exposes hook events around compaction. Use them sparingly for auditing or preserving status, not for hiding critical project state in an invisible automation.

Large Context Is Not a Replacement

Large-context model aliases such as sonnet[1m] and opus[1m] can reduce the need to compact, but they do not remove the need for clean task state. A million tokens of unclear conversation is still unclear.

Last modified on .