The Context Window
Claude Code has a large context window — but it’s shared across everything:| Source | Cost |
|---|---|
| System prompt | Fixed (~50 instructions) |
| CLAUDE.md files | Fixed (loaded at launch) |
| Active skill content | Pay-per-use (loads on trigger) |
| Conversation history | Growing (accumulates over time) |
| Tool results | Variable (file reads, command output, search) |
/compact
When the conversation gets long or unfocused, run /compact. It:
- Summarizes the conversation so far
- Frees context for new work
- Re-injects CLAUDE.md from disk (so your instructions survive)
@imports in CLAUDE.md
The @path/to/file syntax in CLAUDE.md enables inline file expansion. Use it for detailed docs that shouldn’t be in the main CLAUDE.md body:
Large Codebases
- Break work into focused sessions. Don’t try to refactor 20 files in one conversation.
- Point Claude to specific files. “Look at
src/auth/middleware.ts” beats “find the auth code.” - Use agents for exploration. The Explore agent reads many files without polluting your main context.
- Commit between tasks. Gives you a clean rollback point and lets you
/compactwithout losing work.
Signs You’re Running Low
- Claude starts forgetting earlier instructions or decisions
- Responses become less specific or repeat generic advice
- Claude asks questions you already answered
- Tool results are getting truncated
/compact and refocus.
Context as Infrastructure
Context isn’t just “how much Claude remembers” — it’s infrastructure you architect around. Auto-compaction triggers at ~83.5% capacity with a ~33K token buffer. For long-running agentic sessions, this means:- Front-load high-leverage context (CLAUDE.md, skills) — they survive compaction and get re-injected
- Keep tool output concise — verbose
npm testoutput burns context that could hold conversation state - Compact between tasks, not mid-task — compaction mid-flow loses decisions and rationale
The Token Budget Mental Model
Think of context as a budget:- Cheapest: CLAUDE.md pointers and skills (fixed cost, high leverage)
- Mid: Targeted file reads (pay once per read)
- Expensive: Pasting large files into the chat (burns fast, not reusable)
← Prev: Workflow Patterns · Next: Session Management →