Practical guide to understanding what goes into Claude’s context window when you use Claude Code — what you can control, in what order things are loaded, and how to use that knowledge to get better results.
Context Window
The context window is the total amount of text (system prompt + conversation history + tool results) that Claude can see at once. Claude Code manages this carefully:
- The system prompt is split into a static half (cached, never changes) and a dynamic half (rebuilt each turn)
- Older messages are automatically summarised as the window fills up
- CLAUDE.md files and your git status are injected fresh each conversation
Context rot is the gradual degradation of usefulness as a conversation grows longer. The longer you go, the more Claude gets distracted by earlier, now-irrelevant content. Start a new conversation when you change topic.
What Claude Sees — In Order
SYSTEM PROMPT (static — same for every user, cached)
- Who it is and what it does (Intro / Identity)
1 | You are an interactive agent that helps users with software engineering tasks. |
- Rules for tool use and permissions
- How to do tasks (coding style, safety, etc.)
- Tone and output format rules
SYSTEM PROMPT (dynamic — rebuilt each session)
- Session guidance (plan mode, agent tool, skills)
- Your memory files (MEMORY.md)
- Environment: CWD, OS, shell, model name
- Language preference (if set)
- MCP server instructions (if any connected)
- Git status (appended separately)
MESSAGES
- [system-reminder] current date + your CLAUDE.md files
- Conversation history (user turns + assistant turns)
- Tool results (file reads, bash output, etc.)
- Skill discovery hints (when relevant)
The Things You Control
CLAUDE.md — Project Instructions
The most important thing you can configure. Equivalent to Copilot’s copilot-instructions.md.
Loaded fresh at the start of each conversation and injected into the messages as a reminder block. Claude is told it may or may not be relevant — so keep it focused and don’t pad it.
Four tiers, loaded in priority order (later = higher priority):
| Tier | Location | Use for |
|---|---|---|
| Managed | /etc/claude-code/CLAUDE.md |
Team/org-wide rules (set by admins) |
| User | ~/.claude/CLAUDE.md |
Your personal preferences across all projects |
| Project | CLAUDE.md or .claude/CLAUDE.md or .claude/rules/*.md |
Project-specific conventions, checked into source control |
| Local | CLAUDE.local.md |
Your private notes on a project, not committed |
Files closer to your current directory win. Multiple files are all loaded and merged.
What to put in project CLAUDE.md:
- Architecture overview (what the layers are, how they talk to each other)
- Patterns to follow or avoid (“we use X not Y”)
- Where key things live (“API routes are in src/routes/“)
- Testing approach (“always write integration tests, never mock the DB”)
- Things Claude tends to get wrong in your codebase
What not to put:
- Everything — Claude reads the code too, don’t duplicate what’s obvious
- Step-by-step task instructions — those belong in your prompt
- Stuff that changes per-task — use your prompt for that
Splitting with .claude/rules/*.md:
Instead of one long CLAUDE.md you can split by topic:
1 | .claude/ |
All files in the rules directory are loaded automatically.
@include — pulling in other files:
Any CLAUDE.md file can include another file with @path:
1 | @./docs/architecture-overview.md |
The included file is inserted before the including file. Missing files are silently ignored.
Private local notes — CLAUDE.local.md:
Same as CLAUDE.md but not committed to source control. Good for your own reminders about a project without affecting teammates.
Memory Files — Persistent AI Memory
Separate from CLAUDE.md. These are files Claude writes to itself during a conversation to remember things across sessions. Stored in .claude/ inside your project or in ~/.claude/projects/[project]/memory/.
Claude uses a MEMORY.md index file that points to individual memory files. When you ask Claude to “remember” something, it writes a file and adds a pointer to the index.
Injected into the system prompt (not messages), so they count against the static context. Keep them concise.
Types of memory Claude saves:
- user — who you are, your role, your preferences
- feedback — corrections you’ve made (“stop doing X”, “always do Y”)
- project — ongoing work, decisions, deadlines
- reference — where things are (Jira project, Slack channel, dashboard URL)
Environment Info — Automatically Injected
You don’t configure this — it’s added automatically every session:
1 | Primary working directory: /your/project |
Plus your git status — current branch, main branch, last 5 commits, and git status output (up to 2000 characters). Claude uses this to understand where you are in the repo and what’s been changed.
Skills — Slash Commands
Skills are reusable prompt files you invoke with /skill-name. They work like Copilot’s prompt files.
Where to store them:
- Global:
~/.claude/skills/ - Project:
.claude/skills/(checked into source control)
How they work:
- Claude detects when a skill is relevant to your task and surfaces it as a hint
- You invoke a skill with
/skill-nameor by asking Claude to run it - The skill’s content is expanded and used as your prompt
Built-in skills include: /commit, /review-pr, /simplify — you can see these with /help.
Writing your own:
1 | --- |
MCP Servers — External Tools
Model Context Protocol servers extend Claude with additional tools (databases, APIs, services). When connected, each server can provide:
- Additional tools Claude can call
- A block of instructions injected into the system prompt
The instructions section is the MCP server’s equivalent of CLAUDE.md — it tells Claude how to use the server’s tools.
The Conversation Loop
Each time you send a message, Claude:
- Re-reads your CLAUDE.md files and today’s date (injected fresh)
- Looks at git status (injected into system prompt)
- Checks if any memory files are newly relevant
- Checks if any skills are relevant to your current task
- Runs your message through its tools (file reads, bash, etc.) as needed
- Replies
Tool results (file contents, command output) are added to the messages array as user-role messages. The conversation alternates: user → assistant → user (tool results) → assistant → …
Plan Mode
When Claude enters plan mode (EnterPlanMode), it shifts into a design-only mode:
- It can explore the codebase with read-only tools
- It cannot write files or run commands
- It presents a plan for your approval
- You approve with
ExitPlanModebefore it starts implementing
Good for: non-trivial features, anything touching multiple files, decisions where you want sign-off before code is written.
Agent Tool (Subagents)
Claude can spawn subagents to handle parallel or isolated work. Two built-in types:
Explore — fast, read-only codebase research. Use when you need to find something across a large codebase without polluting the main conversation with search results.
Plan — architect-mode subagent that designs implementation plans. Returns a step-by-step plan without writing code.
Subagents get their own context window. Their results are returned as a single message to the main conversation.
Tips
Start fresh conversations often. Context rot is real — a long conversation about one thing will degrade Claude’s performance on the next thing. New topic = new conversation.
Use CLAUDE.md for standing rules, your prompt for the task. Don’t repeat project conventions in every message. Put them in CLAUDE.md once and let Claude find them.
Git status is always visible. Claude always knows your current branch, recent commits, and what files are changed. You don’t need to tell it “I’m on branch X” — it can see.
Claude reads before it writes. The system prompt explicitly tells Claude not to propose changes to code it hasn’t read. If it seems to be guessing, ask it to read the file first.
Skills for repeated tasks. If you find yourself typing the same kind of prompt repeatedly (write a changelog, review this PR, set up a new module), make it a skill.
CLAUDE.local.md for your quirks. If you have personal preferences that aren’t right for the whole team (you like verbose explanations, you want it to always ask before running tests), put them in CLAUDE.local.md so they don’t affect others.