session-report
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSession Report
会话报告
Produce a self-contained HTML report of Claude Code usage and save it to the current working directory.
生成一份独立的Claude Code使用情况HTML报告并保存到当前工作目录。
Steps
步骤
-
Get data. Run the bundled analyzer (default window: last 7 days; honor a different range if the user passed one, e.g.,
24h, or30d). The scriptalllives in the same directory as this SKILL.md — use its absolute path:analyze-sessions.mjsshnode <skill-dir>/analyze-sessions.mjs --json --since 7d > /tmp/session-report.jsonFor all-time, omit.--since -
Read. Skim
/tmp/session-report.json,overall,by_project,by_subagent_type,by_skill,cache_breaks.top_prompts -
Copy the template (also bundled alongside this SKILL.md) to the output path in the current working directory:sh
cp <skill-dir>/template.html ./session-report-$(date +%Y%m%d-%H%M).html -
Edit the output file (use Edit, not Write — preserve the template's JS/CSS):
- Replace the contents of with the full JSON from step 1. The page's JS renders the hero total, all tables, bars, and drill-downs from this blob automatically.
<script id="report-data" type="application/json"> - Fill the block with 3–5 one-line findings. Express figures as a % of total tokens wherever possible (total =
<!-- AGENT: anomalies -->). One line per finding, exact markup:overall.input_tokens.total + overall.output_tokensClasses:html<div class="take bad"><div class="fig">41.2%</div><div class="txt"><b>cc-monitor</b> consumed 41% of the week across just 3 sessions</div></div>for waste/anomalies (red),.take badfor healthy signals (green),.take goodfor neutral facts (blue). The.take infois one short number (a %, a count, or a multiplier like.fig). The12×is one plain-English sentence naming the project/skill/prompt; wrap the subject in.txt. Look for: a project or skill eating a disproportionate share, cache-hit <85%, a single prompt >2% of total, subagent types averaging >1M tokens/call, cache breaks clustering.<b> - Fill the block (at the bottom of the page) with 1–4
<!-- AGENT: optimizations -->suggestions tied to specific rows (e.g. "<div class="callout">spawned 7 subagents for 8.1% of total — scope it to fewer parallel agents")./weekly-status - Do not restructure existing sections.
- Replace the contents of
-
Report the saved file path to the user. Do not open it or render it.
-
获取数据 运行内置的分析器(默认时间窗口:最近7天;如果用户传入了其他时间范围则使用对应范围,例如、
24h或者30d)。all脚本和本SKILL.md存放在同一目录下,请使用它的绝对路径:analyze-sessions.mjsshnode <skill-dir>/analyze-sessions.mjs --json --since 7d > /tmp/session-report.json如果需要统计全量数据,省略参数即可。--since -
读取,浏览
/tmp/session-report.json、overall、by_project、by_subagent_type、by_skill、cache_breaks字段内容。top_prompts -
复制模板(同样和本SKILL.md放在同一目录下)到当前工作目录的输出路径:sh
cp <skill-dir>/template.html ./session-report-$(date +%Y%m%d-%H%M).html -
编辑输出文件(使用编辑操作,不要直接写入覆盖,保留模板的JS/CSS内容):
- 将的内容替换为步骤1得到的完整JSON,页面的JS会自动根据这份数据渲染头部总览、所有表格、柱状图、下钻内容。
<script id="report-data" type="application/json"> - 填充块,添加3-5条单行发现,尽可能用占总tokens的百分比展示数据(总token数 =
<!-- AGENT: anomalies -->)。每条发现占一行,使用固定标记格式:overall.input_tokens.total + overall.output_tokens样式类说明:html<div class="take bad"><div class="fig">41.2%</div><div class="txt"><b>cc-monitor</b> consumed 41% of the week across just 3 sessions</div></div>用于标记浪费/异常情况(红色),.take bad用于标记健康信号(绿色),.take good用于标记中性事实(蓝色)。.take info是简短数值(百分比、计数或者类似.fig的倍数),12×是一句简单说明,标注对应的项目/技能/提示词,将主体内容用.txt包裹。重点关注这些异常:某个项目或技能消耗占比过高、缓存命中率<85%、单个提示词占总消耗2%以上、子Agent类型单调用平均消耗>1M tokens、缓存失效集中出现。<b> - 填充页面底部的块,添加1-4条
<!-- AGENT: optimizations -->格式的优化建议,和具体数据行对应(例如"<div class="callout">spawned 7 subagents for 8.1% of total — scope it to fewer parallel agents")。/weekly-status - 不要修改现有页面结构。
- 将
-
告知用户保存的文件路径,不要打开或者渲染报告文件。
Notes
注意事项
- The template is the source of interactivity (sorting, expand/collapse, block-char bars). Your job is data + narrative, not markup.
- Keep commentary terse and specific — reference actual project names, numbers, timestamps from the JSON.
- already includes subagent tokens and rolls task-notification continuations into the originating prompt.
top_prompts - If the JSON is >2MB, trim to 100 entries and
top_promptsto 100 before embedding (they should already be capped).cache_breaks
- 模板提供了所有交互能力(排序、展开/收起、方块柱状图),你的任务是填充数据和说明内容,不需要修改页面标记。
- 评论要简洁具体,引用JSON中的真实项目名、数值、时间戳。
- 已经包含了子Agent的tokens消耗,并且将任务通知的后续请求合并到了原始提示词中。
top_prompts - 如果JSON大小超过2MB,嵌入前将裁剪到100条,
top_prompts裁剪到100条(默认就应该有上限限制)。 ",cache_breaks