Koda Dojo
· Claude Code

Module 4: Context Management and Compaction

Long productive runs where you measure, budget and preserve context on purpose, instead of sessions that quietly degrade into confusion.

Lessons

  1. What loads before you type. Set where each item loads, launch, and the real window is drawn over your prediction.
  2. Five lines that filled it. Cut the lines that wasted one morning's window, then replay the morning with your cuts.
  3. What survives /compact. A try-out of /compact and /clear. Then bet on what comes back, make a decision outlast it, and watch auto-compaction fire.
  4. The compaction ritual. Set the five steps around one /compact and run them; the next phase shows what they let through.
  5. Clear, compact or delegate. A try-out of /resume after a /clear. Then four moments in billing-api. Get the window ready with real commands, then send the next task and watch.
  6. Fresh check. A try-out of !git status, then an invented session you have not seen. Act on it in the terminal. Your first result is kept.

What you take away

  • Run /context at session start and before big tasks: fixed overhead is real and measurable
  • Compact at phase boundaries with explicit preserve instructions, never mid-debugging
  • /clear for unrelated work, /compact for continuing work: a summary of irrelevant history is pure overhead
  • Durable state lives in files like PROGRESS.md and HANDOFF.md, not in the window
  • Delegate any exploration wider than a few files to a subagent and pay for conclusions, not reading

Field exercises

  • Read Your Context Budget With /context
  • Compare Targeted and Broad Code Reading
  • Compact at a Phase Boundary With a Steering Prompt
  • Choose /clear or /compact on Purpose
  • Survive a Full Session Lifecycle
  • Test a File-Based Session Handoff
  • Run a Large Refactor With a Context Strategy
  • Audit and Slim Your CLAUDE.md
  • Build a Reusable Context Workflow
  • Delegate Research to a Subagent, Keep Only the Conclusion
  • Build a CLAUDE.md with Context Rules
  • Practice Plan Mode and Compaction
  • Compare Context-Clear vs Carry-Over Results
  • Manage Context With CLAUDE.md Planning
  • Practice plan-then-implement discipline
  • Build AGENTS.md With Absolute Rules
  • Rewind a Polluted Session With Git

All fifteen modules of the Claude Code Dojo