DEV Community

Cover image for I Had No Idea How Full My Claude Code Context Window Was. So I Built a Tool.
Yurukusa
Yurukusa

Posted on • Edited on

I Had No Idea How Full My Claude Code Context Window Was. So I Built a Tool.

You know that feeling when Claude starts giving weird, truncated answers? Or when it seems to "forget" earlier context in a long session?

That's your context window filling up.

Claude Sonnet has a 200,000 token context window. When it's full, older messages get dropped. Your carefully set-up context โ€” the files you loaded, the constraints you established, the codebase you explained โ€” silently disappears.

I've been running Claude Code for 60+ days in an autonomous loop. Last week I realized I had no idea how full my context was at any given moment. So I built cc-context-check.

What it does

npx cc-context-check
Enter fullscreen mode Exit fullscreen mode
cc-context-check โ€” Context window usage across sessions

Context limit: 200.0k tokens (Claude Sonnet/Opus)

๐ŸŸข ~/projects/my-app    [a3f9c12] just now ยท 12.4 MB
   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 40.1% used
   80.2k input ยท 1.2k output ยท 119.8k remaining

๐ŸŸก ~/                   [b7d44e1] 2h ago ยท 5.9 MB
   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 71.5% used
   143.0k input ยท 89 output ยท 57.0k remaining
   โ–ณ Warning: Context is getting full โ€” consider /compact
Enter fullscreen mode Exit fullscreen mode

Color coded: ๐ŸŸข under 70% โ†’ ๐ŸŸก 70-85% (consider compacting) โ†’ ๐Ÿ”ด 85%+ (compact now)

How it works

Claude Code stores session transcripts as .jsonl files in ~/.claude/projects/. Each line is a message. Each assistant message includes a usage object:

{
  "usage": {
    "input_tokens": 1,
    "cache_read_input_tokens": 79927,
    "cache_creation_input_tokens": 917,
    "output_tokens": 158
  }
}
Enter fullscreen mode Exit fullscreen mode

The real context usage is input_tokens + cache_read_input_tokens + cache_creation_input_tokens. The input_tokens: 1 is misleading โ€” the cache tokens are where your actual context lives.

cc-context-check reads the last 64KB of each session file, finds the most recent usage data, and calculates your true fill percentage.

When to use /compact

The tool shows all your active Claude Code sessions across all projects. So you can see at a glance:

  • 40%: You're fine. Keep going.
  • 71%: Getting full. /compact will help if you're starting a new task.
  • 87%: Compact soon. You're losing context.

Options

npx cc-context-check --all    # Show top 20 sessions instead of 5
npx cc-context-check --json   # JSON output for scripting
Enter fullscreen mode Exit fullscreen mode

Part of cc-toolkit

This is tool #43 in cc-toolkit โ€” 43 free tools for Claude Code users. Zero dependencies, runs in browser or via npx.


Source: github.com/yurukusa/cc-context-check


More tools: Dev Toolkit โ€” 440+ free browser-based tools for developers. JSON, regex, colors, CSS, SQL, and more. All single HTML files, no signup.


Is your Claude Code setup actually safe? Run npx cc-health-check โ€” a free 20-point diagnostic. Score below 80? The Claude Code Ops Kit fixes everything in one command.


Get started in 10 seconds: npx cc-safe-setup installs 7 essential safety hooks with zero configuration. GitHub

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.