session-report
Generates a self-contained HTML report of session usage — tokens, cache efficiency, subagent costs, and slash command frequency — from local transcripts.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- session-report
- description
- Generates a self-contained HTML report of session usage — tokens, cache efficiency, subagent costs, and slash command frequency — from local transcripts.
- when_to_use
- Run when the user asks what a session or period cost — "token usage", "how much did I spend", "cache hit rate", "session report". Works for Claude Code (~/.claude) and Codex (~/.codex). Pass a time range as argument (24h, 7d, 30d, all) — defaults to 7d. Not for saving state to continue work later — that's session-handoff.
- argument-hint
- [24h|7d|30d|all]
- disable-model-invocation
- true
02 资源文件 6
- 脚本analyze-claude.mjs37.2 KB
- 脚本analyze-codex.mjs32.8 KB
- 脚本lib/periods.mjs4.7 KB
- 脚本lib/read-store.mjs16.2 KB
- 参考文档model-prices.json3.7 KB
- 参考文档template.html100.1 KB
03 SKILL.md 正文
Session Report
Produce a self-contained HTML report of session usage and save it to
<git-root>/.session-report/.
Steps
-
Detect tool and pick analyzer. Run:
if [ -n "$CODEX_HOME" ] || [ -n "$CODEX_SANDBOX_NETWORK_DISABLED" ]; then TOOL=codex; ANALYZER=analyze-codex.mjs elif [ -d "$HOME/.codex/sessions" ] && [ ! -d "$HOME/.claude/projects" ]; then TOOL=codex; ANALYZER=analyze-codex.mjs elif [ -d "$HOME/.claude/projects" ]; then TOOL=claude; ANALYZER=analyze-claude.mjs else TOOL=codex; ANALYZER=analyze-codex.mjs fiAmbiguous case — if both
~/.codex/sessionsand~/.claude/projectsexist and no env var matched, the shell above falls through toTOOL=claude. Honor that result exactly:- If you are Codex: override to
TOOL=codex; ANALYZER=analyze-codex.mjs - If you are Claude Code: the shell result is correct — keep
TOOL=claude; ANALYZER=analyze-claude.mjs. Do not change it.
The user can also force the tool with
--tool codexor--tool claude. - If you are Codex: override to
-
Parse time range from
$ARGUMENTS(e.g.7d,30d,24h). Default:7d. Ifall— omit--since. -
Run the analyzer. Both scripts live alongside this SKILL.md — use the absolute path. Resolve the report directory first and write the JSON there too (it is this skill's working-state home, already gitignored —
/tmpwould strand the intermediate outside the artifact contract). The${TOOL}suffix keeps concurrent runs from different tools from colliding:OUT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.session-report" mkdir -p "$OUT_DIR" # With --since: node <skill-dir>/$ANALYZER --json --since 7d > "$OUT_DIR/session-report-${TOOL}.json" # All-time: node <skill-dir>/$ANALYZER --json > "$OUT_DIR/session-report-${TOOL}.json"Period comparison. When the user asks to compare weeks or periods ("how did this week compare", "week over week"), add
--compare weekly(or7d,24h, any<N>d|<N>h) and, optionally,--periods N(default 4, trailing windows ending now, oldest first;--compare-end <ISO>ends them at a past date instead). The JSON then carriesperiods[]and the report gains a "period comparison" section; without--compareneither exists. The comparison widens the report window to cover every period, so--sinceis not needed alongside it.The analyzers read the usage-trace store when one exists and fall back to transcripts when it doesn't (
--source store|transcripts|auto, defaultauto). The JSON'ssourceandcoveragefields say which one priced the report and why. -
Read
$OUT_DIR/session-report-${TOOL}.json. Skimoverall,by_project,by_subagent_type,by_skill,cache_breaks,top_prompts, andperiodswhen present (apartialperiod had no data at its start, so do not read its totals as a drop). -
Copy the template into the report directory:
# $OUT_DIR was resolved in step 3 cp <skill-dir>/template.html "$OUT_DIR/session-report-$(date +%Y%m%d-%H%M).html"Reports are gitignored working state, not project docs. Before the first write in a repo, run the bootstrap once:
git check-ignore -q .session-report/— if it isn't ignored, ask once ("Reports are scratch — add.session-report/to.gitignore?") and append on yes, or write to.git/info/excludeif the user would rather not touch a tracked file. Never edit either file without asking. Outside a git repo the path falls back to./.session-report/— say so once. AnAGENTS.mdoverride wins. -
Edit the output file (use Edit, not Write — preserve the template's JS/CSS):
-
Replace the contents of
<script id="report-data" type="application/json">with the full JSON from step 3. The analyzers serialize<as\u003c, so transcript text cannot close the script element; preserve those escapes exactly. The page's JS renders everything automatically from this blob. IMPORTANT: the script tag must contain only valid JSON — no comments, no debug lines, no analysis notes. Any non-JSON text before or after the{...}will breakJSON.parse()and leave all sections blank. -
Fill the
<!-- AGENT: anomalies -->block with 3–5 one-line findings. Express figures as % of total tokens (total =overall.input_tokens.total + overall.output_tokens):<div class="take bad"><div class="fig">41.2%</div><div class="txt"><b>project-x</b> consumed 41% of the week across 3 sessions</div></div>Classes:
.take bad(red) for waste/anomalies,.take good(green) for healthy signals,.take info(blue) for neutral. Look for: project eating disproportionate share, cache-hit <85%, single prompt >2% of total, subagents averaging >1M tokens/call, clustering cache breaks.Codex note:
pct_cachedwill be 0 for most OpenAI models — only flag this if the model supports prompt caching. -
Fill the
<!-- AGENT: optimizations -->block with<div class="callout">suggestions. Work the checklist below and write one callout per signal that actually fires — typically 3–6. Each callout must name the row it came from and the change it implies; a suggestion with no number attached to it is noise.Check Data path Fires when Say Cache breaks overall.cache_breaks_over_100k,cache_breaks[]> 0, especially clustered in one project or one day Which project and when, and that a /compactbefore the repeated resume is the cheaper pathSubagent cost overall.subagent.avg_tokens_per_call> 500k per call Which subagent type from by_subagent_typedominates, and that its brief is carrying the context rather than the workCache hit rate overall.input_tokens.pct_cached< 85% (Claude only — see the Codex note) The rate, and which project in by_projectdrags it downProject concentration by_project[].input_tokens.totalone project > 50% of the total Name it with its share and its cost_usd.totalModel mix by_project[].by_model, thetop modelcolumnan expensive model dominates a low- efficiency_scoreprojectThe project, its dominant model, and its cost Per-project efficiency by_project[].efficiency_scoreany project scores below the overall score Which one, and which of cache / msgs / subagents its score is losing on Single-prompt cost top_prompts[0]> 2% of total tokens The prompt, truncated, with its share and session id Session hygiene overall.hours.activevs.wall_clockactive < 50% of wall clock That sessions are being left open, and that every per-hour figure below is diluted by it Skip a row rather than inventing one: an empty checklist entry is a healthy report, not a gap to fill. If nothing fires, say so in a single callout.
-
HTML-escape every transcript-derived project, prompt, model, skill, and tool label inserted into either agent-authored block.
-
Do not restructure existing sections. Each section's body now sits inside a
<details class="fold" open>with its<h2>in the<summary>— the two<!-- AGENT: … -->markers moved with it, so edit by marker, never by line number. Do not add, remove or reorder sections (the "period comparison" section is the template's own and removes itself when the JSON has noperiods), and do not delete the hidden#prompt-histogramcontainer: the render writes to it without a null guard, and removing it kills every render step that follows, including the section nav.
-
-
Report the saved file path. Do not open it or render it.
Notes
- The template auto-adjusts titlebar and command text from
DATA.toolin the JSON. - For Codex: slash commands are extracted from message text (best-effort, not precise attribution). The
by_skilltable shows commands that appeared as/fooin user messages. - For Codex: the subagent replay overcounting problem is handled by the analyzer — events timestamped before the session's own start are discarded.
- If JSON is >2MB, trim
top_promptsandcache_breaksto 100 entries each before embedding.
04 同仓库更多 Skills
orphan
暂无简介
no-blurb
暂无简介
workflow
Routes any dev task into the right execution tier (Small/Medium/Large) and carries condux's operating rules — proportional effort, lazy skill loading, soft gates, implement-yourself-by-default.
usage-trace
Checks and manages durable, local usage capture — ingest, health status, and the opt-in limit snapshot — for Claude Code and Codex. Capture itself runs automatically at session start.
toolkit-skill-standards
Use when writing or reviewing a SKILL.md for jabworks/agentic-toolkit — frontmatter budgets, the trigger contract ("Use when…" description or when_to_use field), progressive disclosure into references/, and keeping a new description out of existing skills' trigger space. Triggers include "review this skill description", "write the frontmatter", "does this collide with an existing skill", "where should this content live". Not for scaffold/sync mechanics; use toolkit-foundry.
toolkit-research-frontier
Use when planning improvement work on jabworks/agentic-toolkit itself — open problems (trigger-collision automation, YAML-strict frontmatter checks, docs-catalog enforcement), existing assets, the next three concrete steps, and the four-front library-health campaign with commands and success criteria. Triggers include "let's improve our toolkit", "let's improve this repo", "what should we improve next", "toolkit roadmap", "open problems", "run the health campaign".