Skip to main content
Code Guide
M02 Beginner Methodology

Context Management

Managing the context window for efficient sessions

The 4 Context Zones

ZoneThresholdRequired action
🟢 Green0–75%Normal work, no action needed
🟡 Yellow75–85%Suggest /compact
🟠 Orange85–90%Compact without waiting
🔴 Red90%+Urgent, /clear if needed

Context Sources (by priority)

1. ~/.claude/CLAUDE.md Global rules
2. ./CLAUDE.md Project rules (root)
3. subfolder/CLAUDE.md Local rules (cumulative)
4. @file Explicit inline import
5. --context flag File passed via CLI

Management Commands

Terminal window
/compact # Summarize + free ~40% of context
/clear # Full reset (loses history)
/cost # View tokens used / remaining
/status # Detailed context state

Adding Context Intelligently

# In the prompt
@src/auth.ts Look at this function
# Via CLAUDE.md (persistent)
Always read package.json before working on deps.
# Via --context (session)
claude --context "We use TypeScript strict mode"

Strategies by Scenario

Long session (refactor) — Make regular checkpoints with /compact every 30 min. Save important decisions in CLAUDE.md.

Complex debugging — Provide only the relevant files with @file. Avoid loading the entire project at once.

Multi-file — Use agents (--agent) to delegate: each sub-agent has its own isolated context.

What Consumes the Most

SourceImpact
Large files read in fullVery high
Conversation historyHigh
Verbose command outputsHigh
Overly long CLAUDE.mdMedium
Long Claude responsesMedium

Optimizing CLAUDE.md

# Good: short and actionable rules
- Always use TypeScript strict mode
- Prefer pnpm over npm
# Bad: long narrative context
We have been working on this project since 2023
and the team decided after many debates to...

Common Anti-patterns

Do not paste large JSON or raw logs into the prompt — use a temporary file and @file instead. Do not ignore context warnings: at 85%+, response quality degrades noticeably.