Chapter 1: Ground Zero
Context and Memory
Context and Memory
Claude Code is powerful, but it has a fundamental constraint: the context window. Understanding how it works will make you dramatically more effective.
What is the context window?
The context window is the total amount of text Claude Code can "see" at once. Think of it as Claude Code's working memory. Everything in your conversation -- your prompts, its responses, file contents it has read, command outputs -- all of this lives in the context window.
The context window is large (up to 200K tokens), but not infinite. A very long conversation with lots of file reads will eventually fill it up.
What fills the context window
Every interaction adds to the context:
| Action | Context cost |
|---|---|
| Your prompt | Small |
| Claude Code's response | Medium |
| Reading a file | Depends on file size |
| Command output | Depends on output length |
| Error messages and stack traces | Can be large |
Large files, verbose error outputs, and long conversations are the fastest ways to fill your context. Be mindful of what you ask Claude Code to read.
Why CLAUDE.md matters (again)
Remember CLAUDE.md from the Understanding CLAUDE.md section? Here's the deeper reason it matters:
CLAUDE.md is loaded at the start of every session. It gives Claude Code essential project knowledge without you having to re-explain everything. Without it, you'd waste context on setup every time.
- Session 1: You explain your project structure, conventions, and patterns to Claude Code
- Session 2: Without CLAUDE.md, you explain it all again. With CLAUDE.md, Claude Code already knows.
- Session 10: The savings compound. CLAUDE.md has paid for itself many times over.
Think of CLAUDE.md as persistent memory that survives between sessions. The context window is short-term memory. CLAUDE.md is long-term memory.
Keeping conversations focused
Here are practical strategies for managing context effectively:
One task per conversation
Don't try to build your entire app in a single conversation. Break work into focused tasks:
- "Add the todo creation form" (one conversation)
- "Add the delete functionality" (another conversation)
- "Style the todo list" (another conversation)
Use /compact regularly
When your conversation gets long, run /compact to summarize and trim. You keep the important context without the bloat.
Be specific with file reads
Instead of "look at all my components", say "look at src/components/TodoItem.tsx". Targeted reads use less context than broad scans.
When to start fresh
Start a new session when:
- You're switching to a completely different task
- Claude Code seems to be "forgetting" earlier instructions
- Responses are getting slower or less accurate
- You've been working for a long time and the conversation is very long
Starting fresh isn't failure -- it's good practice. Each new session gets a clean context window plus your CLAUDE.md, which is often all Claude Code needs.
Referencing specific files
When you want Claude Code to focus on a specific file, use the @ syntax:
"@src/app/page.tsx what does this component render?"
"Compare @src/components/TodoList.tsx and @src/components/AddTodo.tsx — are they following the same patterns?"
The @ prefix tells Claude Code to read that file into context immediately. This is faster than saying "look at the file at src/app/page.tsx" and ensures Claude Code has the exact file contents when formulating its response.
Use @ when you know exactly which file you're asking about. It's especially useful when your question spans multiple files — Claude Code will load all the referenced files before answering.
The golden rule
Keep your conversations short, focused, and task-oriented. One clear task per session beats a marathon conversation every time.
You now understand the fundamentals of how Claude Code thinks and remembers. Let's put everything together with a chapter review.