RoninForge / Tutorials / See ongoing project costs across branches

~1.5k tokens | View as Markdown |

Tutorial

How to see ongoing project costs across all your Claude Code branches

Most days you have eight branches in flight, two parallel Claude Code sessions, and no idea which project is bleeding money. This tutorial wires BudgetClaw into your status line, adds a /budget slash command, and runs the watcher as a launchd agent so the data is always live.

Problem

No live cross-project spend view

Time

3 minutes

Output

Per-project spend always visible

The problem

The default Claude Code status line tells you what the current conversation costs. That's not what you actually need. You need to see what every project on your laptop has cost today, all at once, while you context-switch between them.

Two specific failure modes the default status line has:

  • Single-session view. The number resets the moment you start a fresh session. Yesterday's $80 agentic refactor on the same branch is invisible.
  • Hardcoded model pricing. Most community status-line scripts ship with Sonnet 4.5 rates baked in ($3 / $15 per MTok). Run them on Opus 4.7 ($5 / $25) and the displayed cost is silently wrong by ~5x.

This tutorial replaces that with a BudgetClaw-backed status line that shows your top spending projects today, sorted descending, color-coded. Plus a /budget slash command for the full per-branch table. Plus a macOS launchd agent so the watcher runs whether you remember to start it or not.

Step 1

Install BudgetClaw

Skip if you already have it. Otherwise, one install script drops a single static Go binary on your PATH:

Or via Homebrew:

If this is your first install, also run budgetclaw init to create the config and state directories. The spend-cap tutorial walks the init step in detail.

Step 2

Install the Claude Code integration

One command installs the status line, the /budget slash command, the macOS launchd watcher, and patches your ~/.claude/settings.json:

What it does:

  • Backs up your existing ~/.claude/statusline-command.sh to a timestamped .bak file.
  • Writes the new BudgetClaw-driven status-line script in its place.
  • Drops ~/.claude/commands/budget.md so /budget is registered.
  • On macOS: writes ~/Library/LaunchAgents/org.roninforge.budgetclaw.plist, loads it, starts budgetclaw watch in the background. Logs go to ~/Library/Logs/budgetclaw.log.
  • Patches ~/.claude/settings.json to wire the new status line. Other keys are untouched.
  • Installs jq via Homebrew if it's missing. The status-line script needs it.

Linux: the launchd step is skipped. Use a systemd user unit to run budgetclaw watch permanently - the snippet is in step 5 of the spend-cap tutorial.

Step 3

Backfill historical data

If the watcher was not running before you installed, today's column starts at $0.00. Backfill walks every JSONL file in ~/.claude/projects/ and seeds the rollup database:

scanned 45747 events, priced 45747, skipped 0 (unknown model)

Dedupes on event UUIDs, so re-running is safe. After this, your status line shows real numbers immediately.

Step 4

Open Claude Code and look at the bottom

Open a new Claude Code session. The status line at the bottom now reads:

~/development/myapp (main) | Opus 4.7 | MyClient $78.56 · myapp $8.88 · ronin $5.93

Reading right to left: every project that has spent money today, sorted descending, with the dollar amount. Color thresholds:

  • Red when a single project crosses $50 today
  • Yellow when it crosses $10
  • Dim below that

Top five projects shown. If you have more, the line ends with +N more so you don't lose layout to a wide table.

Step 5

Type /budget for the full per-branch table

The status line is the ambient view. When you actually want to drill in - "which feature branch on which project ate $40 this week?" - type /budget inside any Claude Code session. It runs budgetclaw status and prints the full table:

PROJECT          BRANCH                     TODAY    WEEK     MONTH
MyClient         29323-limit-meetups        $61.20   $61.20   $61.20
MyClient         29387-guest-attendance     $17.36   $17.36   $17.36
RoninForge.org   main                       $8.88    $85.38   $510.32
budgetclaw       main                       $3.05    $43.64   $158.11
TOTAL                                       $90.49   $207.58  $746.83

Pass an argument and it filters by substring on project or branch:

Returns only the MyClient rows. Useful when one project has 30 active branches and you want a focused view.

Step 6

Verify the watcher is running

On macOS:

Expected output (PID, last exit code, label):

8609   0   org.roninforge.budgetclaw

If it's not listed, reload:

The watcher restarts on login automatically (KeepAlive=true, RunAtLoad=true).

Step 7

Tune color thresholds (optional)

Defaults: dim under $10, yellow at $10-$50, red over $50. To change them, edit ~/.claude/statusline-command.sh and find this awk block:

if (amt >= 50) col = "\033[31m"      # red
else if (amt >= 10) col = "\033[33m" # yellow

Adjust the numbers to match your spend rhythm. The script is read on every status-line render so changes take effect immediately, no Claude Code restart needed.

Plugin alternative

Just want /budget, no system changes?

If you don't want the launchd watcher or a new status line, install the BudgetClaw plugin via your Claude Code marketplace. The plugin ships:

  • /budget - the same per-branch table
  • /budgetclaw-setup - bridges to the curl installer above when you decide you do want the full integration

Plugins can't override the global status line or install launchd agents on their own. That's by design - one status line per machine, configured by the user. So the curl installer remains the path for the full setup.

Trust + Uninstall

BudgetClaw never sits between your editor and the Anthropic API. The status line reads BudgetClaw's local SQLite rollup database. BudgetClaw reads JSONL files Claude Code already writes to disk. No prompts captured, no API keys held, no latency added on the inference path.

One command rolls everything back, including restoring your original status line from the most recent .bak file:

BudgetClaw itself, its config, and its rollup database are untouched.

FAQ

How is this different from /cost?

/cost reports the current session only. The moment you start a fresh session it resets, even on the same branch. The BudgetClaw status line aggregates across every session attributed to a project and branch, today, this week, and this month. Two different views: /cost is per-conversation, BudgetClaw is per-attribution.

Why can the plugin not configure the status line on its own?

Claude Code plugins ship slash commands, hooks, MCP servers, skills, and agents. They cannot override the global statusLine.command setting (one status line per machine, user-controlled by design), they cannot install macOS launchd agents or Linux systemd units, and they cannot install system packages like jq. The integration installer at roninforge.org/claude/install.sh handles those system-level pieces. The plugin remains useful for /budget on its own and for bridging to the installer.

Does this work on Claude Pro or Max plans?

Yes. BudgetClaw reads the JSONL session logs Claude Code writes locally regardless of upstream billing. On Pro and Max, the displayed dollar amount is informational rather than billed, but the per-branch attribution is still correct and the status line still tells you which project is consuming your share of the rate-limit budget.

Why was my previous status line silently wrong on cost?

Most community status-line scripts hardcode pricing for a single model, usually Claude Sonnet 4.5 at $3 / $15 per MTok. Run them on Claude Opus 4.7 at $5 / $25 and the displayed cost is roughly 5x too low. BudgetClaw uses a model-aware pricing table maintained by a daily GitHub Action, so the dollar amount tracks whatever model your sessions actually used.

Does the watcher use much CPU or memory?

About 5 MB of RAM and effectively zero CPU when idle. It uses FSEvents on macOS and inotify on Linux to wait for new lines in ~/.claude/projects/. Each new event is a SQLite insert and a rule check, well under a millisecond.

What if I already have a custom status line I want to keep?

The installer backs up your existing ~/.claude/statusline-command.sh to a timestamped .bak file before overwriting. You can copy the BudgetClaw segment out of the new script into your existing one if you prefer to merge them by hand.