budget-set — скилл для Claude Code: что делает и как установить
Скилл переводит денежный бюджет в лимиты токенов и настраивает правила оповещений на дашборде Agent Monitor.
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a claude-codeЧто делает budget-set
Скилл рассчитывает допустимый расход для сессий Claude Code. Он опрашивает локальный эндпоинт GET /api/pricing/cost, забирает текущие траты по моделям и вычисляет среднюю стоимость одного токена. Если передать бюджет в долларах (например, $50/month), скилл делит сумму на эту ставку и находит эквивалентный потолок токенов. При отсутствии периода бюджет считается месячным.
Дашборд Agent Monitor отслеживает пороги по токенам, а не по валюте напрямую. Поэтому инструмент проверяет имеющиеся правила через GET /api/alerts/rules, предупреждает о дубликатах и готовит тело запроса с типом token_threshold. Без запущенного локального сервиса Agent Monitor на http://localhost:4820 отправить правило через curl не получится. Запрос на создание правила запускается только после явного подтверждения пользователя.
Какие задачи решает
- перевести лимит бюджета в долларах в потолок токенов
- проверить текущие расходы по моделям и кэшу через эндпоинт мониторинга
- создать правило
token_thresholdдля оповещений в Agent Monitor - защититься от создания повторяющихся алертов на траты
Примеры запросов агенту
- Установи бюджет $50/month для Agent Monitor
- Проверь текущие расходы и рассчитай лимит на 200000 токенов
- Создай правило алерта для бюджета $10/week
Как установить budget-set
1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a claude-code2Вручную: положить файлы
~/.claude/skills/budget-set/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/budget-set/
1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a codex2Вручную: положить файлы
.agents/skills/budget-set/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a cursor2Вручную: положить файлы
.cursor/skills/budget-set/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install hoangsonww/Claude-Code-Agent-Monitor budget-set2Вручную: положить файлы
.github/skills/budget-set/SKILL.md1Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a gemini-cli2Командой платформы
gemini skills install https://github.com/hoangsonww/Claude-Code-Agent-Monitor --path plugins/ccam-cost-guard/skills/budget-setВручную: положить файлы
.devin/skills/budget-set/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о budget-set
Как установить budget-set в Claude Code?
Выполните команду npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill budget-set -a claude-code. Конфигурация запишется в ~/.claude/skills/budget-set/SKILL.md.
Что делает budget-set?
Он запрашивает данные о текущих расходах через Agent Monitor, переводит долларовый бюджет в эквивалент токенов и формирует правило для отправки в /api/alerts/rules.
Почему бюджет пересчитывается в токены, а не в доллары?
Механизм оповещений Agent Monitor срабатывает на суммарное число токенов за сессию (token_threshold). Скилл берёт фактическую среднюю стоимость токена из /api/pricing/cost и делит бюджет на эту величину.
Исходный текст
SKILL.md · MIT
---
name: budget-set
description: >
Define a spend budget for Claude Code and, optionally, create a cost alert
rule that fires when usage crosses the limit, via POST /api/alerts/rules on
the Agent Monitor dashboard. Reads current spend from /api/pricing/cost to
size the budget sensibly and explains every rule field before writing.
Use when setting a spend limit or wiring up a budget guardrail.
---
# Budget Set
Help the user define a spend budget and turn it into a live cost guardrail on the
Agent Monitor dashboard.
## Input
The user provides: **$ARGUMENTS**
This is the budget to set — e.g. `"$50/month"`, `"$10/week"`, or `"200000 tokens"`.
If a period is omitted, treat it as a monthly budget and say so. If no number is
given, read current spend first and propose a target.
## Data Sources
| Endpoint | Returns |
|----------|---------|
| `GET /api/pricing/cost` | `{ total_cost, breakdown: [{ model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost, matched_rule }] }` — current spend, used to size the budget and compute the blended $/token rate |
| `GET /api/alerts/rules` | `{ rules: [{ id, name, rule_type, config, enabled, cooldown_seconds }] }` — existing rules, so you don't create a duplicate guardrail |
| `POST /api/alerts/rules` | Create a rule. Body: `{ name, rule_type, config, enabled?, cooldown_seconds? }`. Returns `{ rule }` |
## How a budget becomes a rule
The dashboard's alerting engine fires on **tokens**, not dollars. The spend-relevant
rule type is **`token_threshold`**, whose config is `{ total_tokens }` — it fires when
a session's cumulative tokens (input + output + cache_read + cache_write) cross the
threshold. To turn a **dollar** budget into a token ceiling:
```
blended_rate_per_token = total_cost / total_tokens # from /api/pricing/cost
token_ceiling = budget_dollars / blended_rate_per_token
```
Compute `total_tokens` by summing the four token columns across the cost `breakdown`.
### Rule fields explained
| Field | Meaning |
|-------|---------|
| `name` | Human label shown in the alert feed (e.g. `"Monthly $50 budget"`). Required, non-empty. |
| `rule_type` | `"token_threshold"` for a spend guardrail. (Other types: `event_pattern`, `inactivity`, `status_duration` — not spend-related.) |
| `config.total_tokens` | Positive integer token ceiling. A session crossing it fires the alert. Derive from the dollar budget as above. |
| `enabled` | `true` to arm immediately (default), `false` to stage it. |
| `cooldown_seconds` | Minimum seconds between re-fires for the same scope. Default `300`. Raise it (e.g. `3600`) so a single overspending session doesn't spam the feed. |
## Report Sections
### 1. Current spend snapshot
From `/api/pricing/cost`: `total_cost`, total tokens, and the blended $/Mtok rate. State how much of the proposed budget is already consumed.
### 2. Budget interpretation
Restate the parsed budget (amount + period). If converting dollars → tokens, show the blended rate and the `token_ceiling` arithmetic.
### 3. Existing guardrails
List any `token_threshold` rules from `/api/alerts/rules` so the user sees what is already in place; warn before creating a near-duplicate.
### 4. Proposed alert rule
Show the exact JSON body you would POST, with each field annotated. Then give the ready-to-run command (only run it on explicit confirmation):
```
curl -s -X POST http://localhost:4820/api/alerts/rules \
-H 'Content-Type: application/json' \
-d '{"name":"Monthly $50 budget","rule_type":"token_threshold","config":{"total_tokens":12500000},"cooldown_seconds":3600}'
```
### 5. Confirmation
On success, echo the returned `rule` (id, name, config). Remind the user that the rule is per-session token usage — to track a whole-period dollar budget, pair it with `/ccam-cost-guard:forecast` and the `spend-forecast` skill.
## Output
Markdown with the snapshot, the conversion math, and the annotated rule body. Currency as USD to 4 decimal places; token counts with thousands separators. Only POST after the user confirms — never create a rule silently.
© hoangsonww · MIT · hoangsonww/Claude-Code-Agent-Monitor