Context Optimization
Strategies for maximizing effective context usage.
With 1M context windows (Max 20x and Enterprise subscriptions), compaction is rare — most sessions complete well within the available context. Pilot Shell's optimization strategies focus on keeping context lean so Claude spends tokens on your code, not on overhead.
Token Reduction
Pilot Shell reduces context consumption at multiple levels:
| Strategy | Savings | How |
|---|---|---|
| RTK proxy | 60–90% | Rewrites dev tool output (git status, npm test, etc.) to remove noise before it enters the context window |
| Conditional rule loading | Variable | Coding standards load only for matching file types — Python rules don't load when editing TypeScript |
| Progressive skill disclosure | ~90% | Skill frontmatter (~100 tokens) loads always; full SKILL.md loads only on activation; linked files load on demand |
| Scoped MCP tools | Variable | MCP tool schemas are lazy-loaded via ToolSearch — only fetched when needed, not preloaded |
Context Display
The status line shows context usage as a visual progress bar:
Opus 4.6 [1M] | █████░▓ 60% | ...
Claude Code reserves ~16.5% of the context window as a compaction buffer, triggering auto-compaction at ~83.5% raw usage. Pilot Shell rescales this to an effective 0–100% range so the bar fills naturally to 100% right before compaction fires. A ▓ buffer indicator shows the reserved zone. The context monitor warns at ~80% effective (informational) and ~90%+ effective (caution).
Compaction Resilience
When compaction does fire (more common on 200K windows), Pilot Shell preserves state automatically:
PreCompact → Compact → SessionStart(compact)
- PreCompact —
pre_compact.pycaptures active plan, task list, recent decisions, and key context to Pilot Shell Console memory. - Compact — Claude Code summarizes conversation history. Preserves recent tool calls and conversation flow.
- SessionStart(compact) —
post_compact_restore.pyre-injects Pilot context: active plan path, task state, key decisions. Work resumes seamlessly.
Memory observations (decisions, discoveries, bugfixes) persist independently in SQLite — they survive compaction regardless of hooks.
Parallel Sessions
Multiple Pilot Shell sessions can run on the same project without interference. Each session has its own context window, task list, and plan state. The Console dashboard tracks all active sessions.
Context limits are not an emergency — auto-compaction preserves everything and resumes seamlessly. Finish the current task with full quality. The only thing that matters is the output, not the context percentage.