Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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):

  1. Full arg string contains all-projects → --all-projects --output <formats>
  2. Full arg string contains project (and not already caught above) → --project-cost --output <formats>
  3. 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
Полный SKILL.md на GitHub

Установить session-metrics в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

CHANGELOG.mdreferences/custom-prompts.mdreferences/instance-dashboard.mdreferences/jsonl-schema.mdreferences/model-compare.mdreferences/model-compare/prompts/01_claudemd_summarise.mdreferences/model-compare/prompts/02_english_prose.mdreferences/model-compare/prompts/03_code_review.mdreferences/model-compare/prompts/04_stack_trace_debug.mdreferences/model-compare/prompts/05_tool_heavy_task.mdreferences/model-compare/prompts/06_cjk_prose.mdreferences/model-compare/prompts/07_json_reshape.mdreferences/model-compare/prompts/08_csv_transform.mdreferences/model-compare/prompts/09_typescript_refactor.mdreferences/model-compare/prompts/10_instruction_stress.mdreferences/platform-notes.mdreferences/post-export-audit.mdreferences/pricing.mdreferences/tasks-companion.mdscripts/_analytics.pyscripts/_charts.pyscripts/_cli.pyscripts/_constants.pyscripts/_data.pyscripts/_dispatch.pyscripts/_dt.pyscripts/_health.pyscripts/_html_sections.pyscripts/_invariants.pyscripts/_json_export.pyscripts/_md_render.pyscripts/_report.pyscripts/_time_of_day.pyscripts/_turn_parser.pyscripts/_tz.pyscripts/_user_prompt.pyscripts/session-metrics-quick.shscripts/session-metrics.pyscripts/session_metrics_compare.py

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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить session-metrics с