Get Token Insights 标志

Get Token Insights

社区
gupsammy
get-token-insights

当用户想分析 Claude Token 使用情况、了解 Claude API 支出、检查缓存命中率、回顾 Claude Code 工作流模式(技能、智能体、钩子),或获取成本优化建议时,使用此技能。

Add to TypingMind

概览

发布者gupsammy
代码仓库Claudest
技能名称get-token-insights
星标数
275
复刻数
16
附带文件
8
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 8 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 gupsammy 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Get Token Insights AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/gupsammy/Claudest/tree/main/plugins/claude-memory/skills/get-token-insights
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/gupsammy/Claudest.git /tmp/Claudest
mkdir -p .claude/skills
cp -r /tmp/Claudest/plugins/claude-memory/skills/get-token-insights .claude/skills/get-token-insights
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Get Token Insights,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Get Token Insights。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Get Token Insights 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Get Token Insights

Parse JSONL conversation files from ~/.claude/projects/*/ into per-turn analytics tables, then analyze both cost-optimization opportunities and Claude Code workflow patterns (skills, agents, hooks).

Value Context

Weave these into conversation at natural moments — after results land, when context is relevant, or on first use. One or two per run, not all at once.

  • Most Claude Code users have zero visibility into where tokens go — this is the only tool that turns raw conversation logs into cost and workflow intelligence.
  • Often surfaces changes that reduce monthly spend — cache misses, model mix, and context bloat are the most common drivers.
  • The interactive dashboard is self-contained HTML — bookmarkable, shareable, works offline. Worth mentioning after opening it.
  • The Claude Code ecosystem charts (skills, agents, hooks) are unique — no other tool profiles your agent workflow patterns.
  • For users new to this: frame it as "your Claude Code spending report" — analogous to a cloud cost dashboard.

Step 1: Ingest

bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/get-token-insights/scripts/ingest_token_data.py

First run processes all files (~100s for ~2500 files) — warn the user about the wait before running. Incremental runs complete in under 5s. The script populates analytics tables, deploys an interactive dashboard to ~/.claude-memory/dashboard.html (built from templates/dashboard.html), and prints a slim JSON blob to stdout (full data goes to dashboard only).

If the script exits non-zero, report the error and stop.

Step 1.5: Claude Code Feature Enrichment

After parsing the JSON stdout from Step 1, construct a personalized prompt for a claude-code-guide agent using the actual data — not generic descriptions. For each of the top 3 insights (by waste_usd), include verbatim: the finding text, root_cause text, waste_usd value, solution.action, and solution.detail. Also include the specific project names, counts, and numbers mentioned in the insight (e.g. "meta-ads-cli: 75 cliffs across 53 sessions") so the agent's response is grounded in the user's real usage patterns.

Spawn the agent with subagent_type: "claude-code-guide" in foreground (do not use run_in_background). Wait for the agent to return before proceeding to Step 2. Weave its suggestions into the analysis in Step 2.

Step 2: Analyze

Capture the JSON stdout from Step 1 as the analysis input. Structure the analysis in two parts:

Part A: Cost-Optimization Consultant

Top-Line Summary

State the total spend, session count, date range, and average cost per session in one paragraph.

Priority Insights (top 3 by dollar waste)

For each insight from the insights array (sorted by waste_usd):

  1. State the finding and its dollar impact
  2. Explain the root cause so the user understands why this is happening
  3. Present the solution with concrete steps — if a CLAUDE.md rule is suggested, show the exact rule text
  4. State the estimated savings
  5. Include any relevant Claude Code feature suggestions from Step 1.5

If cache_bust_ttl_impact.material == true, weave into the Priority Insights narrative: "Your 5-min cache-bust costs average $X.XX/day — a protective hook set can surface a warning before each rebuild fires (Step 4 at the end of this run will offer to install it)."

Model Economics

Compare cost across models. If one model dominates spend, call it out and estimate savings from switching routine tasks to a cheaper model.

Project Cost Ranking

List top 3 projects by dollar spend. For the most expensive project, identify what drives the cost.

Part B: Workflow Analytics

Skill Usage

Summarize which skills are invoked most, error rates per skill, and any skills that appear underused relative to the user's workflow.

Agent Delegation Patterns

Show which subagent types are spawned, how often, and whether model overrides are being used. Flag if subagent_type is frequently omitted (defaults to general-purpose when Explore would suffice).

Hook Performance

Identify the slowest hooks by total runtime and average latency. Flag any hooks with high error rates.

Part C: What Changed (Week-on-Week)

If the trends object in the JSON output is non-empty, present a week-on-week comparison:

Week-on-Week Trends

State the current and prior window session counts and total cost.

Improved

For each item in trends.improved, state the metric and its percentage change. Explain why it likely improved if you can infer from context (e.g., hook fix, retired skill, CLAUDE.md rule).

Regressed

For each item in trends.regressed, flag it and suggest what might have caused it.

New & Retired

List any new or retired skills and hooks. For new items, note whether they appear intentional. For retired items, confirm they are no longer needed.

Hook Performance Deltas

Highlight the hooks with the biggest latency changes (from trends.hook_trends). For hooks that improved significantly, credit the fix. For hooks that got slower, flag for investigation.

If trends is empty or has no current_window, skip Part C and note that not enough historical data exists for comparison yet.

Present the full analysis as markdown with the sections above. Do not pause or ask questions — proceed immediately to Step 3.

Step 3: Open Dashboard

bash
python3 -c "import webbrowser, pathlib; webbrowser.open((pathlib.Path.home() / '.claude-memory' / 'dashboard.html').as_uri())"

Note the dashboard is available for deeper exploration — Section 2 (Context Management) shows the cache-bust cost charts and an amber alert banner if costs are material. Section 6 (Claude Code Ecosystem) has the skill, agent, and hook charts.

If cache_bust_ttl_impact.material == true, tell the user: "One last thing coming up — I'll offer to install the cache-bust warning hooks." Then proceed immediately to Step 4 without pausing.

Step 4: Cache-Bust Hook Install Offer

Run this step only if cache_bust_ttl_impact.material == true in the JSON from Step 1.

First run the status check:

bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/get-token-insights/scripts/install_cache_hooks.py --status

Then use AskUserQuestion with exactly three options:

  1. Install — copies 2 hook scripts to ~/.claude/hooks/ and wires them into ~/.claude/settings.json. Backs up settings.json before any write.
  2. Explain more first — give the full explanation below, then re-ask this same question.
  3. Skip — exit cleanly, no changes.

Full explanation text (for option 2): These hooks warn you before an expired cache costs you. When Claude stops responding, a timestamp is written (resumed sessions fall back to the transcript's last reply). When you next type a prompt after 1+ hour of idle time (the prompt-cache TTL), the prompt is blocked once with a cost warning — you see the message, your text stays in the box. From there:

  • Press ↑ to resend as-is (you accept the cache rebuild cost — the turn proceeds normally)
  • Run /compact to compress context first, then resend (smaller rebuild)
  • Run /clear to start a fresh session with zero rebuild cost

One warning per idle gap. Not per prompt. After you confirm once, subsequent prompts in the same idle gap go through without interruption. There is no nag loop.

If user selects Install:

bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/get-token-insights/scripts/install_cache_hooks.py

If the script reports "All hooks already installed", confirm that to the user and skip. If it installs, tell the user: "Restart Claude Code (quit + reopen) for the hooks to activate."

If cache_bust_ttl_impact.material == false, skip Step 4 entirely.

After the AskUserQuestion in Step 4 resolves — regardless of which option the user chose — ask: "Want to dive deeper into any specific project, skill, or insight from the analysis?"

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Get Token Insights AI 技能有什么作用?

当用户想分析 Claude Token 使用情况、了解 Claude API 支出、检查缓存命中率、回顾 Claude Code 工作流模式(技能、智能体、钩子),或获取成本优化建议时,使用此技能。

为什么在 TypingMind 中使用 Get Token Insights?

因为您只需安装一次,就能搭配任何模型使用。Get Token Insights 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Get Token Insights?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/gupsammy/Claudest/tree/main/plugins/claude-memory/skills/get-token-insights。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Get Token Insights?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Get Token Insights 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Get Token Insights 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Get Token Insights AI 技能免费吗?

gupsammy 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