tokenclaw-dev
v2.5.0
Published
See what your AI agents spend. Track Claude, OpenAI, Gemini costs. Credit pool tracking for Anthropic's June 15 billing split. Alerts and hard caps.
Maintainers
Readme
tokenclaw
Anthropic's Agent SDK billing split hits June 15. Know what your agents are spending before they stop.
On June 15, programmatic Claude usage (Agent SDK, claude -p, GitHub Actions, third-party apps) moves to a separate credit pool. When credits run out, automated requests hard-stop. No fallback, no rollover.
tokenclaw shows you both pools, side by side.
npm install -g tokenclaw
tokenclaw credits --set-pool 200 # your plan's credit allocation
tokenclaw creditsCredit Usage (2026-06-01 -> 22d remaining)
Subscription (interactive)
Claude Code $4.9K consumed @ API rates
Claude Desktop $83.64 consumed @ API rates
$5.0K consumed on a $200.00/mo plan = 25x value
Agent SDK credits
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░ $13.35 / $200.00 (7%)
├─ OpenClaw $13.35
Projection
Daily rate: $1.33/day
Month-end forecast: $42.71
✓ On track to stay within $200.00 poolNo auth, no config. Reads local session logs from Claude Code, OpenClaw, Cursor, Windsurf, Cline, Roo Code, Aider, and Continue.dev.
Credit pools (new)
tokenclaw credits # see both pools
tokenclaw credits --set-pool 200 # set your SDK credit allocation
tokenclaw credits --set-pool 20 # Pro plan
tokenclaw credits --set-pool 100 # Max 5x
tokenclaw credits --set-period-start 2026-06-15 # set billing cycle start
tokenclaw credits --json # programmatic outputShows subscription usage (interactive, unlimited) vs Agent SDK credits (capped, metered at API rates). Projects when you'll hit your cap based on current burn rate.
| Your plan | SDK credit pool | |-----------|----------------| | Pro ($20/mo) | $20/month | | Max 5x ($100/mo) | $100/month | | Max 20x ($200/mo) | $200/month |
30-second setup
npm install -g tokenclaw
tokenclaw todayShows what you've spent today, by tool:
OpenClaw $12.41
Claude Code $6.20
Total $18.61 / $50.00 (37%)Catch runaway costs early
tokenclaw alert --daily 50Get notified before a bad loop burns hundreds overnight. Installs a background check (runs hourly, survives reboots on macOS).
Connect Slack to get alerts when you're not watching:
tokenclaw config slack https://hooks.slack.com/services/YOUR/WEBHOOK/URLSee cost after every Claude Code turn
tokenclaw hook installEvery time Claude finishes a turn, you see:
[tokenclaw] $18.32/$50 (37%)Hard-block a runaway agent
tokenclaw proxy # start the proxy
ANTHROPIC_BASE_URL=http://localhost:4040 claude # point agent at it
tokenclaw cap --key sk-ant-research --daily 10 # block at $10/dayAt 80% the proxy warns. At 100% it returns 429 and the agent stops. Your money stops leaving.
Built for
- Solo builders with Claude automations hitting the June 15 credit split
- Claude Code users on Max plans burning $200+/day
- OpenClaw / OpenRouter API users running cron agents
- Cursor and Windsurf power users
- Anyone who's had a surprise API bill
All commands
| Command | What it does |
|---------|-------------|
| tokenclaw credits | Subscription vs SDK credit usage, burn projection |
| tokenclaw today | Today's spend by tool |
| tokenclaw view | Full breakdown: models, projects, trends, efficiency |
| tokenclaw status | One-line spend check (instant) |
| tokenclaw alert --daily 50 | Alert at $50/day |
| tokenclaw alert --velocity 0.50 | Alert when burning >$0.50/min |
| tokenclaw hook install | Show spend after every Claude Code turn |
| tokenclaw cap --key <prefix> --daily <n> | Hard-block at $n/day (needs proxy) |
| tokenclaw baseline | Your spending patterns by day-of-week |
| tokenclaw list sessions | Most expensive sessions |
| tokenclaw digest | Daily Slack summary |
| tokenclaw mcp install | Let AI agents check their own budget |
Advanced
tokenclaw alert --velocity 0.50Alerts on spend rate over a 30-minute window from proxy data. Catches runaway loops before they hit the total threshold.
tokenclaw baselineAfter 7+ days, shows per-day-of-week patterns (median, P95). After 14 days, anomaly detection replaces the default spike threshold with one tuned to your actual spend. API-billed tools only.
tokenclaw digest --installSends yesterday's spend summary to Slack at 9 AM daily (macOS launchd).
tokenclaw mcp installGives Claude Code access to three tools: get_budget_status, get_session_cost, estimate_cost. Agents can check their budget before expensive operations and switch to cheaper models when running low.
Add to your project's CLAUDE.md:
## Cost awareness
Before expensive operations, check budget via the tokenclaw MCP server.
If remaining budget is <20%, prefer Sonnet over Opus for routine tasks.Add to ~/.claude/settings.json:
{
"hooks": {
"Stop": [{ "matcher": "", "hooks": [{ "type": "command", "command": "npx tokenclaw status --oneliner 2>/dev/null || true" }] }]
},
"mcpServers": {
"tokenclaw": { "command": "npx", "args": ["tokenclaw", "mcp"] }
}
}Caps require the proxy (tokenclaw proxy). The proxy sits between your agent and the API, counts tokens, and blocks when a cap is hit.
tokenclaw cap --key sk-abc --weekly 500
tokenclaw cap --key sk-abc --monthly 2000
tokenclaw cap # view all caps
tokenclaw cap --clear --key sk-abc # remove a capAuto-detects provider: /v1/messages goes to Anthropic, /v1/chat/completions goes to OpenAI.
Config
tokenclaw config # show current config
tokenclaw config slack <url> # set Slack webhook
tokenclaw config reset # reset to defaultsUninstall
npm uninstall -g tokenclaw
rm -rf ~/.tokenclawLicense
MIT
