Claude Code "Context Limit Reached": How to Continue in a New Session Without Losing Progress

Hit "Context limit reached" in Claude Code? Here is what /compact, /clear and claude -c really do, and how to start a new session without losing what was finished, tested and next.

Kumar NihalNovember 23, 20266 min read
On this page

When Claude Code reports that the context limit is reached, run /compact (optionally with a focus) or /clear to continue, or start a new session and resume from saved state. /compact keeps a summary, while /clear starts empty. Neither guarantees the next session knows what was finished and tested, so record progress outside the chat.

Last updated: November 23, 2026 · Written by Kumar, founder of Causly. Disclosure: I build PCSKit, which is mentioned below.

Quick answers: what should I do right now?#

Your situationDo this
Same task, you need more room/compact focus on what you are doing next
Switching to unrelated work/clear
You closed the terminal and want the same conversation backclaude -c (most recent in this directory) or claude -r "<session>"
You want to see what is using the space/context
You want a fresh session that still knows what is done, tested and nextSave state outside the chat, then resume from it (see below)

What does "Context limit reached" mean in Claude Code?#

Everything Claude knows about your session sits in one context window: your instructions, the files it read, its own replies and tool output. When that window is nearly full, there is no room left for the next step. The message people report is "Context limit reached · /compact or /clear to continue" (see this bug report).

Claude Code normally compacts automatically as you approach the limit, so a full window does not have to end your session. If you do hit the wall, or you want control over what survives, you have the options below.

What happens when the context window fills up?#

According to the Claude Code docs, compaction replaces the conversation with a structured summary. After that:

  • CLAUDE.md at the project root and auto memory are re-injected from disk.
  • Claude Code re-reads up to five of the files Claude read or edited, most recently modified first.
  • Path-scoped rules and nested CLAUDE.md files are loaded into the conversation when triggered, so compaction summarizes them. If a rule must persist, put it in the root CLAUDE.md.

The conversation itself, including the reasoning behind decisions, becomes a summary.

How do I continue with /compact?#

Run /compact with instructions about what to keep:

text
/compact focus on the auth bug fix and the failing refresh-token test

The summary then keeps what you chose, instead of what the automatic pass guesses matters. Anthropic recommends compacting proactively, with a description of where the work is heading, because automatic compaction can drop details when the model cannot predict your next step. Their session management article gives the example of a summary losing a warning from an earlier debugging session.

You can also compact earlier by setting the auto-compact window with /autocompact, for example /autocompact 500k (see the docs for accepted values).

How do I continue with /clear?#

/clear starts a new session. Nothing carries over except what you write into your first message, so it is more work than /compact, but it avoids a lossy summary. It is the right choice when you move to unrelated work. Old conversation takes up space the next task needs, and costs tokens on every message.

How do I resume the same conversation later?#

  • claude -c continues the most recent conversation in the current directory.
  • claude -r "<session>" "query" resumes a session by ID or name, for example claude -r "auth-refactor" "Finish this PR".

Both bring back the old conversation. If that conversation is already at the limit, resuming it does not give you free room.

Why do I lose progress when I start a new session?#

A new session starts without the old conversation. Three things usually go missing:

  1. What was actually finished. The old agent said "done", but did the tests run?
  2. What was in flight. The file it was halfway through editing.
  3. What not to touch. The constraint you explained once, early on.

The usual workaround is asking the agent to write a summary before it runs out of room. That summary is a claim, written by the agent under the most pressure. It can say tests pass when they never ran.

How do I continue in a new session without losing progress?#

Keep a record of the project that does not live in the chat. Whatever you use, carry these over:

  • The original task
  • What is done, and how you know (a test run, not a claim)
  • What is in progress, and which files are uncommitted
  • Failing tests and open problems
  • Do-not-touch notes
  • Exact next steps

You can do this by hand in a file. PCSKit (Project Continuity Kit) automates it: it records git state, file hashes and test runs while the agent works, then builds the handoff from that evidence.

text
npm install -g @knihal/pcskit
cd your-repo
pcs init
pcs connect claude-code
pcs hooks install

With hooks installed, Claude Code sessions start, checkpoint and end by themselves. While you work:

text
pcs task add "Add the --json flag to the exporter"
pcs test --task 1 -- npm test
pcs note add next "Wire the flag into the CLI entry, then add tests"

When the limit hits:

text
pcs session end --reason limit
pcs handoff

In the new session, run:

text
pcs resume --agent claude

With MCP connected, the agent calls pcs_resume itself. pcs resume --prompt prints a ready-to-paste takeover prompt. Resume checks the handoff against the evidence log and labels every line verified, reported or inferred. A task counts as verified only if a passing test run that PCSKit executed is linked to it and the code has not changed since.

PCSKit does not restore the old conversation. It restores the state of the project and what is known about it. If an agent died before writing a handoff, PCSKit builds one from the evidence log and marks the interrupted session as inferred.

/compact vs /clear vs claude -c vs a handoff#

Keeps conversationSeparates verified from claimedFresh contextEffort
/compactAs a summaryNoPartlyLow
/clearNoNoYesYou write a brief
claude -c / -rYesNoNoLow
Evidence-based handoffNoYesYesOne command (pcs resume)

FAQ#

What does "Context limit reached" mean in Claude Code?#

The context window is nearly full. Run /compact or /clear, or let automatic compaction run.

Does Claude Code compact automatically?#

Yes. It compacts as you approach the limit, so a full window does not have to end the session. You can also compact earlier yourself.

Does /compact lose information?#

It is lossy: the conversation becomes a summary. CLAUDE.md and auto memory are reloaded from disk, and Claude Code re-reads up to five recent files.

What is the difference between /compact and /clear?#

/compact keeps a summary of the conversation. /clear starts a new session with nothing carried over except what you write.

How do I get yesterday's session back?#

Use claude -c for the most recent conversation in the directory, or claude -r "<session>" by ID or name.

Does a bigger context window fix this?#

It gives you more room. Some models support a 1M-token window, but Anthropic notes that context rot can still happen as context grows, so compacting proactively still helps.

Does PCSKit send my code anywhere?#

No. It is local-first, with no network access and no telemetry. Data lives in .pcs/ inside your project.

Sources#

Share
Kumar Nihal

Written by

Kumar Nihal

AI-first software engineer and founder of Causly. I build software, SaaS and AI systems, and write about it here. More about me

Get new posts by email

High-signal notes on AI, automation and building systems. No spam.

Keep reading

Insight

Why I Built PCSKit: Solving Context Loss in AI Coding Sessions

AI coding agents are productive, but their work can lose continuity when a context window fills up, a session gets interrupted, or developers switch between tools. I built PCSKit to solve this problem with local-first project continuity, evidence-based handoffs, and verifiable development history—so the next AI agent can continue from the actual project state instead of relying on an unreliable summary.

Nov 24, 2026
Insight

AI Coding Agent Handoffs: Why HANDOFF.md Needs Verifiable Evidence

Learn how to preserve context across AI coding agent sessions with reliable handoffs. Explore the limitations of traditional HANDOFF.md files, why task summaries aren't enough, and how Git state, test results, file changes, and verifiable evidence help agents resume development work with greater confidence.

Nov 24, 2026
Insight

MCP Tool Annotations Explained: Practical Examples, Defaults, and Security Best Practices

Understand MCP Tool Annotations and how they influence AI agent interactions with tools. Learn the four core annotations — readOnlyHint, destructiveHint, idempotentHint, and openWorldHint — with practical JSON examples, default behaviors, security considerations, common mistakes, and testing strategies for building reliable Model Context Protocol servers.

Nov 24, 2026