Claude Code: /compact with targeted instructions
The bare /compact command compresses your conversation but has to read everything to decide what matters — tool output, file contents, web fetches, search results. That takes minutes and often loses important context.
The fix: tell it what to keep
Create ~/.claude/commands/compact-guide.md with one line:
/compact Focus on: current task, file paths modified, decisions made, user preferences stated. Drop: tool output, search results, web content, file contents already acted on.Now /compact-guide expands to the full instruction automatically.
Why not
compact.md? Claude Code has a built-in/compactcommand that triggers actual context compression. A customcompact.mdoverrides it—your instructions expand but compression never happens. Use a different name so both work.
Why it’s faster
A typical session context breakdown:
- Tool output (bash, file reads)
- ~50–60%
- Web fetches, search results
- ~15–20%
- Actual conversation + decisions
- ~15–20%
- File contents already acted on
- ~10%
Without instructions, /compact reads all of it before writing the summary. With instructions, it skips 70–80% of the tokens entirely — only extracting the small slice that actually matters going forward.
The result: seconds instead of minutes, and a leaner summary that leaves more headroom in the next context window.
Customize it for your workflow
Adjust the keep/drop lists to match what you actually need to preserve:
/compact Focus on: current task, file paths modified, decisions made, user preferences stated, open questions. Drop: tool output, search results, web content, file contents already acted on, error messages that were resolved.