Blog · August 5, 2026 · 6 min read · by Vilva Athiban P B

Claude Code Context Management: Treat the Context Window Like a Budget

Most advice about Claude Code is about prompting: brief it well, plan first, be specific. All true. But after enough hours in the terminal, a different constraint starts dominating everything else, and almost nobody budgets for it deliberately: the context window.

Here's the opinion this whole piece hangs on: context is a budget, and most people spend it like it's free. Sessions rarely fail loudly. They degrade. Claude starts forgetting a decision from twenty minutes ago, re-reads files it already read, drifts from the conventions you agreed on. That's not the model getting dumber mid-session — it's a budget quietly running out, and everything you loaded "just in case" is what spent it.

You're spending tokens before you type anything

Claude Code's context window is 200,000 tokens by default (newer models can go higher), which sounds like more than anyone could need. But a surprising slice of it is gone before your first prompt. At session start, Claude loads the system prompt, your CLAUDE.md files at every level — user, project, and any nested ones — its own auto-memory notes, the tool definitions for every MCP server you've connected, and the descriptions of every skill you've installed.

None of these are individually large. Together they add up, and they're charged on every single session whether the task needs them or not. Run /context in a fresh session sometime and look at the breakdown before you've typed a word. That's your fixed overhead — your rent. Everything you actually do — reading files, running commands, iterating on a fix — comes out of what's left.

The practical consequence: every MCP server you connect "in case it's useful" and every paragraph you leave in CLAUDE.md because deleting feels risky is a recurring charge against every future session. Treat it that way.

The CLAUDE.md failure mode: it only ever grows

A briefing file is one of the first things worth setting up in Claude Code, and it stays the highest-leverage file in the repo. But CLAUDE.md files have a failure mode nobody warns you about: they grow monotonically. Every incident adds a rule. Every new teammate adds a section. Nothing ever gets removed, because nobody is sure which line is load-bearing.

The result is a file that reads like a wiki and performs like a tax. Worse, a bloated briefing doesn't just cost tokens — it dilutes itself. Twenty crisp rules get followed; two hundred paragraphs of mixed instruction, history, and trivia get skimmed. The file meant to make every session smarter is now making every session heavier and vaguer at the same time.

The fix is editorial, not technical. Treat CLAUDE.md like an API, not a wiki: small, stable, and versioned with intent. Keep only what applies to most sessions — build commands, hard constraints, the two or three conventions Claude genuinely gets wrong without help. Everything situational goes in separate docs that Claude can pull in on demand (imports with the @path syntax work well for this), so detail is available when a task needs it and costs nothing when it doesn't. And prune it on a schedule. A quarterly deletion pass does more for session quality than any prompt trick.

Auto memory: useful, but audit it

Newer Claude Code versions also keep notes of their own — an auto-memory file per project where Claude records things it figured out: build quirks, corrections you made, patterns that worked. This is genuinely useful, and it compounds nicely with a lean CLAUDE.md: you write the constitution, Claude keeps the field notes.

But it's still budget. Only the top of the memory file is loaded at startup — roughly the first couple hundred lines — so a memory file full of stale observations crowds out the notes that still matter. It deserves the same treatment as your briefing file: open it occasionally (the /memory command gets you there), delete what's obsolete, and promote anything universally true into CLAUDE.md proper.

Compaction is a tax, not a feature

When a session approaches the limit, Claude Code compacts — summarizing older conversation to free space. It's a good safety net. It is a terrible thing to rely on. A summary is lossy by definition: the exact error message from an hour ago, the reason you rejected an approach, the precise wording of a decision — some of that survives compaction and some doesn't, and you don't get to choose which.

So here's the second opinionated claim: if auto-compact fires regularly in your sessions, your sessions are scoped too big. The answer usually isn't a bigger window — it's smaller units of work. Finish a task, have Claude write down anything worth keeping, then /clear and start the next task fresh. A clean 200k window with a two-line handoff note beats a twice-compacted marathon session every time. For genuinely large jobs, subagents are the structural version of the same idea — exploration and research burn a subagent's context, and only the conclusion comes back to your main session.

The honest objection to task-sized sessions is that they create more idle moments — more times when Claude finishes a scoped chunk and waits for you to review, clear, and kick off the next one. If you're watching the terminal, that's friction. The fix is to stop watching: run sessions in parallel or go do something else, and let a notification tell you the moment one needs you.

What a lean setup actually looks like

