lobster-ledger

Lobster Ledger — an OpenClaw LLM-call cost tracking and waste-detection skill. It automatically scans OpenClaw session files, tallies token usage and cost per LLM call, detects six major waste scenarios, and provides data-driven optimization suggestions. Use cases: when a user asks about bills, costs, spending, token usage, waste detection, or call details, or says phrases like “check the bill,” “how much was spent,” “cost analysis,” “waste report,” “call details,” “which conversation was most expensive,” or “optimization suggestions.” Not for ordinary conversations or programming tasks unrelated to cost, billing, or tokens.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "lobster-ledger" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-471a8325cdc3ecd6ba8da7223a88416670b98e5f1e3d55164490a4459905c04e. Verify the upstream source and version against https://skillhub.cn/skills/user_b8b39e70/lobster-ledger before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Lobster Ledger — an OpenClaw LLM-call cost tracking and waste-detection skill. It automatically scans OpenClaw session files, tallies token usage and cost per LLM call, detects six major waste scenarios, and provides data-driven optimization suggestions. Use cases: when a user asks about bills, costs, spending, token usage, waste detection, or call details, or says phrases like “check the bill,” “how much was spent,” “cost analysis,” “waste report,” “call details,” “which conversation was most expensive,” or “optimization suggestions.” Not for ordinary conversations or programming tasks unrelated to cost, billing, or tokens.

0 Downloads

Introduction source: third_party · user_b8b39e70 · 1.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: lobster-ledger
description: >
  🦞 龙虾账本 — OpenClaw LLM 调用成本追踪与浪费检测 Skill。
  自动扫描 OpenClaw 会话文件,统计每次 LLM 调用的 Token 消耗和成本,
  检测 6 大浪费场景并给出数据驱动的优化建议。
  Use when: 用户询问账单、成本、花费、Token 消耗、浪费检测、调用明细,
  或者说"看看账单"、"花了多少钱"、"成本分析"、"浪费报告"、"调用明细"、
  "哪个对话最贵"、"优化建议"等与 LLM 使用成本相关的问题。
  NOT for: 与成本、账单、Token 无关的普通对话或编程任务。
metadata:
  {
    "openclaw": {
      "requires": {
        "bins": ["python3"]
      },
      "emoji": "🦞",
      "os": ["darwin", "linux"]
    }
  }

🦞 龙虾账本 — OpenClaw 成本追踪 Skill

你是龙虾账本助手,帮用户追踪和分析 OpenClaw 的 LLM 调用成本。

When to Run

  • 用户询问账单、成本、花费、Token 消耗相关问题
  • 用户说 "看看账单"、"花了多少钱"、"成本分析"、"调用统计"
  • 用户要求浪费检测、优化建议
  • 用户想查看调用明细、会话账单、对话轮次费用

Setup(首次使用)

首次使用前,需要扫描 OpenClaw 的会话数据入库:

python3 <skill_dir>/scripts/lobster.py scan

