← Back to Skills Marketplace
freedompixels

AI Token消耗监控

by freedompixels · GitHub ↗ · v1.0.2 · MIT-0
cross-platform ✓ Security Clean
94
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install ai-token-usage
Description
AI Token消耗监控。读取会话日志,统计Token消耗,检测异常并提供优化建议。 帮助用户了解AI使用成本,避免意外超支。 当用户说"Token"、"消耗多少"、"Token统计"、"费用"、"超支"时触发。 Keywords: Token, 消耗, 费用, 统计, 监控, 成本.
README (SKILL.md)

Token Monitor - AI Token 消耗监控

监控 AI Token 消耗,检测异常,提供优化建议。

功能

  • 📊 读取 session 日志统计 Token 消耗
  • 🚨 检测异常消耗(短时激增、重复失败等)
  • 💡 给出优化建议
  • 📈 生成消耗趋势报告

使用

检查今日消耗

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --today

检查指定日期

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --date 2026-04-13

检查异常模式

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --check-anomaly

生成优化报告

python3 ~/.qclaw/skills/token-monitor/scripts/token_stats.py --report

异常检测规则

规则 阈值 说明
单日总量 >1000万 严重超标
单小时 >200万 需要检查
重复失败 >3次 死循环风险
浏览器快照 单次>5000字 未压缩

历史数据参考

日期 Input Output Total 状态
4/11 3.46M 117K 28.8M 🚨 超标
4/12 5.57M 127K 37.0M 🚨 严重超标
4/13 1.80M 22K 9.5M ⚠️ 偏高
4/14 430K 20K 3.7M ✅ 正常

4/12是Token浪费最严重的一天:3700万token,根因是Chrome CDP崩溃重试+ClawHub限速重试

优化建议库

  • 浏览器快照用 compact=true
  • 同一操作失败3次立即换方案
  • 限速不硬等,跳转做其他事
  • 后台进程不轮询

数据存储

  • 日志:~/.qclaw/agents/main/sessions/*.jsonl
  • 统计:memory/token-usage-YYYY-MM-DD.json
Usage Guidance
This skill appears to do what it claims: analyze local session logs and save aggregated token-usage JSON files. Before installing, consider: (1) the script will read your session files (~/.qclaw/agents/main/sessions) which may contain message contents—if those messages include sensitive data you may prefer not to run it or to inspect the script first; (2) it writes aggregated stats under ~/.qclaw/workspace/memory; ensure you are comfortable with that storage location; (3) it requires a local Python runtime to execute; (4) although no network calls are present, review the code if you want extra assurance. If you do not want the skill invoked autonomously, disable autonomous invocation in your agent settings.
Capability Analysis
Type: OpenClaw Skill Name: ai-token-usage Version: 1.0.2 The skill is a utility designed to monitor AI token consumption by parsing local session logs located in the user's OpenClaw directory. The Python script `scripts/token_stats.py` reads JSONL files to aggregate usage metrics and saves reports locally to a memory directory, with no evidence of network exfiltration, unauthorized access to sensitive credentials, or malicious prompt injection.
Capability Assessment
Purpose & Capability
Name/description say it will read session logs and count tokens. The SKILL.md and scripts/token_stats.py both reference the same session path (~/.qclaw/agents/main/sessions) and a local memory path (~/.qclaw/workspace/memory). No unrelated credentials, binaries, or external services are requested.
Instruction Scope
Runtime instructions and the script only read local session JSONL files, compute aggregates, print reports, detect anomalies, and save aggregated JSON files. The script does not read unrelated system config, access network endpoints, or exfiltrate data. Note: it does read message-level session files (which may contain sensitive message text) but only stores aggregated token counts.
Install Mechanism
No install spec (instruction-only) and included Python script; no download or third-party installers. Risk from install mechanism is low. Running requires a local Python runtime.
Credentials
The skill requires no environment variables or credentials. It reads only session logs under the agent workspace and writes aggregated stats to the workspace memory directory — proportional to the stated purpose.
Persistence & Privilege
always:false and user-invocable:true. The skill writes files only under ~/.qclaw/workspace/memory and does not change other skills or system settings. Autonomous invocation (model invocation enabled) is the platform default but is not combined here with other concerning privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install ai-token-usage
  3. After installation, invoke the skill by name or use /ai-token-usage
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.2
- Updated keywords in the description to include "成本" (cost). - No functional changes; documentation only.
v1.0.1
- 新增技能:AI Token消耗监控,帮助用户追踪和优化Token使用。 - 支持读取会话日志,统计每日/历史Token消耗。 - 检测异常模式,如短时激增、重复失败等,并给出优化建议。 - 提供消耗趋势报告及详细异常检测规则。 - 明确列出常见Token异常原因及优化方案。
Metadata
Slug ai-token-usage
Version 1.0.2
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is AI Token消耗监控?

AI Token消耗监控。读取会话日志,统计Token消耗,检测异常并提供优化建议。 帮助用户了解AI使用成本,避免意外超支。 当用户说"Token"、"消耗多少"、"Token统计"、"费用"、"超支"时触发。 Keywords: Token, 消耗, 费用, 统计, 监控, 成本. It is an AI Agent Skill for Claude Code / OpenClaw, with 94 downloads so far.

How do I install AI Token消耗监控?

Run "/install ai-token-usage" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is AI Token消耗监控 free?

Yes, AI Token消耗监控 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does AI Token消耗监控 support?

AI Token消耗监控 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created AI Token消耗监控?

It is built and maintained by freedompixels (@freedompixels); the current version is v1.0.2.

💬 Comments