Token Monitor

v1.0.0

分析 OpenClaw 会话 JSONL 文件,监控各 skill/功能的 token 消耗(输入/输出/缓存命中)和成功率。当需要分析会话 token 使用、跟踪性能或生成使用报告时使用。关键词触发:token、会话分析、skill 性能、使用报告。

0· 122·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for qingyu24/qy-token-monitor.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Token Monitor" (qingyu24/qy-token-monitor) from ClawHub.
Skill page: https://clawhub.ai/qingyu24/qy-token-monitor
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Required binaries: python3
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install qy-token-monitor

ClawHub CLI

Package manager switcher

npx clawhub@latest install qy-token-monitor
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (token/session analysis) align with the included script and instructions. The skill only requires python3 and operates on session files under ~/.claude/projects and the local ~/.claude/skills directory to map skill names — which is expected for this purpose.
Instruction Scope
SKILL.md instructs the agent to run the local script against files in the user's home (~/.claude/projects) and to read ~/.claude/skills; this is coherent with session analysis but means the tool will read potentially sensitive local session data. The SKILL.md references a metrics-calculation doc that is not present in the manifest (minor inconsistency). The instructions use a {baseDir} placeholder (ambiguous) — user should ensure the correct path when running.
Install Mechanism
No install spec — instruction-only with an included Python script. No external downloads, no archive extraction, and no package installs are requested in the manifest.
Credentials
The skill declares no required environment variables, no credentials, and no config paths beyond reading files under the user's home. The script reads local files (session JSONL and ~/.claude/skills) which is proportional to its stated goal; it does not access unrelated secrets or cloud credentials.
Persistence & Privilege
always is false and the skill does not request persistent platform privileges. The script appears to only read files and write reports (to stdout or chosen output path) and does not modify other skills or system-wide configuration.
Assessment
This skill appears to do what it says: analyze local OpenClaw/Claude session JSONL files for token usage and produce reports. Before installing or running it, review these points: 1) The tool reads files under ~/.claude/projects and ~/.claude/skills — those session files can contain sensitive conversation content, so run it only if you trust the environment and code. 2) Inspect scripts/analyze_session.py locally (it is included) to verify there are no unexpected network calls or writes; the provided script shows only local file I/O and no networking. 3) When running, prefer an explicit output path (use --output) and run in a controlled directory/sandbox if you have privacy concerns. 4) SKILL.md references a metrics document that is not present (references/metrics-calculation.md) and uses a {baseDir} placeholder — ensure you run the correct script path. If you need higher assurance, run the script in an isolated environment or review/execute it line-by-line before giving it access to your real session files.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

📊 Clawdis
OSmacOS · Linux
Binspython3
latestvk97c9yyft5txxa3ee5hambgvah83gmnj
122downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0
macOS, Linux

Token 监控器

概述

分析 OpenClaw 会话 JSONL 文件,追踪:

  • Token 消耗统计(输入/输出/缓存命中)
  • 成功率/失败率
  • Skill/功能级别的详细分析
  • 性能指标

快速开始

# 分析单个会话
python {baseDir}/scripts/analyze_session.py --session-file ~/.claude/projects/<项目>/<会话>.jsonl

# 分析整个项目
python {baseDir}/scripts/analyze_session.py --project-dir ~/.claude/projects/<项目>

# 生成 HTML 报告
python {baseDir}/scripts/analyze_session.py --project-dir ~/.claude/projects/<项目> --format html --output report.html

# 按 skill 名称筛选
python {baseDir}/scripts/analyze_session.py --skill "skill-name" --project-dir ~/.claude/projects/<项目>

功能说明

  1. 解析会话文件:读取 OpenClaw 项目的 .jsonl 会话文件
  2. 提取使用数据:收集 token 数量、工具调用等信息
  3. 按 Skill 分类:按 skill/工具名称分组操作
  4. 计算指标
    • 输入 tokens
    • 输出 tokens
    • 缓存读取 tokens
    • 缓存写入 tokens
    • 总 tokens
    • 成功率/失败率
    • 平均延迟
  5. 生成报告:输出结构化报告(JSON、Markdown 或 HTML)

输出格式

JSON 输出

{
  "summary": {
    "总会话数": 10,
    "总消息数": 150,
    "输入tokens": 30000,
    "输出tokens": 15000,
    "缓存读取tokens": 5000,
    "总tokens": 50000
  },
  "skills": {
    "skill-name": {
      "调用次数": 5,
      "输入tokens": 8000,
      "输出tokens": 2000,
      "缓存读取tokens": 1000,
      "总tokens": 11000,
      "成功率": 0.95
    }
  }
}

HTML 报告

交互式报告包含:

  • 汇总仪表板
  • Skill 级别详细表格
  • Token 分布可视化
  • 成功率指示器

会话文件结构

会话文件为 JSONL 格式,每条记录如下:

{
  "type": "message",
  "message": {
    "role": "assistant",
    "content": [...],
    "usage": {
      "input_tokens": 1000,
      "output_tokens": 500,
      "cache_read_input_tokens": 200
    }
  },
  "timestamp": "2026-03-16T07:12:47.060Z"
}

参考文档

  • references/session-format.md - 会话文件格式详细说明
  • references/metrics-calculation.md - 指标计算方式

Comments

Loading comments...