# how to keep claude code from blowing context window

Canonical URL: https://bernstein.run/q/how-to-keep-claude-code-from-blowing-context
Markdown URL: https://bernstein.run/q/how-to-keep-claude-code-from-blowing-context.md
Tags: claude-code, context, tuning

the cause of context blow-up is one long-lived agent doing many tasks. bernstein addresses it structurally: each task gets a fresh claude code subprocess in its own git worktree and exits when the task finishes (typically 1-3 tasks per agent). nothing carries over between tasks except the file system, so context starts near-empty every time. the caching_adapter prefix-dedups across spawns. tokens still grow inside one task; the win is that you stop paying for hour-old prose to be re-attended. source: src/bernstein/core/streaming_merge.py, src/bernstein/adapters/caching_adapter.py.

## Related

- https://bernstein.run/q/how-to-run-multiple-claude-code-agents-in-parallel
- https://bernstein.run/q/how-does-bernstein-work
