session-report

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Session Report

会话报告

Produce a self-contained HTML report of Claude Code usage and save it to the current working directory.
生成一份独立的Claude Code使用情况HTML报告并保存到当前工作目录。

Steps

步骤

  1. Get data. Run the bundled analyzer (default window: last 7 days; honor a different range if the user passed one, e.g.
    24h
    ,
    30d
    , or
    all
    ). The script
    analyze-sessions.mjs
    lives in the same directory as this SKILL.md — use its absolute path:
    sh
    node <skill-dir>/analyze-sessions.mjs --json --since 7d > /tmp/session-report.json
    For all-time, omit
    --since
    .
  2. Read
    /tmp/session-report.json
    . Skim
    overall
    ,
    by_project
    ,
    by_subagent_type
    ,
    by_skill
    ,
    cache_breaks
    ,
    top_prompts
    .
  3. 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
  4. 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 1. The page's JS renders the hero total, all tables, bars, and drill-downs from this blob automatically.
    • Fill the
      <!-- AGENT: anomalies -->
      block with 3–5 one-line findings. Express figures as a % of total tokens wherever possible (total =
      overall.input_tokens.total + overall.output_tokens
      ). One line per finding, exact markup:
      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>
      Classes:
      .take bad
      for waste/anomalies (red),
      .take good
      for healthy signals (green),
      .take info
      for neutral facts (blue). The
      .fig
      is one short number (a %, a count, or a multiplier like
      12×
      ). The
      .txt
      is one plain-English sentence naming the project/skill/prompt; wrap the subject in
      <b>
      . 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.
    • Fill the
      <!-- AGENT: optimizations -->
      block (at the bottom of the page) with 1–4
      <div class="callout">
      suggestions tied to specific rows (e.g. "
      /weekly-status
      spawned 7 subagents for 8.1% of total — scope it to fewer parallel agents").
    • Do not restructure existing sections.
  5. Report the saved file path to the user. Do not open it or render it.
  1. 获取数据 运行内置的分析器(默认时间窗口:最近7天;如果用户传入了其他时间范围则使用对应范围,例如
    24h
    30d
    或者
    all
    )。
    analyze-sessions.mjs
    脚本和本SKILL.md存放在同一目录下,请使用它的绝对路径:
    sh
    node <skill-dir>/analyze-sessions.mjs --json --since 7d > /tmp/session-report.json
    如果需要统计全量数据,省略
    --since
    参数即可。
  2. 读取
    /tmp/session-report.json
    ,浏览
    overall
    by_project
    by_subagent_type
    by_skill
    cache_breaks
    top_prompts
    字段内容。
  3. 复制模板(同样和本SKILL.md放在同一目录下)到当前工作目录的输出路径:
    sh
    cp <skill-dir>/template.html ./session-report-$(date +%Y%m%d-%H%M).html
  4. 编辑输出文件(使用编辑操作,不要直接写入覆盖,保留模板的JS/CSS内容):
    • <script id="report-data" type="application/json">
      的内容替换为步骤1得到的完整JSON,页面的JS会自动根据这份数据渲染头部总览、所有表格、柱状图、下钻内容。
    • 填充
      <!-- AGENT: anomalies -->
      块,添加3-5条单行发现,尽可能用占总tokens的百分比展示数据(总token数 =
      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
      是一句简单说明,标注对应的项目/技能/提示词,将主体内容用
      <b>
      包裹。重点关注这些异常:某个项目或技能消耗占比过高、缓存命中率<85%、单个提示词占总消耗2%以上、子Agent类型单调用平均消耗>1M tokens、缓存失效集中出现。
    • 填充页面底部的
      <!-- AGENT: optimizations -->
      块,添加1-4条
      <div class="callout">
      格式的优化建议,和具体数据行对应(例如"
      /weekly-status
      spawned 7 subagents for 8.1% of total — scope it to fewer parallel agents")。
    • 不要修改现有页面结构。
  5. 告知用户保存的文件路径,不要打开或者渲染报告文件。

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.
  • top_prompts
    already includes subagent tokens and rolls task-notification continuations into the originating prompt.
  • If the JSON is >2MB, trim
    top_prompts
    to 100 entries and
    cache_breaks
    to 100 before embedding (they should already be capped).
  • 模板提供了所有交互能力(排序、展开/收起、方块柱状图),你的任务是填充数据和说明内容,不需要修改页面标记。
  • 评论要简洁具体,引用JSON中的真实项目名、数值、时间戳。
  • top_prompts
    已经包含了子Agent的tokens消耗,并且将任务通知的后续请求合并到了原始提示词中。
  • 如果JSON大小超过2MB,嵌入前将
    top_prompts
    裁剪到100条,
    cache_breaks
    裁剪到100条(默认就应该有上限限制)。 ",