Video Lesson: Clear the context window in Claude Code

Clear the context window in Claude Code

Use Claude Code’s /clear after each Git commit to reset context, improve focus, speed, and cost.


Lesson Content

After you finish a task and commit it, run /clear to reset Claude Code's context window. The next task then starts clean, with nothing left over from the last one.

Why it still helps

Models handle long conversations much better than they used to, so a long session won't quietly derail the way it once did. Old context still costs you, though. File contents, rejected approaches, and details from unrelated features all stay in the window, and they can occasionally leak into answers where they don't belong. A fresh context keeps Claude focused on the task in front of it. It also makes each request faster and cheaper.

When to clear

Right after a commit is the natural place. The work is done and tested, and it's saved in Git. The commit message already records what you did and why, so you don't need to carry that conversation forward.

A simple rhythm:

  1. Ask Claude Code for a small, specific change

  2. Review and test it

  3. Commit

  4. Run /clear

  5. Move to the next task

Keeping what matters

If something from the session is worth keeping, like an architectural decision or a research finding, ask Claude to write it to a markdown file in your project before you clear. You can point to that file in the next conversation. Plans made in plan mode are already saved for you.

Tip: If a conversation gets long partway through a task, /compact summarizes the history instead of wiping it. With a frontier model like Opus or Fable, you probably won't need to run it yourself. Claude Code compacts automatically as the window fills up, and these models are good at keeping what matters in the summary, so you can usually just keep working. Use /clear between tasks and let compaction take care of the middle of one.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Log in for AI tutor access.

Comments

Join the discussion!

Notes

Keep track of what you learn!