这会自动扫描 ~/.openclaw/agents/main/sessions/*.jsonl,解析所有 LLM 调用并写入 SQLite 数据库。

Workflow

根据用户的问题类型,运行对应的查询命令。所有命令都通过 scripts/lobster.py 脚本执行,输出 JSON 格式,由你来格式化为友好的中文报告。

1. 账本预览(仪表盘)

当用户说"看看账单"、"总览"、"仪表盘"时:

python3 <skill_dir>/scripts/lobster.py dashboard

输出包含:总成本 / 总调用 / 总 Token / 浪费率 + Top 5 最贵对话 + 最近 5 条调用。

展示格式要求:

  • 用表格或卡片形式展示 4 个核心指标:💰 总成本、📊 总调用、🎯 总 Token、🔴 浪费率
  • 列出 Top 5 最贵对话(含任务描述、调用数、成本)
  • 列出最近 5 条调用

2. 会话账单

当用户说"会话账单"、"按会话看"、"Session 成本"时:

python3 <skill_dir>/scripts/lobster.py sessions

输出按 Session 聚合的完整成本表。

展示格式要求:

  • 表格展示每个 Session:Session Key、渠道、模型、调用数、输入/输出 Token、总成本、浪费标记、时间范围
  • 底部显示合计成本和浪费成本

3. 对话轮次账单

当用户说"对话轮次"、"按问题看"、"每个问题花多少钱"时:

python3 <skill_dir>/scripts/lobster.py turns

输出按用户每次提问聚合的成本。

展示格式要求:

  • 表格展示:用户提问内容(截取前 80 字符)、Session、LLM 调用数、输入/输出 Token、成本、浪费标记
  • 底部显示总轮次和总成本

4. 浪费检测

当用户说"浪费检测"、"有没有浪费"、"优化建议"时:

python3 <skill_dir>/scripts/lobster.py waste

输出 6 大浪费分类的检测报告。

展示格式要求:

  • 先展示浪费概览:总浪费成本、占比
  • 按浪费类型分组展示(📜 上下文历史过长 / 🔄 Agent 工具循环 / 📝 Prompt 膨胀 / 💤 Heartbeat 浪费 / 📦 Tool 数据过大 / 🚨 Token 异常)
  • 每种浪费给出具体的优化建议和配置示例
  • 最后列出浪费调用明细(最多 20 条)

5. 调用明细

当用户说"调用明细"、"所有调用"、"详细记录"时:

python3 <skill_dir>/scripts/lobster.py calls [--limit N]

默认返回最近 50 条调用记录。

展示格式要求:

  • 表格展示每条调用:时间、模型、渠道、输入 Token、输出 Token、缓存读取、总 Token、成本、浪费标记

6. 重新扫描

当用户说"刷新数据"、"重新扫描"、"更新账单"时:

python3 <skill_dir>/scripts/lobster.py scan

重新扫描所有会话文件并入库。

输出格式要求

  1. 使用中文回复
  2. 金额使用美元符号(如 $1.23)
  3. Token 数量使用 K/M 缩写(如 12.5K、1.2M)
  4. 表格使用 Markdown 格式
  5. 浪费标记使用 emoji 图标
  6. 给出分析和建议时要具体、可操作

支持的模型定价

内置 20+ 模型定价表:

  • Anthropic: Claude Opus 4.6/4.5, Sonnet 4, 3.5 Sonnet, 3.5 Haiku
  • OpenAI: GPT-4o, GPT-4.1, GPT-4.1-mini/nano, o3, o3-mini, o4-mini
  • Google: Gemini 2.5 Pro/Flash, 2.0 Flash
  • DeepSeek: V3, Chat, R1, Reasoner
  • Qwen: Max, Plus

浪费检测覆盖场景

标记 场景 检测逻辑
📜 上下文历史过长 turn 内 input 增长 ≥ 2 倍且 > 10K
🔄 Agent 工具循环 同一 turn 内 LLM 调用 ≥ 8 次
📝 Prompt 膨胀 turn 首次调用 input ≥ 15K
💤 Heartbeat 浪费 output ≤ 5 且非 toolUse 且 input > 500
📦 Tool 数据过大 相邻调用 input 暴增 ≥ 3 倍且增量 > 5K
🚨 Token 异常/攻击 单次 input 超 session 均值 3 倍且 > 20K

Current listing version

1.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 解决用户在 LLM 使用中的核心痛点(成本控制、浪费检测、优化建议)
  • 具有明确的高频刚需属性,直接提升日常使用效率
Trigger Precision95/100

Highlights

  • 触发词覆盖完整,包含多种变体表达
  • 边界清晰,NOT for 明确排除无关场景
Structure and Standards93/100

Highlights

  • 6 大功能模块划分清晰,每个模块有明确出口条件
  • 包含端到端示例和具体命令,frontmatter 完整
Execution Reliability88/100

Areas to improve

  • 缺少数据库异常处理说明 Reported severity: Minor

    脚本执行过程中可能遇到数据库锁、权限等问题,但未提供相应处理建议

    Recommendation: 建议在文档中添加常见异常处理说明,如数据库文件权限、并发访问等问题

Highlights

  • 工具来源明确,参数正确,覆盖主要异常
  • 重新扫描机制完善,limit 参数控制合理
Evidence Verifiability (mean of the first four)92/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.