Claude Code /compact — What Do You Keep When Context Shrinks?

In a long Claude Code session, when the window fills up, /compact replaces conversation history with a structured summary so you can keep going. Automatic compaction uses the same axis. If you trust the summary alone, Goal · decisions · Next blur. Safer practice: freeze a minimum state before compact—outside the chat, or in the compact instructions.

This post covers only minimum info before compact · restart prompts · what to keep in files. Grounding: Commands (/compact, /context, /clear) and Explore the context window (What survives compaction). No plan prices, invented quotas, or affiliates. No C++ samples.

What minimum info do you keep before compact?

One-line answer: Freeze Goal · Done · a single Next · Decisions · one-line repro · key paths that live only in chat right before compact. Mechanisms: /compact instructions and on-disk CLAUDE.md · memory · plan · checkpoint files.

/compact [instructions] summarizes the conversation; optional arguments steer the summary. Docs example: /compact focus on the auth bug fix. Your stated axes beat whatever the automatic pass guesses is important.

Pre-compact checklist:

ItemChat-only riskBefore compact
GoalDiluted in the summaryOne line in /compact instructions or a file
Done / Do-not-redoMixed with long debug trailsSpell verified and abandoned approaches
Next (one)Multiple candidates blurKeep exactly one next step
DecisionsDesign rationale lostOne or two lines: choice + rejected alternative
ReproFailure logs truncatedCommand + symptom + path
Key pathsOnly some reads reloadName the files you will open next

Practical order:

  1. Run /context to see what fills the window (categories and optimization hints). When over the window, the UI/docs may warn and point at space-freeing commands.
  2. Unrelated work → /clear. Same task → /compact. /clear starts empty; /compact continues the same conversation via a summary (Commands docs).
  3. Pass focus instructions before compact. Example:
/compact Keep: Goal=<…>; Done=<…>; Next=<one step>; Decisions=<…>;
Repro=<cmd + symptom>; Key paths=<…>. Drop: stale debug tangents, abandoned approaches.
  1. Whatever already lives on disk is re-injected (next section). Move chat-only contracts into instructions or files.
  2. Delegate large reads to a subagent so bulky contents stay out of your window (docs). That slows fill rate; it is not a substitute for compact.

Automatic compaction follows the same summary path as /compact. Before a long new task, a focused manual /compact is more predictable than “whatever auto thought mattered.” /autocompact can adjust when auto-compact fires; this post does not invent thresholds or plan numbers—use current UI/docs values.

What restart prompt do you use?

One-line answer: Right after compact, do not “start from scratch.” Stay on summary + re-injected disk state and run one Next step. After /clear, read the checkpoint / CLAUDE.md path first.

Continue in the same session after compact:

After compact: treat the summary as lossy. Re-state Goal and the single Next.
Do not re-explore Done/Do-not-redo. Open only the Key paths listed.
First action: <one concrete Next step>. Report blockers in one line.

True restart after /clear or a new conversation:

Read `PATH/TO/CHECKPOINT.md` (and project CLAUDE.md) first.
Do not reconstruct the old chat. Goal / Done / Next / Blocked only.
Execute exactly one Next step. Do not expand scope.

Compare (per docs):

SituationCommandPrompt focus
Same task, free space/compact [instructions]Verify summary → one Next
Unrelated work/clearCheckpoint / CLAUDE.md first
Shrink only part of history/rewind → Summarize …Summarize from/up to a message
Inspect fill/contextDecide what to shed

Do not: “just continue somehow,” launch a huge new exploration right after compact, or re-run experiments already in Done. Summaries are lossy. Re-state Goal / Next / paths once.

What belongs in files?

One-line answer: Separate what reloads from disk after compact from what survives only inside the summary. Put durable contracts, plans, and memory in files; leave one-off noise in chat.

From What survives compaction (product behavior; see official docs for version notes):

MechanismAfter compaction
System prompt and output styleStill apply
Project-root CLAUDE.md, unscoped rulesRe-injected from disk
Auto memoryRe-injected from disk
Plan written in plan modeRe-injected from disk
Rules with paths:Reload when matching files are read again
Nested CLAUDE.md in subdirsReload when files in that subdir are read
Files Claude read or editedRe-reads up to five, most recently modified first; oversized files may return as path references only
Invoked skill bodiesRe-injected (per-skill and total caps; oldest dropped first)
Background commands / subagentsKeep running; Claude is reminded not to duplicate them
Context hooks added earlierSummarized with the conversation
SessionStart hooks matching compactRun; output added to compacted context

File vs chat:

Put it hereWhatWhy
Root CLAUDE.md / unscoped rulesTeam invariants, deny pathsRe-injected after compact
Plan file (plan mode)Agreed implementation planRe-injected
Auto memory / /memoryRecurring prefsRe-injected; edit via /memory
Checkpoint md (agreed repo path)Goal · Done · Next · Blocked · pathsDo not trust chat summary alone
Chat + /compact instructionsThis turn’s focusInstructions steer summary quality
Chat onlyLong failed log dumpsCollapse to one-line repro in file/instructions

One-line rules:

  1. Need it after the next compact/session? → Put it in a file.
  2. Path-scoped rules / nested CLAUDE.md alone may be empty until their trigger files are read again. If it must always apply, promote to root / unscoped (docs).
  3. Post-compact auto re-reads are capped. Name the next files in the checkpoint or instructions.
  4. Skills re-inject but truncate under caps—put critical instructions near the top of SKILL.md (docs).

Bottom line: Claude Code compact = focused /compact · one Next afterward · disk reloads CLAUDE.md / memory / plan · chat-only contracts move to files or instructions. Do not confuse it with /clear.

FAQ

/compact vs /clear?

/compact continues the same conversation via a summary. /clear (aliases /reset, /new) starts an empty conversation. Switch tasks with /clear; free space on the same task with /compact.

Is automatic compact enough?

Auto uses the same summary axis. Before a long new task, /compact with instructions locks focus better. Observe/adjust timing with /context and /autocompact (when your build supports it)—do not invent quota numbers.

Files look “unread” after compact?

At most five recently modified files auto re-read; large ones may be path references only. Ask Claude to open needed paths again, or list them in the checkpoint.

Why did a path-scoped rule disappear?

It entered history when the trigger file was read, then was summarized away with the rest. If it must survive compact, drop paths: or move it into root CLAUDE.md (docs).

Sources