AGENT SKILL

session-stats

Shows token usage, model distribution, turn count, duration, tool usage, tool errors, and frustration signals (correction phrases, stuck tool-call loops) for a Claude Code session. Use when the user asks about token usage, session cost, model breakdown, what tool errors happened, or whether they got stuck in a loop -- "session stats", "how much did this session use", "what tool errors happened", "was I stuck in a loop". For the full session profile (tasks, messages, summary) rather than usage stats alone, use session-detail instead.

License 许可
Apache-2.0
最近更新
2026-11-15
Stars
★ 0
Forks
0

01 前言 Front Matter

name
session-stats
description
Shows token usage, model distribution, turn count, duration, tool usage, tool errors, and frustration signals (correction phrases, stuck tool-call loops) for a Claude Code session. Use when the user asks about token usage, session cost, model breakdown, what tool errors happened, or whether they got stuck in a loop -- "session stats", "how much did this session use", "what tool errors happened", "was I stuck in a loop". For the full session profile (tasks, messages, summary) rather than usage stats alone, use session-detail instead.
allowed-tools
Bash(python3 "${CLAUDE_PLUGIN_ROOT}/scripts/session_store.py":*) Bash(python3 "${CLAUDE_PLUGIN_ROOT}/scripts/session_transcript.py":*)

02 资源文件 1

03 SKILL.md 正文

Session Stats

Show detailed statistics for a single session.

When to Use

  • Wants a token-usage/cost/model breakdown for one session, and nothing more
  • "session stats", "how much did this session use", "model breakdown"
  • Wants to know what tool errors happened in a session, or whether they got stuck in a repeated tool-call loop or pushed back with a correction — "what tool errors happened", "was I stuck in a loop", "did I get frustrated in that session"

When NOT to Use

  • The full session profile (tasks, messages, summary), not just usage stats → use session-detail instead
  • Interruption recovery, not error listing ("my session crashed, help me continue") → use session-recover instead

Step 1: Resolve the session

If the user provides a session ID or path, use it directly. Otherwise, find the current session:

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/session_store.py" current

Use the path field from the result. This resolves the live session directly (via its own session ID), not by matching the current directory against a project name — safe even when the current working directory doesn't match where the session actually started (e.g. a worktree created mid-session).

Step 2: Run the stats script

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/session_transcript.py" stats <session-jsonl-path>

For tool errors or frustration signals instead of (or alongside) usage stats, run the matching subcommand on the same session path:

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/session_transcript.py" errors <session-jsonl-path>
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/session_transcript.py" irritation <session-jsonl-path>

Step 3: Present results

Each subcommand outputs its own JSON object. Present as a visual summary:

  • stats — duration and turns as headline stats; token usage as a breakdown (input, output, cache read, cache create) with totals; model distribution as a list showing which models were used and how many turns each; tool usage as a ranked list (most used first)
  • errors — a list of tool errors (timestamp, tool name, truncated error content); report the count first, then the list
  • irritation — correction phrases (timestamp, matched phrase, excerpt) and stuck tool-call loops (tool name, consecutive-call count); report both counts, then the details

Note: Cost estimation is not available. Report raw token counts and model names only.

irritation's correction-phrase matching is a simple substring heuristic (case-insensitive, phrases like "wrong", "stop", "undo") — it can false-positive on unrelated uses of those words. Present matches as signals to review, not confirmed frustration.

Testing & Validation

Eval suite: evals/session-stats/ — 3 scenarios (tool-error reporting, token/model breakdown reporting, loop/frustration detection), skill-tester Quick Workflow blind comparison, all passed. Eval 3 verified the error/frustration-detection capability is used (not a generic token summary) and reports concrete evidence, not a bare yes/no. get_stats/get_errors/get_irritation_signals's own branching logic is additionally directly unit-tested via tests/test_session_transcript.py.

Last dated run record: evals/session-stats/workspace/iteration-1/eval-{1,2,3}/with_skill/grading.json, 2026-09-03. scripts/smoke_test.py structural self-check also passing as of the same date.

Verify this skill activates on:

  • "session stats"
  • "how much did this session use"
  • "what models were used in this session"
  • "what tool errors happened in that session"
  • "was I stuck in a loop"

Verify it does NOT activate on:

  • "show me everything about this session" (full profile) → session-detail
  • "my session crashed, help me continue" (interruption recovery, not error listing) → session-recover

Quality gates:

  • [ ] Step 1's current call needs no --format flag — the command always emits JSON
  • [ ] irritation results are presented as signals to review, never as confirmed frustration
  • [ ] errors entries attribute the correct tool_name via tool_use_id matching, not silently "unknown"

04 同仓库更多 Skills

AndreHahm
AndreHahm/andres-cc-marketplace

demo

Fixture skill used by scripts.marketplace_ci sync tests.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

export-demo

Fixture skill used by scripts.marketplace_ci export tests.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

work-to-development

Validate an accepted Linear Issue's readiness for implementation (criteria, dependencies, duplicate/existing artifacts) and request governed branch/worktree creation through git-kit:starting-work — recording work-started Git/GitHub evidence and a deliberate Linear Started transition only after Git identity is read back and verified. Use when asked to start work on a Linear issue, begin development for an accepted issue, or prepare an accepted issue for implementation. Never creates a branch directly — always delegates to git-kit.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

work-linking

Create and maintain stable cross-system links and authority labels between Notion and Linear records, and detect/repair drift between them. Use when asked to link a Notion record to a Linear record, check for drift between Notion and Linear, or repair a broken/stale link. Repairs only the bounded non-authoritative copy or link — never chooses by newest timestamp, and never creates a reverse-write loop against either system's own authority.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

status-and-learning

Produce a dated, explicitly non-live Linear-to-Notion progress summary, or capture an outcome/learning after work completes. Use when asked to summarize progress to Notion, report portfolio status, or capture what was learned from a completed piece of work — not to disposition open follow-up items (see open-item-management for that). Never runs automatically or continuously — every summary is a deliberate, approved snapshot, not a live sync.

★ 0
AndreHahm
AndreHahm/andres-cc-marketplace

repository-gates

Discover, delegate, record, and invalidate this repository's actual Git/GitHub lifecycle gates (pre-commit, pre-push, PR required checks, Codex delta review, review requirements, merge rights) and the repository-policy provider profile that maps governed operations to git-kit. Use when asked what gates apply to this repository, to discover repository policy before starting Wave 2 work, or to check whether prior gate evidence is still valid after new commits. Discovery and delegation only — never executes a gate's own internal logic, and never invents a gate the repository doesn't actually define (in particular, never assumes a "Review Changes" gate exists).

★ 0