anomalies — команда для Claude Code: что делает и как установить
Команда anomalies находит сессии с аномальным расходом токенов и денег через расчёт z-score в дашборде Agent Monitor.
MIT ★ 1 198 обновлён 2026-10-23
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor
/plugin install ccam-insights@claude-code-agent-monitor-pluginsЧто делает anomalies
Команда обращается к локальному сервису Agent Monitor по адресу http://localhost:4820 и запрашивает последние 200 сессий. На основе полученного пула рассчитываются среднее арифметическое и стандартное отклонение для денежных затрат и общего числа токенов.
Сессии, чей z-score превышает заданный порог (по умолчанию 2.0), выводятся в Markdown-таблицу. В расчёт токенов входят входящие, исходящие и кэшированные данные. Строки ранжируются по убыванию отклонения и маркируются значками: 🟡 для z > 2 и 🔴 для z > 3.
Без запущенного сервера дашборда на порту 4820 собрать статистику не получится. Если сервис недоступен, перед запуском команды нужно выполнить npm start в корне репозитория монитора.
Какие задачи решает
- найти сессии с аномальным расходом бюджета на API
- выявить скрытые утечки контекста и раздутые токены
- отфильтровать выбросы по настраиваемому порогу z-score
- сопоставить траты разных моделей в единой таблице
Примеры запросов агенту
- /anomalies
- /anomalies 2.5
- /anomalies 1.5
Как установить anomalies
1Через маркетплейс плагинов
/plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor/plugin install ccam-insights@claude-code-agent-monitor-plugins2Вручную: положить файлы
.claude/commands/anomalies.mdВызов — /anomalies. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/anomalies.mdВызов — /prompts:anomalies. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/anomalies.prompt.mdВручную: положить файлы
.gemini/commands/anomalies.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы об anomalies
Как установить anomalies в Claude Code?
Выполните сначала /plugin marketplace add hoangsonww/Claude-Code-Agent-Monitor, а затем /plugin install ccam-insights@claude-code-agent-monitor-plugins.
Что делает команда anomalies?
Она вычисляет статистические отклонения по расходу токенов и стоимости сессий, выводя список аномальных запусков.
Что нужно для работы команды anomalies?
Требуется работающий локальный дашборд Agent Monitor по адресу http://localhost:4820. Запустить его можно командой npm start из корня репозитория.
Исходный текст
anomalies.md · MIT
--- description: List current cost and token outlier sessions via z-score argument-hint: "[threshold]" --- List the current cost/token **outlier** sessions from the Agent Monitor dashboard using a z-score test. **$ARGUMENTS** optionally sets the z-score threshold (default `2.0`; lower = stricter). 1. Fetch the population: - `curl -s "http://localhost:4820/api/sessions?limit=200"` → a session list; each item has `id`, `status`, `model`, `cwd`, `started_at`, `cost`, and `metadata`. 2. Compute the baseline over all returned sessions: - Mean and standard deviation of `cost`. - For sessions where you need token totals, pull `curl -s http://localhost:4820/api/pricing/cost/<id>` and sum `input_tokens + output_tokens + cache_read_tokens + cache_write_tokens`; compute mean and stddev of total tokens too. 3. Flag outliers: any session whose `z = (value − mean) / stddev` exceeds the threshold (default 2.0) on cost (primary) or tokens (secondary). Skip the calc gracefully if stddev is 0. 4. Print the flagged sessions, sorted by descending cost z-score: - Session id (short), model, started_at. - Cost (USD, 4 decimals) and its z-score. - Total tokens and its z-score (when fetched). - A flag tag: 🔴 if z > 3, 🟡 if z > 2. Output rules: a Markdown table of flagged sessions only; currency in USD to 4 decimals; z-scores to 2 decimals; if nothing exceeds the threshold, say "No cost/token outliers above z=<threshold>" and report the top session by cost for context. Cite only API values — never fabricate. If the dashboard is unreachable at `http://localhost:4820`, tell the user to start it with `npm start` from the repo root.
© Son Nguyen · MIT · hoangsonww/Claude-Code-Agent-Monitor