A CLI tool that displays a colored terminal bar showing model context window usage.
Project description
show-model-context
A CLI tool that displays a colored terminal bar showing Claude Code context window usage, broken down by configurable categories.
45K / 200K ██████████████░░░░░░░░░░░░░░░░░░░░░░░░░░
The filled portion is multi-colored, with each color representing a category of context usage (system prompts, files, tools, skills, Claude responses).
How It Works
show-model-context integrates with Claude Code's statusLine setting. After each assistant message, Claude Code sends a JSON payload on stdin containing the transcript path and token usage. This tool:
- Reads the session transcript (JSONL) and categorizes each content block
- Estimates token usage per category (chars / 4)
- Scales proportionally to match the actual token counts from Claude Code
- Renders a colored ANSI bar to stdout, which Claude Code displays in its status area
Installation
Requires Python 3.11+.
# Clone the repository
git clone https://github.com/your-org/show-model-context.git
cd show-model-context
# Install with uv
uv sync
Or install directly:
uv tool install git+https://github.com/your-org/show-model-context.git
Claude Code Setup
Add the following to your Claude Code settings (.claude/settings.json or ~/.claude/settings.json):
{
"statusLine": {
"type": "command",
"command": "uv tool run show-model-context --mode total"
}
}
Usage
show-model-context [--config PATH] [--mode total|current]
| Flag | Description |
|---|---|
--config PATH |
Path to a TOML config file (default: ~/.config/show-model-context/config.toml) |
--mode total |
100% = model's max context window (e.g. 200K). Shows how full the window is. |
--mode current |
100% = current tokens used. Shows category proportions only. |
The tool reads JSON from stdin and writes a single line to stdout.
Display Modes
Total mode (default) -- shows usage relative to the full context window:
45K / 200K ██████████████░░░░░░░░░░░░░░░░░░░░░░░░░░
^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
filled (used) empty (remaining)
Current mode -- shows category proportions within the used portion:
45K / 45K ████████████████████████████████████████
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
all filled, colored by category
Default Categories
| Category | Color | What it matches |
|---|---|---|
| system | gray | User messages containing <system-reminder>, CLAUDE.md, <local-command- |
| files | blue | Tool calls to Read, Write, Edit |
| tools | yellow | Tool calls to Bash, Glob, Grep, WebFetch, WebSearch |
| skills | magenta | Tool calls to Task, Skill |
| claude | green | Assistant text and thinking blocks |
| other | dim | Anything that doesn't match the above |
Categories are checked in order; first match wins.
Configuration
Optionally create ~/.config/show-model-context/config.toml (or pass --config). See config.example.toml for all options.
[general]
bar_width = 0 # 0 = auto-detect from terminal width; >0 = fixed character count
empty_char = "░" # character for unfilled portion
filled_char = "█" # character for filled portion
label_position = "left" # "left" or "right"
label_format = "ratio" # "ratio", "percentage", or "legend"
[[categories]]
name = "system"
color = "bright_black"
label = "Sy" # custom legend label (default: first char of name)
match_type = "user" # match transcript entry type
content_contains = ["<system-reminder>", "CLAUDE.md"] # substring match
[[categories]]
name = "files"
color = "blue"
match_tools = ["Read", "Write", "Edit"] # match tool_use/tool_result by name
[[categories]]
name = "claude"
color = "green"
match_type = "assistant"
match_content_types = ["text", "thinking"] # match content block type
Category Matching Rules
Each category can use one or more of these matchers (all specified matchers must pass):
| Matcher | Description |
|---|---|
match_type |
Match the transcript entry's type field (user or assistant) |
match_tools |
Match tool_use blocks by tool name, or tool_result blocks paired with a preceding tool_use |
match_content_types |
Match content block type (text, thinking, tool_use, etc.) |
content_contains |
Match if serialized content contains any of the listed substrings |
label |
Custom legend label (used in legend label_format). Defaults to the first character of name. Useful when multiple categories share the same initial (e.g. "system" and "skills"). |
Wildcards
Any list matcher (match_tools, match_content_types, content_contains) supports "*" as a wildcard that matches anything. This is useful for catch-all categories at the end of the list:
# Catch any tool not matched by earlier categories
[[categories]]
name = "tools"
color = "yellow"
match_tools = ["*"]
# Match all assistant output regardless of content block type
[[categories]]
name = "claude"
color = "green"
match_type = "assistant"
match_content_types = ["*"]
The wildcard only applies to the field it's in — other matchers on the same category still apply normally. For example, match_type = "assistant" with match_tools = ["*"] will only match assistant entries that contain tool blocks.
Available Colors
black, red, green, yellow, blue, magenta, cyan, white, and bright variants (bright_black, bright_red, etc.), plus dim.
Development
# Install dependencies
uv sync
# Run tests (100% branch coverage required)
uv run --frozen pytest -x
# Type checking
uv tool run pyright
# Linting
uv tool run ruff check --fix
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file show_model_context-0.1.0.tar.gz.
File metadata
- Download URL: show_model_context-0.1.0.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47ab9c5c63f93ffaf3df92242355442fc7fb5f895a6e06bf75c656e7a8c9c14a
|
|
| MD5 |
41e5aa4b5eb0d0012e5cbe0f6854ec86
|
|
| BLAKE2b-256 |
b7aa2ab57d656dacc25d4d101806645baa76f918f63e365b9c362936f17ec8c2
|
Provenance
The following attestation bundles were made for show_model_context-0.1.0.tar.gz:
Publisher:
publish.yml on jnapper7/show-model-context
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
show_model_context-0.1.0.tar.gz -
Subject digest:
47ab9c5c63f93ffaf3df92242355442fc7fb5f895a6e06bf75c656e7a8c9c14a - Sigstore transparency entry: 1065954700
- Sigstore integration time:
-
Permalink:
jnapper7/show-model-context@1f96eef178697d5b45a46cccc43d4ccdd8cc034a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jnapper7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f96eef178697d5b45a46cccc43d4ccdd8cc034a -
Trigger Event:
push
-
Statement type:
File details
Details for the file show_model_context-0.1.0-py3-none-any.whl.
File metadata
- Download URL: show_model_context-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45750bd417cce17e68e91bb3a43b3435b3f4155a0ff8af57ba81e8c9146b4c9b
|
|
| MD5 |
65b2d1630987908bcf9c07411c6cb7eb
|
|
| BLAKE2b-256 |
3609f2c8f3d6263c829cde3d2ffc2cc43651395e6b6192bf62e44564faa75511
|
Provenance
The following attestation bundles were made for show_model_context-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on jnapper7/show-model-context
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
show_model_context-0.1.0-py3-none-any.whl -
Subject digest:
45750bd417cce17e68e91bb3a43b3435b3f4155a0ff8af57ba81e8c9146b4c9b - Sigstore transparency entry: 1065954704
- Sigstore integration time:
-
Permalink:
jnapper7/show-model-context@1f96eef178697d5b45a46cccc43d4ccdd8cc034a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jnapper7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1f96eef178697d5b45a46cccc43d4ccdd8cc034a -
Trigger Event:
push
-
Statement type: