Context Bar, a Claude Code context bar mod: see what fills your Claude Code context window
Your Claude Code context window as one stacked bar above the prompt, a color per category, with token counts.
#6 in Best Claude Code ModsPermissions
- Changes the UIDraws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/toolsRegisters new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- Stores dataKeeps data between sessions in the plugin's private store ($.store.*).
- tested with
- v2.1.291
- last tested
- requires
- Claude Code ≥ 2.1.287
- surfaces
- above-prompt
- source
- Hamza Zafar (hamzafer) (MIT)
Install inside Claude Code:
/plugin install context-bar --marketplace hamzafer/claude-code-modsWhat does this mod do?
Context Bar is a community mod by Hamza Zafar (hamzafer), part of his claude-code-mods collection. It is a Claude Code context bar that answers one question: what is filling my context window? Above the Claude Code prompt it draws a small bordered band with a single stacked bar the width of the terminal. The bar is split into the same categories /context uses, such as system prompt, tools, MCP tools, memory files, skills and messages, followed by free space and the auto-compact buffer.
The header line reads like 48k of 200k · compacts at 167k with a colored percentage badge. The badge is green, turns yellow at 70% of the compaction point and red at 90% (measured against the full window when auto-compact is off). Under the bar, a legend lists each category with its token count and its share of the window, packed into as many lines as the terminal width needs. Tool schemas that are loaded on demand are left out, as /context leaves them out of its grid.
Context Bar is close to our own Context Meter, but they show different things. Context Meter is a single status-line string with the overall context percentage, the 5-hour and 7-day plan windows, the session cost and a one-time warning at 80%. Context Bar shows no plan usage or cost; instead it breaks the context down by category, so you can see whether MCP tools, memory files or the conversation itself is taking the space. The author's README needs Claude Code 2.1.287 or later.
Demo
The recording starts Claude Code with the mod loaded in the small demo project and asks Claude to read README.md and describe the project in one sentence. When the turn completes, the band above the prompt shows the context window split by category (system prompt, system tools, skills, messages, free space), the total such as 54k of 200k, where auto-compact kicks in, and the used percentage.
Install
Use any of the methods in the install block; they install straight from the author's own marketplace. The bar appears on the next session start, and /context-bar hides or shows it.
$ install context-bar
Requires Claude Code ≥ 2.1.287
Installs from the author's own marketplace: hamzafer/claude-code-mods
1.One line, inside Claude Code
/plugin install context-bar --marketplace hamzafer/claude-code-modsPaste into a running session (v2.1.275+). Claude Code asks to add the marketplace first.
2.From your shell
claude plugin marketplace add hamzafer/claude-code-mods claude plugin install context-bar@claude-code-modsThen run /reload-plugins in any session that is already open.
3.Try it without installing
git clone https://github.com/hamzafer/claude-code-mods claude --plugin-dir ./claude-code-mods/mods/context-barLoads the mod for one session only. Nothing is added to your settings.
How it works
The mod keeps the latest reading in a host-held $.state atom, so it survives a hot reload, and redraws it on the AbovePrompt render site. The refresh function, from hooks/register.tsx:
// Asks the engine for /context's breakdown, estimated locally (no token-count calls).
async function refresh($: EngineInterface) {
if (await read($, isHidden)) return
const usage = await $.session.usage({ breakdown: 'summary' })
const b = usage.context.breakdown
if (!b || !(b.rawMaxTokens > 0)) return // no window to measure against
await update($, reading, () => toReading(b))
}refresh runs on session.start, on turn.complete when there is no agentId (subagent turns are skipped), and on session.compact, because a /compact empties the window without a turn ending. toReading drops deferred categories and empty ones, sorts used rows before free space and the buffer, and assigns colors. Pure helpers cells and legend turn the reading into bar runs and legend lines: every used category gets at least one cell, and rounding leftovers go to free space first. Below 20 columns of inner width the bar is not drawn. When a survey is using the space above the prompt, the band steps aside.
Customize it
There are no options in /config. The only switch is the /context-bar command, whose hidden/shown state is stored with $.store. To change the look, edit the constants at the top of register.tsx: PALETTE for the category colors, MESSAGES for the messages color, GLYPH for the bar characters and MIN_WIDTH for the narrowest width that still draws.
Permissions & safety
We read every file the plugin can execute before running it: hooks/hooks.json, hooks/register.tsx, the type declarations and the tests. There is no package.json, install script or bundled code.
Changes the UI covers the band above the prompt. Adds a command covers /context-bar. The mod reads context figures through $.session.usage, stores a single true/false value with $.store, and keeps its reading in $.state. It does not run shell commands, read or write files, use the network, read environment variables or call the model. claude plugin validate reported no errors or warnings, and the author's 6 tests passed on Claude Code 2.1.291.
- Changes the UI
- Draws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/tools
- Registers new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- Stores data
- Keeps data between sessions in the plugin's private store ($.store.*).
Compatibility & troubleshooting
Checked with Claude Code 2.1.291 on macOS (validate and tests). If the bar does not show up:
claude --versionis 2.1.287 or later.- You did not hide it earlier: run
/context-baronce and look for "Context bar on". - The terminal is wide enough: the bar needs at least 24 columns for the band.
- A survey is open above the input; the band returns after it closes.
- The breakdown is only available once Claude Code knows the window size. If the band is missing at the very start, send one prompt.
FAQ
- Does the context bar spend tokens or call the API?
- No. It asks Claude Code for the same summary breakdown that /context draws, which the code comments describe as estimated locally with no token-count calls. It makes no network requests of its own.
- How do I hide the bar?
- Run /context-bar. It toggles the bar off and on, and the choice is saved in the plugin's own store, so a new session starts the way you left it.
- When does the bar refresh?
- At session start, after each of the main agent's turns, and after a compaction. Subagent turns are skipped because they fill their own window, not yours.
- How is it different from Context Meter (cm-context-meter)?
- Context Meter writes one short line into the status line with the context percentage, 5-hour and 7-day plan usage, session cost and an 80% warning toast. Context Bar draws a bordered band above the prompt that splits the context into categories, with no plan usage, cost or toast.
- What do the colors and glyphs mean?
- Each used category (system prompt, tools, MCP tools, memory files, skills and so on) gets its own color from a fixed palette, and messages are drawn in orange. Free space is a thin grey line and the auto-compact buffer is hatched.
# Related mods
FeaturedContext Meter
Context-window fill, 5-hour and 7-day plan usage and session cost in the status line, plus a warning near the limit.
- status
- toast
- Changes the UI
tested with v2.1.310
FeaturedTool Call Counter
Counts Claude's tool calls per turn and session, shows the count by the spinner, and adds /tally for a breakdown.
- spinner
- transcript
- status
- Intercepts tool calls
- Changes the UI
- Adds commands/tools
tested with v2.1.310
More in Context, quota, cost, Status line & prompt bar.