If you want the checklist version of the argument:

  • Run /context once a week. You can't budget what you don't measure. If fixed overhead looks fat, find out which server or file is responsible.
  • Cap CLAUDE.md ruthlessly. Universal rules only; push situational detail into on-demand docs. Delete something every time you add something.
  • Disconnect idle MCP servers. Their tool definitions load every session. Connect the ones this project actually uses, not the ones you might use someday.
  • Prune auto memory monthly. Stale notes crowd out live ones at the top of the file.
  • Prefer /clear over compaction. End tasks deliberately with a short handoff note instead of letting summaries decide what survives.
  • Delegate research to subagents. Let exploration burn disposable context, not your main session's.

Budget, don't hoard

The instinct behind every bloated setup is the same: more context must mean a smarter agent. It's exactly backwards. The best Claude Code sessions are the ones where nearly all of the window is spent on the task in front of it — not on rules for situations that won't come up, tools that won't be called, and summaries of conversations that should have ended an hour ago. Spend deliberately, prune on a schedule, scope tasks to fit the window — and let AI Done Now handle the one part of a short-session workflow that used to be annoying: knowing the moment each session is done.

Keep reading

Desk Exercises for Programmers: 15 Moves to Do While Your AI Agent Codes

7 min read

Exercise While Coding: Turn Claude Code Wait Time Into Micro-Workouts

7 min read

Claude Code Notch Notifications on Mac: See When Claude Is Done Without Watching the Terminal

7 min read

Claude Code Tips and Tricks: 12 Ways to Use Claude Code Effectively

8 min read

Claude Code Multiple Sessions: How to Run Agents in Parallel Without Losing Track

6 min read

A Claude Code Workflow That Doesn't Involve Watching the Terminal

5 min read

Claude Code Hooks: A Practical Guide to Automating Your Agent Workflow

7 min read

Claude Code Auto Mode: Fewer Permission Prompts Without Living Dangerously

7 min read

Claude Code Subagents: How to Delegate Work to Specialized Agents

7 min read

Per-Subagent Model Selection: Route the Grunt Work Down, Keep the Judgment Up Top

7 min read

Skills and Plugins: How to Teach Claude Code Your Way of Working

7 min read

Claude Code Background Tasks: Run Long Commands Without Blocking Your Session

6 min read

Codex CLI Notifications: How to Get a Ding When Codex Is Done or Needs Input

7 min read

Cursor Notification When Done: Every Way to Get Notified When Cursor Finishes

6 min read

Claude Code Notifications: How to Get Notified When Claude Code Finishes or Needs Your Input

6 min read

Want to Be Notified When Claude Responds? How Claude Notifications Work on Web, Desktop, and Mobile

5 min read

Claude Code Notification Scripts: Copy-Paste Recipes for Every Platform

6 min read

Get a Ding the Moment Codex Needs Your Response

6 min read

Get Notified the Moment Claude Code Is Waiting for Your Input

6 min read

“Notifications Are Turned Off for Claude” — Here Is the Fix

6 min read

Codex Sound When Done: Make Codex CLI Play a Sound When It Finishes

6 min read

terminal-notifier + Claude Code: Native macOS Alerts When Your Agent Finishes

6 min read

Gemini CLI Notifications: How to Get a Sound or Alert When Gemini Finishes

6 min read

Get Claude Code Notifications on Your Phone

6 min read

Claude Code Remote Control, Explained

7 min read

preferredNotifChannel: Claude Code's Built-In Notification Setting

6 min read

Claude Code Notifications in tmux and Over SSH

7 min read

Claude Code Effort Levels: Why Your Setting Keeps Getting Ignored

8 min read

Codex vs Claude Code Notifications: How Each One Tells You It Is Done

8 min read

Claude Code Notifications Not Working: A Diagnostic Checklist

10 min read

Claude Code Notifications Inside Your Editor's Terminal

7 min read

CLAUDE_CODE_DISABLE_BACKGROUND_TASKS Explained

7 min read

CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP Explained

8 min read

Cursor Alerts Explained: Every Alert Cursor Raises, and How to Control Them

7 min read

Claude Code Environment Variables: The Groups That Actually Matter

10 min read

Claude Code Notifications on WSL and Windows

9 min read

Claude Code Checkpoints and /rewind

8 min read

Claude Remote Control: How It Works, Turning It Off, and Auto Mode

7 min read

Claude Code /loop: Poll a Deploy, Babysit a PR, and Get Told When It's Done

8 min read

Setting Up NotchFit With OpenAI Codex CLI: Hooks, $notchfit-plan, and the Daily Flow

7 min read

Claude Mods Explained: What the New Plugin Layer Can Do, and How to Turn On 'You Should Know'

9 min read

NotchFit vs Mac Break Reminder Apps: A Clock or a Signal From Your Coding Agent?

8 min read

Claude Code Headless Mode: Running claude -p in Scripts and CI, and the Three Signals That It Finished

10 min read

Building a Movement Habit at a Desk: Use the Agent Run as the Cue, One Set as the Unit, and Streaks Carefully

8 min read

Claude Code MCP Servers Explained: Adding Servers, Choosing a Scope, Handling Secrets, and Why Long Tool Calls Go to the Background

10 min read

/notchfit:plan Explained: How Claude Code or Codex Writes a Weekly Workout Plan the Notch Can Actually Run

8 min read

Claude Code Spinner Verbs Explained: What “Pondering” and “Brewing” Mean, How to Change Them, and Why You Should Stop Watching the Spinner

7 min read

Why NotchFit's Done and Permission Alerts Wait Until Your Set Ends, When That Costs You, and How to Turn the Workout Off

7 min read

How to Resume a Claude Code Session: --continue vs --resume, Naming Sessions, the Session Picker, Branching, and What Comes Back

9 min read

NotchFit on a Mac Without a Notch: How Pill Mode Works on Mac mini, iMac, Mac Studio and a MacBook With the Lid Closed

6 min read

How to Run a Claude Code Session in the Background: /background, claude --bg, Agent View, and Getting Back to It

9 min read

What a Notch App Can See: NotchFit's Local-First Design, What the Claude Code and Codex Hooks Send, and What Stays on Your Mac

7 min read

Why Codex CLI Asks for Permission Every Time, and How to Tune the Sandbox and Approval Policy Without Going Full Access

8 min read

What to Do While Claude Code or Codex Works: A Simple Protocol for the Two-to-Twenty-Minute Gap in Every Agent Run

7 min read

Is It Possible to Get a Notification When Claude Code or Codex Hits a Reset? Yes for Claude Code: the quota_auto_resume Hooks, Explained

8 min read

What a MacBook Notch App Can Actually Do: The Five Kinds of Notch Utility, Their Trade-offs, and Where NotchFit Fits

7 min read

How to Make MCP Servers Not Take Up as Much Context in Claude Code: Tool Search, alwaysLoad, Scopes and Output Caps

8 min read

The notchfit Command Line: Drive Your Workout, Read Status as JSON, Validate Plans and Test the Notch Without Leaving the Terminal

7 min read

How to Audit MCP Tool Calls Made by Claude Code: A Five-Minute Hook Audit Log, OpenTelemetry Tool Events, and the Transcript for Investigations

9 min read

Exercise Snacks: What the Research Actually Says About One-Minute Vigorous Breaks, What It Does Not, and How NotchFit's Agent-Run Sets Compare

8 min read

How Long Until a Claude Code MCP Tool Call Times Out? The Four Timers (Startup, Two-Minute Backgrounding, Idle, Wall-Clock), Their Defaults, and Which One to Change

8 min read

Sitting Too Long as a Developer: The Posture Problems Coding Agents Made Worse, What the Research Says About Breaking Up Sitting, and How NotchFit Turns an Agent Run Into the Break

8 min read

Claude Code .mcp.json Explained: Where Project-Scoped MCP Servers Are Read From, What Happens in Subfolders and Monorepos, and Why a Committed Server Shows Pending Approval

8 min read

Standing Desk Exercises for Developers: Why Standing Still Is Not the Goal, Eight Movements That Fit a Thirty-Second Agent Run, and How NotchFit Cues Them From the Notch

8 min read

The claude mcp Command Reference: add Syntax by Transport, What --scope local, project and user Actually Mean, add-json and add-from-claude-desktop, list, get, remove, login and serve

9 min read

Your First Week With NotchFit: Install and Simulate, Run Real Tasks, Write a Smaller Plan Than You Want, Tune the Alerts, Survive the First Skipped Day, and Decide What Stays

8 min read

How to Stop a Running Claude Code Task: Esc vs Ctrl+C, Background Tasks, Subagents, and Disconnecting Remote Control

8 min read

Pomodoro vs Agent-Driven Breaks: Timing Movement to Claude Code and Codex Runs Instead of a Timer

7 min read

Claude Desktop MCP Configuration: claude_desktop_config.json, Logs, Extensions, and the Difference From Claude Code

9 min read

The 20-20-20 Rule for Developers: Eye Strain, the Evidence, and Agent Runs as the Cue

8 min read

Claude Agent SDK + MCP Servers: mcpServers, allowedTools, Status Checks and Auth

9 min read

Discreet Desk Exercises for an Open-Plan Office While Claude Code Runs

7 min read

claude remote-control Server Mode: Run Claude Code as a Session Server

9 min read

Wrist and Forearm Stretches for Developers: A 60-Second Routine for Every Claude Code Run

7 min read