
What to check when Claude Code context feels low
When Claude Code forgets instructions or context fills fast, run /context before /compact. Check CLAUDE.md, auto memory, MCP, logs, and whether this is still one task.
Hyuk · · 7 min read · Code · Updated
When Claude Code forgets the last instruction, rereads a file it already edited, or makes worse edits as the session goes on, the usual diagnosis is “context is low.” That is two different problems.
Either the window is actually full, or the facts Claude needs never entered it.
A larger context window does not fix the second one. It also does not fix a session stuffed with logs, leftover tasks, and a CLAUDE.md that grew into a wiki.
This is a checklist against Anthropic’s current Claude Code docs. Run /context before you reach for /compact.
Two different problems
The window is full. /context shows most of the budget already used. Then /compact, /clear, a subagent, or fewer MCP servers actually help.
The window is fine, but the briefing is missing. Usage can sit around 40% while Claude still does not know the architecture, the test command, or a decision from last session. Then you want CLAUDE.md, auto memory, .claude/rules/, skills, or a tighter prompt, not a bigger model window.
Ask that split first. The rest of the checklist is how to tell which one you have.
Start with context
/contextThe command visualizes current usage as a colored grid and suggests cuts. It lists which CLAUDE.md and auto memory files loaded. Pass all if the per-item breakdown is collapsed.
A lot of that space is filled before you type. The docs walk through a typical startup mix: the system prompt, auto memory, environment info, MCP tool names, skill descriptions, your user CLAUDE.md, and the project CLAUDE.md. Then every file read, path-scoped rule, hook payload, test log, and follow-up stays in the same window.
Do not treat “context is low” as a reason to compact on instinct. See what is expensive.
Watch the window
/usage/usage shows session cost, plan limits, and activity stats. /cost and /stats are aliases. On Pro, Max, Team, or Enterprise it also breaks usage down by skill, subagent, plugin, and MCP server.
If you want the percentage in view while you work, ask Claude Code to build a status line:
/statusline show model name and context percentage with a progress barThe script reads context_window.used_percentage from session JSON. That field is input tokens only. It does not include output tokens. The status line itself does not consume API tokens.
One task per session
Old turns are not free. They are resent on every later request. Anthropic’s own cost writeup is blunt: one long session costs more than the same work split across a few short ones, because turn 40 is also re-reading the 39 turns before it.
When the next job is unrelated, start a new conversation:
/rename auth-feature
/clear/clear wipes the chat and keeps project memory. You can also pass the name on /clear itself: /clear auth-feature labels the previous conversation in the /resume picker. /resume brings an earlier session back.
Treat one clear unit of work as one session. Not one repository as one immortal thread.
Compact with a focus
Claude Code compacts automatically as you approach the limit, so a full window does not end the session. You can also run it yourself, and you should if you want a say in what survives.
/compact Focus on current architecture decisions, modified files, test failures, and remaining tasks.Without instructions, the summary keeps what the automatic pass guesses is important. Compaction is lossy. Full tool outputs and intermediate reasoning go away.
You can put standing rules in CLAUDE.md:
Compact instructions
When compacting:
- Preserve architecture decisions
- Preserve modified file paths
- Preserve unresolved errors
- Preserve the current implementation plan
- Preserve test resultsProject-root CLAUDE.md, unscoped rules, and auto memory are re-read from disk after compact. Path-scoped rules and nested CLAUDE.md files are not. They return the next time Claude reads a matching file. Chat-only instructions do not come back unless you wrote them down.
If you only need to drop the last few bad turns, /rewind is cheaper than compact. Rewind cuts from the end, so the prompt cache in front of those turns can stay. Compact rewrites the conversation.
For a question that should not stay in history at all, /btw answers on the side and never appends to the transcript.
Keep CLAUDE.md short
CLAUDE.md is loaded at the start of every session. Anthropic’s target is under 200 lines per file. Longer files consume more context and reduce adherence. Claude Code skips a file over 4 MiB. /doctor can propose trims for a checked-in file: it cuts things Claude can derive from the repo and keeps pitfalls and conventions.
Put facts Claude should hold every session: build and test commands, conventions, a short architecture note, hard constraints, known gotchas.
Do not put full API docs, changelogs, or a multi-step workflow that only matters sometimes. Those belong in a skill or a path-scoped rule under .claude/rules/. Skills load on demand. Path-scoped rules load when Claude reads a matching file.
@path imports in CLAUDE.md still enter context at launch. They organize the file. They do not shrink the window.
Check auto memory
CLAUDE.md is what you write. Auto memory is notes Claude writes for itself: preferences, corrections, project facts it cannot derive from the code.
Both load at the start of a session. Auto memory is not the whole directory. Only the first 200 lines or 25KB of MEMORY.md, whichever comes first, are injected. Topic files next to the index load on demand. If the index is over the limit, the extra lines are dropped on the next load.
The files live under ~/.claude/projects/<project>/memory/. They are plain markdown. Run /memory to browse, edit, or delete them. Stale notes in the index are still startup context.
Turn off idle MCP servers
MCP tool search is on by default. At startup Claude sees tool names and server instructions. Full JSON schemas stay deferred until a task needs them. That is not permission to leave every server connected.
Run /mcp and disable anything this session does not need. Run /context all to see how many tokens each loaded MCP tool uses.
Anthropic still prefers a CLI when one exists. gh, aws, gcloud, and sentry-cli add no per-tool listing. Claude can run them as shell commands.
Park noisy work in a subagent
Command output enters the conversation the same way a file read does, and it stays for the rest of the session. Anthropic’s sessions post notes that outputs over 30,000 characters are written to a file, with only a preview and a path left in the chat (BASH_MAX_OUTPUT_LENGTH changes that). The pain is everything under that cap: a test runner that prints hundreds of passing lines still lands in every later turn.
Delegate research, log greps, and test runs to a subagent. It gets its own window. The main session gets a summary and a small metadata trailer. The file reads stay behind.
Ask for it when Claude does not reach for one: “go through this log in a subagent.” For a job you hand off often, give that subagent its own definition and a cheaper model.
Narrow the search
“Find problems in this project and improve them” is a license to read src, lib, tests, and config. Each of those reads stays.
Name the file, the function, and what “fixed” looks like. @-mention a path you already know so the file is attached on the first request instead of found with a search plus a Read. Anthropic’s costs page is explicit: vague prompts trigger broad scanning; specific ones let Claude work with fewer file reads.
Use code intelligence
If Claude keeps rereading the same files, the task may be too wide, or it is searching by text instead of by symbol.
On a typed language, install a code intelligence plugin. That turns on Claude Code’s LSP tool: go to definition, find references, hover types, list symbols. The costs docs say one “go to definition” call can replace a grep plus several candidate file reads. Language servers also report type errors after edits, so Claude can notice a break without running a compiler.
Compact versus clear
Same task, window filling up: /compact with a focus.
Task changed: /clear.
Anthropic’s help center puts it as one task per conversation. Best practices add a second rule: if you have corrected Claude more than twice on the same issue, /clear and write a better first prompt. A clean session with a sharper brief almost always beats a long one full of failed approaches.
/clear is not a delete of the project. CLAUDE.md and auto memory reload. The previous chat is still reachable with /resume if you named it.
Design the layers
On a large repo, stop trying to keep every fact in the main window.
- Always on: a short project
CLAUDE.mdplus unscoped rules - When the file matches:
.claude/rules/withpaths:frontmatter - When invoked: skills
- This task only: the main session
- High-volume work: subagents
The job is not to make Claude hold everything. The job is to put the right briefing in at the right time.
A bigger window still holds junk if you put junk in it. The model then has to rank signal against noise on every turn. Manage what enters the window. Do not wait for a 1M variant to paper over a kitchen-sink session.
Source cutoff: Claude Code context, memory, commands, costs, best-practices, statusline, MCP, and plugin docs, plus Anthropic’s August 14, 2026 sessions post and the CLAUDE.md help article, as retrieved August 23, 2026.
Sources
- Claude Code — Explore the context window
- Claude Code — How Claude remembers your project
- Claude Code — Commands
- Claude Code — Manage costs effectively
- Claude Code — Best practices
- Claude Code — Customize your status line
- Anthropic — Maximizing the value of your Claude Code sessions
- Anthropic Help Center — Give Claude context
Related
Comments
Comments are off until Giscus is configured.