tokenwise
它能做什么
TokenWise 能帮你选择既能完成任务、又最便宜的 AI 模型,从而节省 AI 使用费用。它会记录每个任务花了多少钱,还能让你测试哪种模型最适合你。
适用场景
- ✓在不降低回复质量的前提下削减成本。
- ✓检查更简单的模型是否足以应付你的任务。
- ✓了解 AI 费用都花在了哪里。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/tokenwise/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想测试一下 Haiku 模型能不能把这段文字改写得更简单。”
每周 5 个新技能,1 分钟读完。
工作原理
TokenWise 会分析你的任务,并把它交给最合适、性价比最高的 AI 模型。它会记录每个任务的确切花费,还允许你对比不同模型,确保你用的是最佳选项。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
TokenWise — Measurement-Driven Model Router
Overview
A Claude Code skill that auto-routes subtasks to the cheapest model that can handle them (Haiku for grunt work, Sonnet for scoped reasoning, Opus only for synthesis), then logs every routed task to a local NDJSON with real token + cost numbers. Includes an A/B test subcommand that runs the same task across multiple tiers and scores quality, so the routing decisions are verified against the user's real workload — not estimated.
Anthropic's own bug tracker (Issue #27665) reports 93.8% of Max-subscriber Claude Code tokens flow to Opus. Existing routers (claude-router, wshobson, VoltAgent) either pin models statically or route by vibes-based heuristics with no measurement. TokenWise fills the measurement gap.
When to use
- Cutting Claude Code token spend without sacrificing output quality
- Validating whether Haiku/Sonnet is "good enough" for a specific task class before trusting auto-routing
- Auditing where Opus tokens are actually being burned
- Logging per-session cost data for finance or chargeback
Subcommands
/tokenwise:install— guided installer with diff preview, automatic backups, and--dry-runmode/tokenwise:report— per-session token + cost summary vs all-Opus baseline/tokenwise:summary [--week|--month|--all]— historical aggregate with trend/tokenwise:ab "<task>"— A/B test the same task at multiple tiers, generates a markdown comparison/tokenwise:undo— restore CLAUDE.md / settings.json from backup
Routing taxonomy
| Tier | Model | Task class |
|---|---|---|
| Mechanical | Haiku 4.5 | file reads, grep, format, rename, simple edits, doc lookups |
| Scoped reasoning | Sonnet 4.6 | single-file refactor, scoped research, test writing |
| Synthesis | Opus 4.7 | architecture decisions, multi-file refactor, security review |
Safety caps:
- Haiku never spawns further subagents
- Max spawn depth = 2
- Subagents that need a smarter model return to parent — they never escalate on their own
- Tasks under 100 chars with no file context run inline (subagent overhead > savings)
- Subagent context >30k tokens bumps a tier
Privacy
Zero telemetry. All logs in .tokenwise/log.ndjson local to the project. Task descriptions truncated to 80 chars and stripped of file contents before logging. No analytics endpoint exists in the source.
Install
In any Claude Code session:
/plugin marketplace add CodeShuX/tokenwise
/plugin install tokenwise@tokenwise
Then run /tokenwise:install and follow the guided prompts.
Limitations
- Token counts approximate to ±2% vs Anthropic billing
- A/B test mode costs extra tokens (one task × N tiers) — intentional one-time validation
- Anthropic-only by design (use LiteLLM or OpenRouter for cross-vendor)
- Subagent
model:param has known silent-fail bugs on some Claude Code builds — skill probes for this at install and refuses to configure if routing is broken
Source
- Repo: https://github.com/CodeShuX/tokenwise
- License: MIT
- Author: CodeShuX
常见问题
TokenWise 如何选择合适的模型?
它依据一份预设清单:简单、快速的任务交给 Haiku,需要一定推理的任务交给 Sonnet,而像规划软件架构这类复杂任务则交给 Opus。如果任务比预期复杂,它还能升级为更强的模型。
TokenWise 会把我的数据发送到别处吗?
不会,它完全是私密的。所有费用信息和任务都只保存在你的电脑上,敏感数据也受到保护。
什么是 A/B 测试?
这是一项功能,允许你让不同的 AI 模型同时执行同一个任务。这样你就能看出哪个模型在你的具体用途中质量最好,确保省钱不会影响结果。
详情
作者的原始描述
Measurement-driven model router for Claude Code. Routes Haiku/Sonnet/Opus per task class, logs every routed task with real $ numbers, and A/B tests cheaper tiers before you trust the savings.
热度
- GitHub 星标
- 48k
- 排名
- #6303
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。