claude-context-bar
A live, multi-session context-window meter for Claude Code.
What it does
I built contextbar because I was getting sick of running /context over and over
to keep tabs on my agents.
This started as a little afternoon for-fun project that I wasn't going to put on GitHub, but it's actually really useful to watch your agents' context grow in real time. So I decided to throw it up on GitHub for shiggles.
contextbar watches every session file under ~/.claude/projects/ and shows a
live TUI dashboard with one row per active Claude Code session: project name,
colored usage bar, percentage, token counts, and time since the session was
last updated. It refreshes once per second, depends only on the Python
standard library, and ships as a single file.
Install
pip install claude-context-bar
contextbar
That's it.
Native Windows (adds windows-curses):
pip install "claude-context-bar[windows]"
From source / GitHub:
pip install git+https://github.com/ethanarnold/claude-context-bar.git
No-install one-liner:
curl -O https://raw.githubusercontent.com/ethanarnold/claude-context-bar/main/contextbar.py
python3 contextbar.py
Usage
contextbar [--ascii] [--limit N] [--no-auto-limit]
[--refresh SEC] [--once] [--version]
| Flag | Example | Effect |
|---|---|---|
| (no flags) | contextbar |
Live TUI dashboard. Press q to quit. |
--once |
contextbar --once |
Print one snapshot line per session and exit. Pipe-friendly. |
--ascii |
contextbar --ascii |
Use ASCII glyphs (#/-) instead of Unicode block characters. |
--limit N |
contextbar --limit 1000000 |
Override the context window in tokens. Disables auto-detect. |
--no-auto-limit |
contextbar --no-auto-limit |
Disable per-model context window detection; use the 200k default. |
--refresh SEC |
contextbar --refresh 0.5 |
Change the refresh interval (default: 1.0s). |
--version |
contextbar --version |
Print version and exit. |
Combine --once --ascii for clean piping:
contextbar --once --ascii | head -3
How it works
Claude Code stores each session as a JSON-Lines file under
~/.claude/projects/<encoded-cwd>/<session-id>.jsonl. contextbar walks
those files and, for each one, scans entries of the form:
{"type": "assistant", "message": {"model": "claude-...", "usage": { ... }}}
The token count for a session is the sum of the four token fields in the
most recent usage object:
input_tokenscache_creation_input_tokenscache_read_input_tokensoutput_tokens
The model name is read from message.model on the same entries and is used
to pick the right context window via the regex table in MODEL_LIMITS.
Color thresholds
| Usage | Color |
|---|---|
< 50% |
Green |
50%–85% |
Yellow |
≥ 85% |
Red |
| schema mismatch | Yellow with schema? label |
Caveats
- The Claude Code session file format is undocumented and unofficial. If
it changes, the bar may render
0%or display a yellowschema?warning on affected rows. Open an issue if you see this. - Model auto-detection is regex-based and only knows about
opus,sonnet,haiku, and the 1M-context Sonnet beta. Use--limitfor anything else. - The TUI uses Unicode block glyphs by default. On terminals that can't
render them, pass
--ascii. - Reads files only —
contextbarnever writes to or modifies your Claude Code sessions.
Requirements
- Python 3.9+
- A
curses-capable terminal:- macOS / Linux / WSL: built in
- Native Windows:
pip install windows-curses(or use the[windows]install extra above)
- Claude Code installed and run at least once, so that
~/.claude/projects/exists
Development
git clone https://github.com/ethanarnold/claude-context-bar.git
cd claude-context-bar
python3 contextbar.py
Single-file project. No build step, no dependencies.
License
MIT © 2026 Ethan
Disclaimer
Not affiliated with Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic. This project depends on an undocumented file format and may break without warning when Claude Code is updated.
Metadata
Release files for claude-context-bar 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| claude_context_bar-0.1.1.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| claude_context_bar-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / claude_context_bar-0.1.1.tar.gz
| Download URL | claude_context_bar-0.1.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6ac376fbc006350f6524b2dd8d9c6322c377814ddc27bc29ea70e552e94d9f3
|
|
BLAKE2b-256 checksum How to use checksums |
2cd277b4c8005beeb53926def5eb937a895b10aa8b744204932db594ae3b4044
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / claude_context_bar-0.1.1-py3-none-any.whl
| Download URL | claude_context_bar-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
207f5be81d723155d379aca231d6b7aff833bac865c60a4ad9e70658d8f04393
|
|
BLAKE2b-256 checksum How to use checksums |
76965d1f58db204d14cbd6a085de4f064b728505c7b777f7ba961233c3401a09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|