cost-alert — Claude Code skill: audit fired spend alerts
Walks through the budget rules configured in Agent Monitor and the alerts that already fired, with a plain explanation of what set each one off.
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a claude-codeWhat cost-alert does
The skill pulls from two dashboard endpoints. GET /api/alerts/rules returns the guardrail definitions, and GET /api/alerts returns the fired feed, newest first. It then lines the two up so every alert is tied back to the rule behind it.
Four rule types exist. token_threshold trips when a session's cumulative tokens pass a ceiling. event_pattern counts matching events inside a time window. inactivity watches for a session going quiet, and status_duration catches an agent stuck in working or waiting. Spend work means the first one: the skill converts its token ceiling into dollars using the blended rate at /api/pricing/cost, computed as total_cost / total_tokens. Figures come out in USD with four decimal places.
Pass no argument to review everything. The string "unacked" narrows the query with ?unacked=true, and a rule name focuses the report on that rule alone. The closing section suggests acknowledging stale alerts through POST /api/alerts/:id/ack or /api/alerts/ack-all, or adjusting a threshold. When no budget rule is armed at all, it points you to the budget-set skill.
What it helps with
- find out why a spend alert fired
- see which budget rules are configured
- convert a token ceiling into dollars at current rates
- filter the feed down to unacknowledged alerts
- acknowledge stale alerts in one call
Example prompts for the agent
- Show the fired spend alerts and explain what tripped each one
- Check unacked alerts only:
unacked - Break down the
token_thresholdrule — what's the ceiling and what does it cost in dollars?
How to install cost-alert
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a claude-code2Manually: put the files in place
~/.claude/skills/cost-alert/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/cost-alert/
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a codex2Manually: put the files in place
.agents/skills/cost-alert/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a cursor2Manually: put the files in place
.cursor/skills/cost-alert/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install hoangsonww/Claude-Code-Agent-Monitor cost-alert2Manually: put the files in place
.github/skills/cost-alert/SKILL.md1Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a gemini-cli2Platform CLI
gemini skills install https://github.com/hoangsonww/Claude-Code-Agent-Monitor --path plugins/ccam-cost-guard/skills/cost-alertManually: put the files in place
.devin/skills/cost-alert/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about cost-alert
How do I install cost-alert in Claude Code?
Run npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a claude-code. The skill file lands at ~/.claude/skills/cost-alert/SKILL.md.
What does cost-alert do?
It reads rule definitions from /api/alerts/rules and the fired feed from /api/alerts, then explains for each alert which rule triggered it and at what value.
Which budget rules does it cover?
Four types: token_threshold, event_pattern, inactivity and status_duration. Spend control relies on token_threshold, whose ceiling the skill converts to dollars using the rate from /api/pricing/cost.
Source text
SKILL.md · MIT
---
name: cost-alert
description: >
Review the configured cost alert rules and the alerts currently fired on the
Agent Monitor dashboard, then explain exactly what tripped and why. Uses
/api/alerts (fired feed) and /api/alerts/rules (definitions). Use when
checking spend alerts or asking why a cost alarm went off.
---
# Cost Alert
Audit the spend guardrails: which rules exist, which have fired, and what tripped them.
## Input
The user provides: **$ARGUMENTS**
This may be empty (review everything), `"unacked"` (only unacknowledged alerts),
or a rule name to focus on.
## Data Sources
| Endpoint | Returns |
|----------|---------|
| `GET /api/alerts/rules` | `{ rules: [{ id, name, rule_type, config, enabled, cooldown_seconds }] }` — the guardrail definitions |
| `GET /api/alerts` | `{ alerts: [{ id, rule_id, rule_name, rule_type, session_id, agent_id, message, details, triggered_at, acked }], total, unacked, limit, offset }` — the fired-alert feed, newest first. `?unacked=true` filters to unacknowledged |
## What the rule types mean
| `rule_type` | `config` | Fires when |
|-------------|----------|------------|
| `token_threshold` | `{ total_tokens }` | A session's cumulative tokens (input + output + cache_read + cache_write) cross the ceiling — the spend-relevant guardrail |
| `event_pattern` | `{ event_type?, tool_name?, summary_contains?, count?, window_minutes? }` | Matching events reach `count` within the window |
| `inactivity` | `{ minutes }` | An active session goes quiet for `minutes` |
| `status_duration` | `{ status, minutes }` | An agent is stuck in `working`/`waiting` for `minutes` |
For cost work, focus on `token_threshold`. Translate its token ceiling to dollars using the blended rate from `/api/pricing/cost` (`total_cost / total_tokens`) so the user sees the alarm in money terms.
## Report Sections
### 1. Configured guardrails
Table from `/api/alerts/rules`: name, type, the human-readable threshold (e.g. `token_threshold → 12,500,000 tokens ≈ $50.0000`), enabled state, cooldown. Flag rules that are `disabled` or have no spend-relevant guardrail at all.
### 2. Fired alerts
Table from `/api/alerts`: rule name, `triggered_at`, scope (session/agent id), `acked`, and the `message`. Lead with the `unacked` count. Honor `"unacked"` input by querying `?unacked=true`.
### 3. What tripped — per alert
For each fired alert, parse `details` and explain in plain terms: e.g. *"session X crossed 12,500,000 tokens (threshold 12,500,000) ≈ $50.12 at current rates — your `token_threshold` budget rule fired."* Tie the observed value back to the rule's config.
### 4. Next steps
Suggest acknowledging stale alerts (`POST /api/alerts/:id/ack` or `/api/alerts/ack-all`), tightening or loosening a threshold, or arming a missing budget rule (point to the `budget-set` skill).
## Output
Markdown tables. Currency as USD to 4 decimal places; token counts with thousands separators. Make the link between each fired alert and the rule that produced it explicit — never report a raw alert without saying which rule tripped and why.
© hoangsonww · MIT · hoangsonww/Claude-Code-Agent-Monitor