Claude context limit recovery: inspect, compact, or restart.
If a Claude Code conversation is getting too large, use Claude's own context tools first. Check what is consuming space with /context, compact the current conversation with /compact, or start a fresh one with /clear. Save the repository state before discarding anything you may need.
What the context limit means.
Claude Code sends the active conversation, relevant instructions, and tool results into a model context window. Standard Claude models commonly use a 200K-token context window, while extended-context models or plans can have a different limit. The active model and configuration determine the actual budget. The number is a capacity limit, not a promise that every token of a long chat remains equally useful. A transcript full of old tool output and abandoned attempts can make the current task harder to follow before a hard limit is reached.
Context capacity and account usage are separate. A rate limit or exhausted plan allowance may block new requests even in a short session. A prompt-too-long or context warning concerns what is being sent to the model now. Diagnose which one you have before choosing a recovery path. The Claude usage-limit guide covers the quota case.
First, inspect the live session with /context.
In Claude Code, run /context while the session still accepts commands. Anthropic documents it as a view of current context usage and optimization suggestions. It can show whether tools, persistent instructions, or accumulated conversation are taking space. Use its output to decide what to keep; it does not itself reduce the context. If a large tool result is merely diagnostic noise, record its useful conclusion and the command needed to reproduce it. If project instructions have duplicated or obsolete material, review them, but do not delete essential rules just to make a warning disappear.
Before compressing or clearing the session, note the active goal, changed files, last observed failure, tests already run, tests still pending, and the next decision. For a Git project, git status --short tells you what is modified, and git diff --stat shows the scope. Read git diff for the actual changes. None of these commands tells you why an edit was made, so preserve decisions and rejected approaches separately when they matter.
Use /compact when you want to stay in the conversation.
/compact summarizes earlier conversation to free space in the current Claude Code session. You can pass focus instructions, for example /compact keep the current goal, failed test output, changed files, and rejected approaches. It is the least disruptive built-in option when the session is still healthy and you want to continue the same task. After compaction, ask Claude to restate the current goal and next check, then compare that answer with the repository and your own notes.
Compaction is lossy by design. It can retain the broad plan yet omit the exact failing command or the reason a common approach was rejected. Do not treat a compacted claim such as “tests passed” as a test result. Find the command output or rerun the relevant check. If the condensed session makes a confident claim that conflicts with current files, stop dependent edits until you resolve the conflict.
Claude Code can also compact automatically as the context fills. That helps an ordinary long session continue, but it does not turn every old assertion into verified state. If auto-compaction has already happened, inspect the resulting brief and the checkout before asking for more changes. A second manual compaction of an already confused session may remove more detail without fixing an incorrect assumption.
Use /clear for a fresh context, not for preserving the old one.
/clear starts a new Claude Code conversation with an empty conversation context. It is useful when a task is complete or the active thread is too noisy to salvage. It does not undo your repository edits. It also does not automatically transfer the previous chat's reasoning into the new one. Give the fresh session a short task brief and ask it to inspect current files before editing. If your task is unfinished, create the brief before running /clear.
A good first prompt is specific: “Inspect the current branch and diff. The goal is X. Files A and B changed. Command Y failed with output Z. We rejected approach Q because of R. Verify the current state, then do only the next step S.” That is more actionable than pasting an entire transcript, and it gives the model a way to check your claims.
If resuming reports “prompt too long.”
A resumed Claude Code session can still be overfull. Anthropic's issue #92434, checked September 13, 2026, reports a macOS case where loaded instructions contributed to a context overflow. The reporter said a manual /compact worked for that case. It is an individual report, not proof of a universal defect or a shipped fix. Record your version and exact error before trying the workaround.
- If the session accepts commands, preserve the repository checkpoint and try
/compactonce with focus instructions. - If compaction fails or the same error returns, stop retrying the oversized prompt. Start a new session with a lean brief.
- Review project instructions and large pasted logs for avoidable duplication. Keep security and project constraints intact.
- In the new session, verify the branch, diff, and test status before continuing.
When the old session is inaccessible, Claude's in-session commands cannot be run there. That does not mean the coding work is gone. Your working tree and recent commits can still be inspected directly. If the session history is available, Claude Code's resume options may help recover intent, but repository evidence remains the check for what actually changed.
Choose the smallest built-in path that fits.
Still responsive
Run /context, save a checkpoint, then use /compact if you need to continue this conversation.
Already compacted
Compare the retained summary with the diff and tests. If it dropped a critical constraint, write that constraint down before more edits.
Too noisy to trust
Prepare a short verified brief and use /clear or start a new session. Do not import the full chat by default.
Command will not run
Inspect Git, files, and local notes outside Claude. Mark missing conversation-only decisions as unknown.
Build a handoff that survives a clean restart.
Keep six fields: current goal, exact stopping point, files and diff, decisions and constraints, verification results, and one next action. Record failed attempts only when they prevent an obvious retry. Name the branch and commit when multiple checkouts exist. If a test failed, include its command and observed output; if a test was not run, say so explicitly. Do not use “verified” to mean that an AI said it was done.
Give the new Claude session inspection work before edit work. Ask it to locate the named files, compare your brief against the diff, and run a focused safe check. Only after it confirms the state should it continue the implementation. This protects against both dropped context and a stale human handoff note. The handoff-file guide has a reusable field structure, and summary recovery covers missing decisions.
When ShardStitch becomes useful.
The built-in commands should be the first choice when Claude's session is healthy and you want to stay in Claude. ShardStitch is an optional path when the old session cannot answer, its summary is unreliable, or you need to move to another tool. It reads surviving project state and creates a continuation packet with verified disk facts separated from inferred intent. It cannot recreate a decision that was never saved anywhere, and it does not replace a focused test of the current code.
Sources and scope.
Anthropic's Claude Code command reference documents /context, /compact, and /clear. Its session guide explains local session history. The 200K figure is a common standard-model context size, not a guarantee for every model or configuration. Product behavior and limits can change; check the commands and active model in your own installation.
FAQ.
Does /context free tokens?
No. It shows what uses the current window. Use /compact to summarize earlier turns or /clear to start a fresh conversation.
Will /compact save my exact test results?
Do not assume so. Save the command and output yourself and rerun the relevant check when possible.
Does /clear delete my code changes?
No. It clears conversation context, not the repository working tree. Confirm that the new session opens the correct checkout before asking it to edit.
Is every Claude context window exactly 200K tokens?
No. The active model and configuration determine the limit. Use the current documentation and /context rather than treating one number as universal.