Context preservation strategy for multi-session projects during context window compaction.
SkillScore95Maintained
Automatic
◆AI Engineer pack
Last verified 8/3/2026
What it changes
Passed 21 of 22 test cases with the skill, and 15 of 22 without it.
Without skill68%
With skill95%
Checks it passed that the model alone missed
The response specifies framing the current objective as a one-line statement
The response advises discarding intermediate mental models and exploratory passages
The response recommends limiting the decision reasoning to a single concise sentence
and 4 more in the full report
6 fixed15 passed either way1 still failing0 broke
Pass-rate lift
+27 pp
Tokens
+16%
Agent turns
0%
Response time
-36%
Model gemini-3.6-flashMeasured 8/3/2026v121 of 22 cases passed with skill
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 6
Prompt
We just wrapped up Phase 2 (API design) of our multi-phase project and are about to start Phase 3 (Database integration). What dual action should be taken before starting the new phase?
When a Claude Code session approaches context-window limits and performs context compaction (manual /compact or automatic), the agent must balance information density with continuity. This skill defines what to preserve and what to discard.
What to Preserve
Current objective / phase — one-line statement of what the session is actively working on
Blockers and open blockers — issues preventing forward progress, with minimal context
Decisions that remain valid — architectural or planning decisions made in earlier sessions that still apply
Validation state — which tests are passing, which requirements are met, which gates are open/blocked
Worktree / branch state — when relevant to resuming work (branch name, uncommitted changes, PR status)
Next concrete step — what the next AI session should do immediately after loading context
What to Discard
Resolved conversations — back-and-forth debugging or decision-making that concluded
Repeated reasoning — the same analysis or explanation presented multiple times across the session
Discarded attempts — approaches tried and rejected, unless the rejection reason remains strategically important
Large tool outputs — full log dumps, verbose grep results, API responses in their entirety (keep only the relevant extracted data)
Intermediate mental models — exploratory reasoning or "let me think through this" passages that didn't lead to decision
Critical Principle
The compact summary is a sketch, not a replacement for durable state. If the project has a session-handoff.md, PROGRESS.md, CHANGELOG.md, or equivalent living documentation, those files remain the source of truth. The compacted context is temporary and lossy — it buys context space in the current session, but it does not eliminate the need to maintain formal handoff documents for the next session.
If compaction is being used to work around missing handoff documentation, that is a symptom — fix the root cause (write the missing session-handoff.md or PROGRESS.md) rather than relying on compaction to carry state.
Trigger Conditions
Manual invocation: /compact command during an active session
Automatic invocation: Claude Code's built-in auto-compact mechanism when token usage exceeds threshold
Proactive: when working on multi-phase projects and ending a phase, consider manual compact + handoff update in parallel
Output Quality Check
Before finalizing a compact summary, ask:
Can a blind AI read the preserved state and continue without asking? If the next session would need to ask "what phase are we in?" or "which branch?", add more specificity.
Is decision context preserved? If a decision matters for the next steps, include the reasoning in one sentence.
Are blockers actionable? "Blocked on X" is better than "something wrong" — the next session should know what to check first.