Skip to content

akakarantzas/claude-code-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Counter

Ever wonder how many tokens you're burning in a Claude Code session? I kept hitting Claude Code's context limit mid-session with no warning, so I built a browser extension that shows your token usage in real time.

Context window usage, token counts, cache stats, all sitting in your toolbar while you work.

Technologies

  • Python 3.9+
  • JavaScript
  • Chrome Extension (with Native Messaging)

Installation

Step 1: Load the extension in Chrome

  1. Clone or download this repo
  2. Open chrome://extensions
  3. Turn on Developer mode (top right)
  4. Click Load unpacked and select the extension/ folder
  5. Copy the extension ID from the card that appears — it is a 32-character string like abcdefghijklmnopqrstuvwxyz123456 shown under the extension name

Step 2: Install the native host

The extension can't read your local files directly (browser security), so it talks to a small Python script running in the background. Takes 30 seconds to set up.

macOS / Linux:

git clone https://github.com/akakarantzas/claude-code-counter
cd claude-code-counter
bash scripts/install-mac-linux.sh --extension-id YOUR_EXTENSION_ID

Windows:

setup.bat

Or pass the extension ID directly:

setup.bat YOUR_EXTENSION_ID

You can also run the PowerShell installer directly:

git clone https://github.com/akakarantzas/claude-code-counter
cd claude-code-counter
.\scripts\install-windows.ps1 -ExtensionId YOUR_EXTENSION_ID

That's it. Click the icon in your toolbar and you'll see your token usage update every 2.5 seconds.

What it tracks

Metric Description
Context window How full your context is (avg tokens per turn vs 200k limit)
Session tokens Input, output, and total for the whole session
Prompt cache How much of your input is being served from cache
Activity Turn count, tool calls, how long the session has been running

How it works

Claude Code saves every session as a .jsonl file in ~/.claude/projects/. Each turn has a usage block with exact token counts straight from the API. The Python script reads the latest session file and passes the data to the extension using Chrome's Native Messaging API. No network requests, no accounts, nothing leaves your machine.

Requirements

  • Python 3.9+
  • Chrome 88+
  • Claude Code

Uninstall

macOS / Linux:

bash scripts/uninstall-mac-linux.sh

Windows:

uninstall.bat

Or run the PowerShell uninstaller directly:

.\scripts\uninstall-windows.ps1

Then remove the extension from chrome://extensions.

License

MIT

About

Real-time token usage tracker for Claude Code. Monitor context window usage, session tokens, prompt cache stats, and activity directly from your Chrome toolbar.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors