Strategic Compaction
Proactive context management to maximize usable working context.
When to Compact
Compact at natural phase transitions, not arbitrary token thresholds:
- •Research → Plan: After gathering information, before writing implementation plan.
- •Plan → Implement: After plan is approved, before writing code.
- •Implement → Test: After initial implementation, before test writing/debugging.
- •Debug → Next Feature: After resolving a bug, before moving to next task.
- •Any → Handoff: Before ending a session that will continue later.
How to Compact
- •Summarize key decisions and context into a concise handoff note.
- •Include: current state, next steps, blockers, file paths touched.
- •Use
/compactwith a summary of what to preserve.
Handoff Document Template
markdown
## Session Handoff — [date] ### What was done - [Completed task 1] - [Completed task 2] ### Current state - [Branch name, last commit] - [What's working, what's not] ### Next steps - [ ] [Task 1] - [ ] [Task 2] ### Key decisions - [Decision 1: chose X because Y] - [Decision 2: chose A over B because C] ### Files touched - `path/to/file.go` — [what changed] - `path/to/other.py` — [what changed]
Anti-Patterns
- •Don't compact mid-debug. You lose stack trace context.
- •Don't compact right after reading a large file. Summarize it first.
- •Don't rely on auto-compact — it triggers at 80% capacity with no phase awareness.
- •Don't start a new feature without compacting the previous one's context.