DEV Community

Amit Raz
Amit Raz

Posted on

Why I Started Watching My Claude Code Context Window (And Built Something to Track It)

If you're using Claude Code heavily and not paying attention to your context window, you're probably paying more than you need to. Here's why it matters and what I changed.

The thing most people don't realize

Every time you send a message in Claude Code, the entire conversation history gets sent with it. Not just your new question. Everything. Every file you pasted, every response Claude gave, every back-and-forth since you opened the session.

This means cost doesn't scale with message length. It scales with accumulated context.

If your context window is at 70% and you ask something simple like "can you rename this variable?", you're paying for the full 70% of history sitting behind that tiny question. The question itself is almost irrelevant to the token count.

Once this clicked for me, I couldn't unsee it.

What actually drives your token costs

Let's make this concrete.

Say you've been in a Claude Code session for two hours. You've pasted several files, iterated on a feature, debugged a few things. Your context is sitting at 65%. Now you ask a quick follow-up question.

That API call includes:

  • All the files you pasted earlier
  • Every response Claude gave
  • All your messages
  • Your new question (tiny, almost irrelevant to the total)

The new question might be 20 tokens. The history behind it could be 40,000. That's what you're paying for.

This is by design, not a bug. The model needs the history to maintain coherence. But it means your costs compound as a session grows, and most people don't notice because there's no obvious signal telling them to pay attention.

The fix is simple but you have to be deliberate about it

When a session gets long, especially before starting a new feature or a significant refactor, I now do this:

  1. Open a fresh session
  2. Write a short handoff note: what we built, current state of the code, what I need next
  3. Paste only the files relevant to the next task
  4. Continue from there

That's it. The handoff takes maybe two minutes. In exchange, I'm starting the next task with a lean context instead of dragging tens of thousands of tokens of history into every subsequent query.

The responses often get sharper too. A packed context window can cause the model to lose focus on earlier content. Starting fresh with a tight, relevant context tends to produce more focused answers.

Why I built a custom status bar

The problem is that none of this is visible by default in Claude Code. You're flying blind. There's no indicator telling you how full your context is, how much of your 5-hour session budget you've used, or how much of your 7-day limit remains.

So I built a custom status bar that shows all three in real time.

It sits in the terminal and updates as I work. When I see the context creeping up, it's a clear signal: finish this thread, write the handoff, open a new session.

Before I built it, I had no idea how fast context accumulates during a real coding session. Seeing the number climb in real time changes how you work.

(I shared how I built it in a previous post. Link in the comments.)

The mental model shift

Think of the context window status like a fuel gauge, not a progress bar.

A progress bar tells you how far you've come. A fuel gauge tells you when to stop and refuel before you run out. The context window is the latter. Watching it helps you make an active decision: keep going, or reset and start lean.

Most developers I've talked to treat Claude Code sessions like a continuous conversation that they just let run. That works fine for short tasks. For longer sessions, it's quietly expensive.

TL;DR

  • Every Claude Code query sends the full conversation history
  • Cost scales with accumulated context, not message length
  • Heavy context also affects response quality
  • The fix: start fresh sessions before big new tasks, with a short handoff summary
  • Make context visible so you know when to reset

If you're using Claude Code for serious development work, the context window is worth paying attention to. It's not just a technical detail. It's directly tied to what you're spending.


Amit Raz is a Software Architect and AI consultant based in Israel. I build AI-powered products and write about developer tools, Android development, and AI workflows at rzailabs.com.

Top comments (1)

Collapse
 
amit_raz_4280cb3a49bb4086 profile image
Amit Raz

For context, this post is a follow-up to something I shared last week. I built a custom status bar for Claude Code that shows context size and session usage (5h and 7d windows) in real time. The setup is here if you want to try it: