Skip to content

About

Context window and rate limit usage bars for the Claude Code status line

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

claude-usagebars

         ██╗   ██╗███████╗ █████╗  ██████╗ ███████╗
         ██║   ██║██╔════╝██╔══██╗██╔════╝ ██╔════╝
         ██║   ██║███████╗███████║██║  ███╗█████╗
         ██║   ██║╚════██║██╔══██║██║   ██║██╔══╝
         ╚██████╔╝███████║██║  ██║╚██████╔╝███████╗
          ╚═════╝ ╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝

              ██████╗  █████╗ ██████╗ ███████╗
░░░░░░░░▒▓██  ██╔══██╗██╔══██╗██╔══██╗██╔════╝  ██▓▒░░░░░░░░
░░░░░▒▓█████  ██████╔╝███████║██████╔╝███████╗  █████▓▒░░░░░
░░░▓████████  ██╔══██╗██╔══██║██╔══██╗╚════██║  ████████▓░░░
░▓██████████  ██████╔╝██║  ██║██║  ██║███████║  ██████████▓░
              ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝

                             ★
                      for Claude Code

Context window and rate limit usage as compact bars in the Claude Code status line:

ctx:42% ████░░░░░░ ┃ 5h:12% █░░░░░░░░░ 7d:57% █████▒░░░░

Claude Code status line with usage bars

  • ctx — context window usage: green below 75%, yellow from 75%, red from 90%
  • 5h / 7d — the five-hour and seven-day rate limits (blue). Claude Code only reports these for claude.ai subscribers; on API-key accounts the bars are skipped automatically.
  • 4-level sub-character shading (█ ▓ ▒ ░), so a 10-character bar resolves 2.5% steps
  • Plain bash + jq, no other dependencies, no background process — it reads the JSON Claude Code pipes into the status line on every refresh

Install

Let Claude install it — paste this prompt into Claude Code:

Install https://github.com/TLausZ/claude-usagebars: clone the repo, run its
test.sh, then wire scripts/usagebars-segment into my Claude Code status line —
if I already have a statusLine command, append the segment to it; otherwise
point statusLine.command in ~/.claude/settings.json directly at the script.
Show me your plan before changing any of my existing files. You are done when
test.sh passes and my status line renders the bars.

Or by hand: clone the repo:

git clone https://github.com/TLausZ/claude-usagebars.git

Requires jq (brew install jq on macOS). Then pick one of the two setups:

No status line yet? Point statusLine in ~/.claude/settings.json straight at the script — it is a complete status line on its own:

"statusLine": {
  "type": "command",
  "command": "/path/to/claude-usagebars/scripts/usagebars-segment"
}

Existing status line? Pass the JSON your script already reads on to the segment and append its output:

bars=$(printf '%s' "$input" | "$HOME/path/to/claude-usagebars/scripts/usagebars-segment")
[ -n "$bars" ] && line="$line ┃ $bars"

Adjust the paths to wherever the clone ended up on your machine.

Customizing

  • Bar width: set USAGEBARS_WIDTH (default 10), e.g. USAGEBARS_WIDTH=20 usagebars-segment in your status line script.
  • Colors and thresholds live at the top of the parts section in scripts/usagebars-segment — standard ANSI escapes, edit to taste.

How it works

Claude Code pipes a JSON blob into the status line command on every refresh. The script pulls context_window.used_percentage, rate_limits.five_hour.used_percentage and rate_limits.seven_day.used_percentage out of it with jq, renders each as a percentage plus bar, and joins them with ┃. Missing fields drop their bar; if nothing is available the script prints nothing and exits 0, so it never breaks the surrounding status line.

./test.sh runs a small self-check against canned JSON.

About

Context window and rate limit usage bars for the Claude Code status line

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages