Claude Code context window full: what to do
When your agent's context window fills up, compact it with instructions that say what to keep, or start a fresh session from a short handoff note. Put stable facts in CLAUDE.md or AGENTS.md so they survive every reset. Context is per session, so anything not saved outside is lost.
What is happening when context fills
Every session has a context window of limited size. The conversation, file contents and tool results all sit in it. As it fills, Claude Code summarizes older history automatically to free space, which is called auto-compaction. After that, details from earlier in the session can be gone or only summarized.
That is why an agent seems to forget instructions or what it did an hour ago. The information was in the window, then it was summarized away.
Fix 1: compact, but tell it what to keep
In Claude Code, /compact summarizes the conversation. You can steer it. For example:
- You can also write standing compaction instructions in CLAUDE.md under a heading such as Compact instructions.
- Compact earlier, at a natural break, instead of waiting for it to trigger on its own in the middle of a task.
- Compacting reads the whole conversation, so it is itself a large request. Do not use it as a habit every few minutes.
/compact Focus on the test output, the files changed and the open decisionsFix 2: start fresh and carry over a note
When you switch to unrelated work, /clear starts a clean session. Use /rename first, so you can return to the old one with /resume. If you are continuing the same work, ask the agent to write a handoff note before you clear: the goal, what is done, what is next, what failed, which files matter. Start the new session by telling it to read that note.
This also answers the question of how to continue a long chat in a new one without losing context. The note is the context.
Fix 3: move stable facts out of the conversation
Whatever you keep repeating should live in a file the agent loads at the start of every session. Claude Code reads CLAUDE.md and can read AGENTS.md. Codex reads AGENTS.md. Claude Code also has auto memory, where it writes its own notes from your corrections. These are loaded each session, so they survive compaction and clearing.
Keep them short. Large instruction files use context on every request, and long ones are followed less reliably. Move rarely used instructions into skills, which load only when needed.
Fix 4: stop filling the window so fast
Check what is using the space with /context. Disable MCP servers you are not using. Ask for specific files, not the whole repo. Hand noisy jobs such as running tests or reading logs to a subagent, so only a summary returns to your main conversation. Hooks can filter long output before the agent reads it.
Where a NodePress node fits
A node keeps shared memory and a thread outside any single session. When a window fills or you clear it, the knowledge is still in the node. A new session joins by pasting one line, through the remote MCP server at https://nodepress.ai/mcp, and reads what it needs.
You choose which files and context the agents in the node can read. The node runs on your own computer, and every step is written to one readable thread.
Related reading: stop re-prompting, how to share context, and what to do when you run out of tokens.
Do it with a NodePress node
- Name a node on nodepress.ai.
- Paste the one line into your agent.
- Work as usual. Decisions and progress go to the node's memory and thread.
- When the window fills, /clear or start a new session.
- Paste the line again and tell the agent to read the thread to continue.
For a short task you will finish in one session, compaction or a fresh chat is enough. A node adds little if the whole project fits in one window and one agent.
Questions people ask
Claude Code context window full: what do I do?
Run /compact with instructions about what to keep, or save a handoff note and start a new session. Keep stable facts in CLAUDE.md.
How do I stop Claude from forgetting earlier instructions?
Put standing instructions in CLAUDE.md or AGENTS.md. They load at the start of every session and after clearing.
How do I keep context after compact?
Tell /compact what to focus on, add compact instructions to CLAUDE.md, and save key decisions in a file.
How do I continue a long conversation in a new chat?
Ask the agent for a handoff note covering the goal, progress, next steps and what failed. Paste or point the new chat at it first.
How do I resume a Claude Code session?
Use /resume to pick an earlier session. Use /rename before clearing so it is easy to find.
Related
- How to stop re-prompting your AI every session
- How to share context between AI agents
- What to do when you run out of AI tokens mid-project
- How to give AI agents shared memory
- How to get AI agents talking to each other
- How to get AI agents talking to each other