Context Hygiene Cheatsheet
The one fact everything follows from: the agent's memory (context window) is finite, and it gets dumber as it fills. Clean context is free intelligence, and cheaper tokens. Same habit, both wins.
The habits
| Habit | When |
|---|---|
/context |
Glance at it like a fuel gauge, every session |
/clear |
Between unrelated tasks, always |
| Focused sessions | One task per session; open with the task, not "let's improve things" |
/compact |
Long session, still mid-task, running low, a blunt tool; prefer /clear when the task changed |
Revert + /clear + better prompt |
After two failed corrections on the same thing |
| Subagents | "Use a subagent to investigate X", research happens in a separate memory, you get the summary |
| Point, don't sweep | Name the files to read; never "look at everything" |
CLAUDE.md rules
- Loaded every session → every line is rent paid forever
- The test for each line: "would removing this cause mistakes?" No → cut
- Index, not archive: point to docs, don't inline them
- Bloat isn't just cost, a long CLAUDE.md gets ignored
- Always-needed → CLAUDE.md (tiny). Sometimes-needed → a skill (rich, loads on demand)
Save/restore (relay-race development)
End every session on purpose; open every session where you left off:
/context-savebefore closing, writes down what was done, what was decided, what's next/context-restorewhen opening, picks the baton straight back up
This pair is how you get a fresh, sharp window without losing the plot. Many short, sharp sessions beat one long one losing its mind.
No-tools fallback (works in any agent, forever): end with "summarise
what we did, what we decided, what's next, and which files the next
session should NOT bother re-reading", save it as HANDOFF.md, and paste
it into the fresh session.
Token economy (the same habits, priced)
- Unused skills / MCP servers tax every message → uninstall what you don't use; prefer CLI tools (cost nothing until used)
- Whole-folder reads are the expensive habit; named files are the cheap one
- Re-explaining your project every session is what CLAUDE.md and
/context-saveexist to eliminate, and when a project outgrows both,/setup-gbraingives it a queryable long-term memory (index, not archive, at codebase scale)