Claude Code 101
← All lessons
Lesson 06Claude Code 101

Context Management in Claude Code

Summary audio

Spoken summary — press play to read along: the line being spoken stays near the top.

Study notes

Core Concepts

  • Context window = Claude's working memory; limited space that stores files, commands, messages, and tool results
  • Every interaction (prompts, file reads, tool calls) consumes context space
  • Context is automatically compacted when approaching the limit, which summarizes details but may lose information

Key Commands

  • /context – Check current context size, categories using most space, and visual breakdown
  • /compact – Manually summarize and compress context while retaining memory of previous work
  • /clear – Remove all context to start completely fresh without bias from previous work

When to Use Compact vs. Clear

  • Compact: Continuing work on the same feature; keeps context relevant and preserves progress
  • Clear: Finished with a feature and starting something new; prevents previous work from biasing new development

Optimization Strategies

  • Be specific in prompts – Explicit instructions reduce Claude's need to explore the codebase, saving context space
  • **Use Claude. md file** – Store information you want Claude to remember across sessions
  • Disable unused MCP servers – They load all tools into context by default; turn off unrelated ones
  • Use skills instead of MCP servers – Skills save space by not loading entire toolsets into context
  • Delegate with subagents – Run parallel tasks with separate context windows; use for tasks where only the answer matters, not the process

Takeaways

  • Context window is limited working memory – Every prompt, file, and tool result consumes space; monitor with /context and manage proactively to avoid automatic compaction that loses information
  • Use /compact to continue work, /clear to start fresh – Compact preserves progress on the same task; clear prevents bias when switching to new features
  • Be specific in prompts and disable unused tools – Explicit instructions and turning off unrelated MCP servers significantly reduce context consumption
  • **Use Claude. md and skills over MCP servers** – Store persistent information in Claude. md and prefer skills to avoid loading entire toolsets into context
  • Delegate with subagents for parallel work – Run separate tasks in independent context windows when only the final answer matters, not the reasoning process
Flashcards 10 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions