session-metrics
БесплатноЗапускает вложенные скриптыНе проверенTally Claude Code session token usage and cost estimates from the raw JSONL conversation log. Trigger when the user asks about session cost, token usage, API…
от centminmod★ 2 752 звезды на GitHubОб этом скилле
Session Metrics
Runs scripts/session-metrics.py against the Claude Code JSONL log to produce
a timeline-ordered cost summary with per-turn and cumulative totals.
Dispatch — how to route this invocation
First positional argument received: $ARGUMENTS[0]
Full argument string: $ARGUMENTS
Read $ARGUMENTS[0] above and match it by literal equality against the
table below. Claude Code already tokenized the arguments shell-style, so no
parsing is required — just compare strings.
$ARGUMENTS[0] |
Route | Then read |
|---|---|---|
all-projects |
Instance-wide dashboard aggregating every project under ~/.claude/projects |
## Instance dashboard (all projects) below |
compare |
Two-session compare on JSONLs that already exist | ## Model comparison below, then references/model-compare.md before running |
compare-run |
Fully automated capture: spawns two claude -p sessions, feeds the suite, then runs --compare |
## Model comparison below, then references/model-compare.md "Workflow A — automated" |
compare-prep |
Print manual capture protocol + 10-prompt suite (fallback when headless is unavailable) | ## Model comparison below |
count-tokens |
API-key-only tokenizer check | ## Model comparison below |
export |
Natural-language export shortcut — scan full arg string to determine session vs project scope | ## Export shortcuts below |
project |
All sessions for the current project — timeline + per-session subtotals + grand total | ## Quick usage below (--project-cost); also scan remaining args for --output format flags |
project-cost |
Alias for project |
## Quick usage below (--project-cost); also scan remaining args for --output format flags |
| (empty, or any other value) | Default single-session report | ## Quick usage below |
This is the single gate that keeps compare mode off the natural-language
path. Do not infer the route from the user's chat history; only use the
literal value of $ARGUMENTS[0] above.
When the skill auto-triggers from a natural-language question ("how much did
this session cost?", "show me token usage"), there are no positional
arguments — $ARGUMENTS[0] is empty — and you always route to the default.
Phrases like "compare 4.6 vs 4.7 cost" arriving as natural language do NOT
produce $ARGUMENTS[0] = compare and must not route into compare mode;
answer them by running the default report on the current session and
suggesting /session-metrics compare-prep if the user wants a real
benchmark.
Pre-flight context
- skill-dir: ${CLAUDE_SKILL_DIR}
- session-id: ${CLAUDE_SESSION_ID}
Export shortcuts
Reached when $ARGUMENTS[0] is export. Scan the full argument string (not just $ARGUMENTS[0]) to determine scope and formats. Apply these checks in order (first match wins):
- Full arg string contains
all-projects→--all-projects --output <formats> - Full arg string contains
project(and not already caught above) →--project-cost --output <formats> - Otherwise → current session
--session ${CLAUDE_SESSION_ID} --output <formats>
Infer format flags from the argument string: html → html, csv → csv, md or markdown → md. Always add json alongside any requested format per the post-export audit convention (see ## Optional post-export audit below).
Always add --quiet to session and project export commands. When exporting, the per-turn detail lives in the written HTML/JSON, so the full stdout timeline is redundant — and at project scope (or for a long session) it can run to thousands of lines, spilling the run into a harness overflow file that buries the [export] path lines you need. --quiet collapses stdout to the legend + grand total + footer (plus the [export] lines), keeping the run inline. Do not add --quiet for --all-projects — its instance dashboard text is already compact and the flag has no effect there.
Examples:
| Full argument string | Command |
|---|---|
export session |
--session ${CLAUDE_SESSION_ID} --quiet --output json |
export session to html |
--session ${CLAUDE_SESSION_ID} --quiet --output html json |
export session metrics to html |
--session ${CLAUDE_SESSION_ID} --quiet --output html json |
export to html |
--session ${CLAUDE_SESSION_ID} --quiet --output html json |
export project |
--project-cost --quiet --output json |
export project to html |
--project-cost --quiet --output html json |
export project sessions |
--project-cost --quiet --output json |
export project sessions to html |
--project-cost --quiet --output html json |
export entire project's session metrics to html |
`--project-cost --qui |
Установить session-metrics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл session-metrics?
Tally Claude Code session token usage and cost estimates from the raw JSONL conversation log. Trigger when the user asks about session cost, token usage, API spend, cache hit rate, input/output tokens, or wants a breakdown of how much a Claude Code session has cost. Also trigger for "how much have we spent", "show me token usage", "session summary", "cost so far", or any request to analyse or display per-turn metrics from the current or a past session. Do NOT auto-dispatch compare mode (--compare / --compare-prep / --compare-run / --count-tokens-only) from natural-language phrases. The skill body uses $ARGUMENTS[0] as the dispatch key — if the first positional argument is not literally "compare", "compare-prep", "compare-run", or "count-tokens", route to the default single-session report.
Как установить скилл session-metrics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл session-metrics запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic