cost-alert — скилл для Claude Code: разбор сработавших алертов по расходам
Показывает, какие правила бюджета настроены в Agent Monitor, какие уже сработали и почему. Нужен, когда непонятно, откуда взялся алерт.
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a claude-codeЧто делает cost-alert
Скилл читает два эндпоинта дашборда Agent Monitor: GET /api/alerts/rules отдаёт определения правил, а GET /api/alerts — ленту сработавших алертов, свежие сверху. Дальше он сопоставляет одно с другим и объясняет, какое правило и на каком значении сработало.
Правила бывают четырёх типов: token_threshold (сессия перевалила заданный лимит токенов), event_pattern (совпадающие события набрали нужное число за окно), inactivity (сессия замолчала) и status_duration (агент застрял в working или waiting). Для денег важен первый: скилл переводит лимит токенов в доллары по смешанной ставке из /api/pricing/cost, то есть по отношению total_cost / total_tokens. Суммы выводятся в USD с четырьмя знаками после точки.
Аргумент можно не передавать — тогда проверяется всё. Строка "unacked" сужает выборку до неподтверждённых алертов через ?unacked=true, а имя правила фокусирует отчёт на нём. В конце скилл предлагает подтвердить устаревшие алерты (POST /api/alerts/:id/ack или /api/alerts/ack-all) либо подкрутить порог. Если бюджетного правила нет вообще, он укажет на скилл budget-set.
Какие задачи решает
- понять, почему сработал алерт по расходам
- увидеть, какие правила бюджета вообще настроены
- перевести лимит токенов в доллары по текущим ставкам
- отфильтровать неподтверждённые алерты
- подтвердить устаревшие алерты одной командой
Примеры запросов агенту
- Покажи сработавшие алерты по расходам и объясни, что их вызвало
- Проверь только неподтверждённые алерты:
unacked - Разбери правило
token_threshold: какой лимит и сколько это в долларах
Как установить cost-alert
1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a claude-code2Вручную: положить файлы
~/.claude/skills/cost-alert/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/cost-alert/
1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a codex2Вручную: положить файлы
.agents/skills/cost-alert/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a cursor2Вручную: положить файлы
.cursor/skills/cost-alert/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install hoangsonww/Claude-Code-Agent-Monitor cost-alert2Вручную: положить файлы
.github/skills/cost-alert/SKILL.md1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a gemini-cli2Командой платформы
gemini skills install https://github.com/hoangsonww/Claude-Code-Agent-Monitor --path plugins/ccam-cost-guard/skills/cost-alertВручную: положить файлы
.devin/skills/cost-alert/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о cost-alert
Как установить cost-alert в Claude Code?
Выполните npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-alert -a claude-code. Файл скилла появится по пути ~/.claude/skills/cost-alert/SKILL.md.
Что делает cost-alert?
Собирает определения правил из /api/alerts/rules и ленту срабатываний из /api/alerts, а затем объясняет по каждому алерту, какое правило его вызвало и на каком значении.
Какие правила бюджета он понимает?
Четыре типа: token_threshold, event_pattern, inactivity и status_duration. Для контроля расходов используется token_threshold — его лимит скилл переводит в доллары по ставке из /api/pricing/cost.
Исходный текст
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