Skip to content
ClaudeClaude

Context Management in Claude Code

Context is Claude's working memory, and managing it well is key to productive sessions. Learn when to use /compact vs /clear and practical tips for keeping your context window lean. Take the full course: claude.com/courses

May 18, 20263mWatch on YouTube ↗

CHAPTERS

  1. What “context” means in Claude Code (the working memory budget)

    The video defines context as Claude’s working memory: everything Claude reads, runs, or receives accumulates in a finite context window. Understanding what contributes to that window is the foundation for managing it effectively.

  2. Why context optimization matters during development

    As you work longer in a session, context can fill up and reduce effectiveness. The video frames context management as a practical necessity to keep Claude focused on the current task.

  3. Automatic compaction: what happens near the context limit

    When you approach the context window limit, Claude Code automatically compacts the session. Compaction summarizes key details and removes less useful artifacts (like verbose tool results) to free space.

  4. Manual compaction with /compact (keep a summary, free space)

    You can compact on demand using the /compact command. This is useful when you want to continue the same feature but need to reduce context usage while retaining a high-level memory of prior work.

  5. Starting completely fresh with /clear (remove prior session influence)

    If you want to reset entirely, /clear wipes prior context so Claude starts without memory of what happened earlier in the session. This helps avoid “bias” from earlier discussions when switching to a new feature or direction.

  6. Inspecting context usage with /context (see what’s taking space)

    The /context command provides visibility into current context size and what categories are consuming it. The video emphasizes using this view to make informed decisions about compacting or clearing.

  7. Rule of thumb: compact to continue a feature, clear to start a new one

    The guidance is simple: if you’re mid-feature and running long, compact to keep momentum with relevant context. If you’ve finished and are starting something new, clear to reset the mental frame.

  8. Persisting important knowledge across sessions with claude.md

    For information you want Claude to remember in future sessions, store it in a claude.md file. This prevents Claude from having to re-discover key project facts each time.

  9. Be specific: shorter prompts can cost more context long-term

    The video highlights a counterintuitive point: overly brief prompts can lead to more context usage. If Claude must explore the codebase and reason more to infer intent, it can consume more context than a couple of explicit sentences would.

  10. MCP servers and tool bloat: turning off unrelated tools

    MCP servers load their available tools into context by default, which can inflate context usage. If you have many unrelated MCP servers enabled, disabling them can save substantial space.

  11. Using skills as a lighter-weight alternative to MCP servers

    Skills are presented as similar to MCP servers but without loading the entire toolset into context. This can preserve context window capacity while still enabling capabilities.

  12. Subagents: parallel work with separate context windows

    Subagents run alongside the main agent with a completely separate context window. They’re ideal for tasks where you only need the answer (not the full investigative trail), returning a concise summary back to the main session.

  13. Practical wrap-up: a workflow for keeping context under control

    The closing consolidates the tactics into a simple operating approach: monitor context, compact long sessions, clear between features, write durable notes in claude.md, be explicit in requests, and delegate via subagents when appropriate.

Get more out of YouTube videos.

High quality summaries for YouTube videos. Accurate transcripts to search & find moments. Powered by ChatGPT & Claude AI.