/everything-claude-code:cost-trackingfrom everything-claude-code
Queries a local SQLite database to report Claude Code token usage, spending, and budgets by project, tool, session, or date.
Ships in everything-claude-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
使用此技能从本地 SQLite 数据库分析 Claude Code 的成本和使用历史。它适用于已经安装了成本跟踪钩子或插件并将使用记录写入 ~/.claude-cost-tracker/usage.db 的用户。
来源:从 MayurBhavsar 的过期社区 PR #1304 中抢救。
首先验证前置条件:
command -v sqlite3 >/dev/null && echo "sqlite3 可用" || echo "sqlite3 缺失"
test -f ~/.claude-cost-tracker/usage.db && echo "数据库已找到" || echo "数据库未找到"
如果数据库不存在,不要编造使用数据。告知用户成本跟踪未配置,并建议安装或启用可信的本地成本跟踪钩子/插件。
预期的 usage 表通常每个工具调用或模型交互有一行。列名因跟踪器而异,但以下示例假设:
| 列 | 含义 |
|---|---|
timestamp | 使用事件的 ISO 时间戳 |
project | 项目或仓库名称 |
tool_name | 工具或事件名称 |
input_tokens | 输入 token 数,当有记录时 |
output_tokens | 输出 token 数,当有记录时 |
cost_usd | 预计算的美元成本 |
session_id | Claude Code 会话标识符 |
model | 事件使用的模型 |
优先使用 cost_usd 而非手动计算定价。模型价格和缓存定价会随时间变化,跟踪器应该是每行如何定价的事实来源。
sqlite3 ~/.claude-cost-tracker/usage.db "
SELECT
'今天: $' || ROUND(COALESCE(SUM(CASE WHEN date(timestamp) = date('now') THEN cost_usd END), 0), 4) ||
' | 总计: $' || ROUND(COALESCE(SUM(cost_usd), 0), 4) ||
' | 调用: ' || COUNT(*) ||
' | 会话: ' || COUNT(DISTINCT session_id)
FROM usage;
"
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
SELECT project, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls
FROM usage
GROUP BY project
ORDER BY cost DESC;
"
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
SELECT tool_name, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls
FROM usage
GROUP BY tool_name
ORDER BY cost DESC;
"
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
SELECT date(timestamp) AS date, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls
FROM usage
GROUP BY date(timestamp)
ORDER BY date DESC
LIMIT 7;
"
sqlite3 -header -column ~/.claude-cost-tracker/usage.db "
SELECT session_id,
MIN(timestamp) AS started,
MAX(timestamp) AS ended,
ROUND(SUM(cost_usd), 4) AS cost,
COUNT(*) AS calls
FROM usage
GROUP BY session_id
ORDER BY started DESC
LIMIT 10;
"
展示成本数据时,包含:
对于小金额,使用四位小数格式化货币。对于较大金额,两位小数即可。
cost_usd 存在时,不要从原始 token 数估算成本。SELECT * 导出。/cost-report - 使用同一数据库的命令形式报告。cost-aware-llm-pipeline - 模型路由和预算设计模式。token-budget-advisor - 上下文和 token 预算规划。strategic-compact - 上下文压缩以减少重复的 token 支出。What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: agents: Invalid string: must end with ".md"
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.
272 skills in this plugin
/accessibility使用 WCAG 2.2 AA 级标准设计、实施和审计包容性数字产品。使用此技能为 Web 和原生平台(iOS/Android)生成语义化 ARIA 和辅助功能属性。/agent-architecture-audit智能体和 LLM 应用的全栈诊断。审计 12 层智能体堆栈,检查包装器回归、内存污染、工具纪律失败、隐藏修复循环和渲染损坏。生成按严重程度排序的发现和代码优先修复。对于构建智能体应用、自主循环或任何 LLM 驱动功能的开发者至关重要。/agent-eval在自定义任务上对编码智能体(Claude Code、Aider、Codex 等)进行头对头比较,包含通过率、成本、时间和一致性指标/agent-harness-construction设计和优化 AI 智能体操作空间、工具定义和观察格式,以获得更高的完成率。Other plugins' skills for the same job