Lesson 1: Context Is Everything
This is the single most important concept for working with Claude Code. If you take nothing else from this module, take this.
Fast-track: Already understand context windows,
/clear,/compact,/rewind, and subagents? Skip to Lesson 2.
What is context?
Every time you talk to Claude Code, your conversation fills up a "context window." Think of it as Claude Code's short-term memory. Everything goes in:
- Your messages
- Claude Code's responses
- Files Claude Code reads
- Command output (test results, errors, build logs)
- Tool results
The context window has a fixed size. When it fills up, older content gets compressed or dropped. Claude Code starts forgetting things. Its responses get worse.
The kitchen sink session
Here's what a bad session looks like:
- You start by fixing a bug
- Then you ask Claude Code to add a feature
- Then you ask about a completely unrelated file
- Then you ask it to refactor something
- Then you wonder why Claude Code keeps making mistakes
By step 5, Claude Code's context is full of unrelated information. It's trying to hold the bug fix, the new feature, the unrelated file, and the refactor all in "memory" at once. That's the kitchen sink session โ and it's the number one reason people think Claude Code "stopped working."
The fix: start fresh between tasks
The simplest rule: one task, one session.
When you finish a task and start something unrelated, use /clear:
/clear
This wipes the conversation and gives you a fresh context window. Claude Code forgets everything from the previous task โ and that's exactly what you want.
If the new task is related to what you just did, you don't need to /clear. The rule is about unrelated tasks.
For related work, keep going. The context is useful. But if you notice Claude Code's responses getting worse โ repeating itself, making mistakes it didn't make earlier, or forgetting things you told it โ that's your signal to clear.
Auto-compaction and /compact
When your context gets large, Claude Code automatically compacts it โ summarizing older messages to free up space. This happens behind the scenes.
You can also trigger compaction manually:
/compact
This is useful when you want to keep going but the conversation is getting long. Think of it as "summarize everything so far and keep working."
You can also give /compact specific instructions about what to preserve:
/compact Focus on the API changes and keep the list of modified files
This tells Claude Code what matters most when summarizing, so critical context survives.
When context is compacted, Claude Code creates a summary of the conversation so far and uses that summary as the starting point. The original messages are discarded.
This means some nuance gets lost. If you gave Claude Code a very specific instruction 30 messages ago, it might not survive compaction. For important instructions, put them in your CLAUDE.md file (covered in Lesson 4) so Claude Code sees them every session.
You can also customize compaction behavior in CLAUDE.md with instructions like "When compacting, always preserve the full list of modified files and any test commands" to ensure critical context survives summarization.
Undo for your conversation: /rewind
Made a wrong turn? Used a bad prompt? Claude Code went off in the wrong direction?
/rewind
This rolls back your conversation to a previous point. Think of it as Ctrl+Z for your Claude Code session.
You can also press Escape while Claude Code is working to stop it mid-response. Then use /rewind to go back to before the bad prompt.
When to start fresh vs. when to keep going
| Situation | What to do |
|---|---|
| Finished a task, starting something unrelated | /clear |
| Same task, but conversation is getting long | /compact |
| Claude Code just made a mistake | /rewind or Escape + try a different prompt |
| Claude Code keeps making the same mistake | /clear and start over with a better prompt |
| You've corrected Claude Code twice and it's still wrong | /clear โ something in the context is confusing it |
That last row is important. We call it the two-correction rule: if you've corrected Claude Code twice on the same thing and it's still not getting it, the context is probably polluted. Don't keep fighting. Clear and start fresh with a better prompt.
Subagents: context protection
Sometimes you'll see Claude Code spawn a subagent โ a helper that runs in the background while your main session stays clean. It looks like this in your terminal:

A subagent runs in its own separate context. It does its work, returns the result, and its messy intermediate steps never pollute your main conversation. That's the key insight: it's not just about doing things in parallel โ it's about context protection. Your main context stays clean.
You don't need to manage subagents yourself. Claude Code decides when to use them. Just know that when you see one spinning, it's keeping your conversation leaner than if it did everything in the main thread. We'll explore agents in much more depth in Module 3.
If your conversation starts feeling sluggish โ Claude Code repeating itself or forgetting things โ that's usually a sign the context is full. Use /compact to summarize and keep going, or /clear to start fresh.
Resuming conversations
Claude Code saves conversations locally. When a task spans multiple conversations โ say you close the terminal for the day โ you don't have to start over. Use claude --continue to resume the most recent conversation, or claude --resume to pick from a list:
claude --continue # Resume the most recent conversation
claude --resume # Pick from a list of recent conversations
Use /rename inside a conversation to give it a descriptive name:
/rename oauth-migration
This makes it easy to find later with --resume. Treat conversations like branches: different features or workstreams can each have their own persistent context.
Checkpoint
- I understand what the context window is
- I know what a "kitchen sink session" is and why it's a problem
- I know how to use
/clearto start fresh - I know the difference between
/clear,/compact, and/rewind - I know the two-correction rule: clear and start fresh after two failed corrections
- I know how to resume sessions with
--continueand--resume