$ recombobulate _
home / tips / add-custom-compaction-instructions-to-preserve-key-context
0

Add Custom Compaction Instructions to Preserve Key Context

bagwaa @bagwaa · Mar 26, 2026 · Performance
add-custom-compaction-instructions-to-preserve-key-context

When Claude Code compacts your conversation (either automatically or via /compact), it summarises everything to free up context space. But the default summary might drop details you care about, like specific test output or API response formats.

You can tell Claude exactly what to prioritise:

> /compact Focus on code samples, test failures, and API response shapes

The text after /compact becomes the summarisation instruction. Claude will weight those areas more heavily when deciding what to keep and what to drop.

For project-wide defaults, add compaction instructions to your CLAUDE.md:

# Compact instructions

When you are using compact, please focus on:
- Test output and failure messages
- Code changes and their rationale
- API contracts and type signatures
- File paths that were modified

This way, every automatic compaction in this project preserves the context that matters most to your workflow.

This is especially useful for long debugging sessions where you need Claude to remember specific error messages and stack traces, or for refactoring sessions where the sequence of changes matters.

Don't let auto-compaction throw away the context you actually need.


via Claude Code Docs — Costs

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Filter Test Output with a PreToolUse Hook to Cut Token Costs

A PreToolUse hook can intercept test runner commands and filter output to show only failures, cutting thousands of tokens from Claude's context.

bagwaa @bagwaa · 3 hours ago
0
Move Specialised CLAUDE.md Instructions into Skills to Shrink Context

CLAUDE.md loads into every message. Move workflow-specific instructions into skills that load on demand to reduce token costs across your session.

bagwaa @bagwaa · 3 hours ago
0
Use prompt.id to Trace All Activity from a Single User Prompt

Every event emitted while processing a single prompt shares a prompt.id UUID, letting you trace the complete chain of API calls and tool executions.

bagwaa @bagwaa · 3 hours ago