Skip to content

Claude Code statusline integration using CodexBar CLI #377

@kanoliban

Description

@kanoliban

What

A statusline script for Claude Code that uses CodexBar's CLI JSON output to show real-time rate limit data directly in the Claude Code status bar.

Why

Claude Code supports custom status lines via a shell script that receives session JSON on stdin. By combining that with codexbar --provider claude --format json, users get live rate limit visibility without leaving their coding session.

What it looks like

Normal (plenty of capacity):

[Opus 4.6 · Max] 📁 project 🌿 main │ Ctx: 🟢 12% │ Session: 92% │ Weekly: 77% │ $4.82

Low session (reset time appears automatically):

[Opus 4.6 · Max] 📁 project 🌿 main │ Ctx: 🟢 12% │ Session: 30% (8:00PM) │ Weekly: 77% │ $2.10

No CodexBar available (graceful fallback):

[Claude] 📁 project 🌿 main │ Ctx: 🟢 12% │ $0.00

How it works

  • Parses Claude Code's stdin JSON for: model name, context %, cost, workspace
  • Calls codexbar --provider claude --format json for: session %, weekly %, plan tier, reset times
  • Caches CodexBar output for 60s with background refresh (no render blocking)
  • PID guard prevents concurrent codexbar processes
  • Reset times only shown when capacity ≤ 50% (reduces noise)

CodexBar fields used

.[0].usage.primary.usedPercent        → session % (inverted to "% left")
.[0].usage.secondary.usedPercent      → weekly %
.[0].usage.primary.resetDescription   → session reset time
.[0].usage.secondary.resetDescription → weekly reset time
.[0].usage.identity.loginMethod       → plan tier (e.g. "Claude Max")

Proposal

Happy to open a PR adding this as an example integration — something like examples/claude-code-statusline.sh with a reference in docs/claude.md. The script is here: https://gist.github.com/kanoliban/39bb37cda2678b6e0941c5ca99757d9e

Let me know if you'd want this and where you'd prefer it to live.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions