Token导航 LogoToken导航

Agent Skill · 研究检索

token-optimizer(令牌优化器)

token-optimizer 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

token-optimizer 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 38,602。

总安装 1,536周安装 66GitHub Stars 4下载 539核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:token-optimizer(令牌优化器)
来源仓库:https://github.com/alexismunoz1/token-optimizer
仓库路径:skills/token-optimizer
安装命令:
npx skills add https://github.com/alexismunoz1/token-optimizer --skill token-optimizer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/alexismunoz1/token-optimizer --skill token-optimizer

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于降低 AI 调用成本与优化提示词架构,提供批量 API 与缓存机制的实际应用建议。适合在 Codex、Claude、Cursor、Gemini CLI 用户及直接调用 Anthropic API 的开发者中使用。使用时需区分 Claude Code 场景与其他 API 调用方式,选择对应的优化章节进行操作。

安装方式:通过 npx skills add 命令从指定 GitHub 仓库添加,支持跨平台部署。推荐结合实验数据与当前定价模型制定节省策略,重点关注 prompt caching 等高回报项。

来源仓库内路径:skills/token-optimizer

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/alexismunoz1/token-optimizer --skill token-opt…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

token-optimizer 怎么安装?

在终端执行 npx skills add https://github.com/alexismunoz1/token-optimizer --skill token-optimizer。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

token-optimizer 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

token-optimizer 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

token-optimizer 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

token-optimizer 用的人多吗?

公开数据是累计安装 1,536 次,近一周安装 66 次,下载 539 次,GitHub 4 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

token-optimizer 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
token-optimizer

令牌优化器 · 本页

1,5364调用外部服务未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Token Optimizer

A comprehensive toolkit to reduce token consumption and lower AI costs — for both Claude Code users (file organization, CLAUDE.md, context hygiene) and API developers (prompt caching, Batch API, effort tuning, prompt architecture). Recommendations are backed by real experiment data and current Anthropic pricing.

Which sections apply to you:

  • Using Claude Code? → Sections 1-5 and the Quick Wins Checklist.
  • Calling the Anthropic API directly? → Also read references/api-optimization-guide.md. That's where the biggest savings live (prompt caching = 90% off, Batch API = 50% off, stackable).

Installation

npx skills add amunozdev/token-optimizer

Or manually:

cp -r token-optimizer ~/.claude/skills/

Core Features

1. File Organization Optimization

The single highest-impact optimization. Small, focused files reduce token consumption by 18.2% and noise by 92% on focused tasks (the majority of daily development work).

Core rules:

  • Maximum 150 lines per file — split by responsibility if longer
  • Single responsibility — one concern per file
  • Descriptive names in kebab-case — the filename tells the AI exactly what's inside

Real example: Fixing an email validation bug required reading 814 lines in a monolithic file (49,466 tokens) vs only 67 lines in a modular setup (40,447 tokens) — 18.2% savings, 92% less noise.

For naming conventions, avoid/prefer tables, and project structure templates, see references/file-organization-guide.md

2. CLAUDE.md Optimization

A well-structured CLAUDE.md can reduce token consumption by 50-70%. Most projects have bloated CLAUDE.md files that load unnecessary context on every interaction.

Key principles:

  • Keep it under 500 lines — essentials only
  • Be specific — "PostgreSQL with Prisma" not just "database"
  • Include project structure and commands — save the AI from guessing
  • Use triggers, not full docs — reference skills/files for details, don't inline everything
For a ready-to-use optimized template, see references/claude-md-template.md

3. Context Management

Token waste often comes from accumulated irrelevant context, not from individual operations.

Essential commands:

CommandWhen to UseEffect
/clearSwitching tasks, after major correctionsResets context completely
/compactLong conversation (>50 exchanges)Compresses history, keeps essentials
/contextDiagnosing high token useShows what's consuming tokens

Lazy loading: Don't front-load all information. One project achieved 54% reduction in initial tokens (7,584 → 3,434) by keeping only triggers in CLAUDE.md and loading details on demand.

For advanced strategies, subagent patterns, and MCP management, see references/context-management-guide.md

4. Strategic Model Selection

Choosing the right model per task type is one of the easiest cost savings to implement.

Task TypeModelWhy
80% of daily tasksSonnetBest cost/performance ratio
Complex architectureOpusDeeper reasoning needed
Simple/quick tasksHaikuUp to 18x cheaper than Opus

Default to Sonnet. Escalate to Opus only for genuinely complex problems. Use Haiku for simple tasks, tests, and searches.

5. MCP & Subagent Optimization

MCP Management:

  • Keep maximum 10 active MCPs at a time (max 80 total tools)
  • Disable MCPs not needed for the current task
  • Each unused MCP still costs tokens in tool descriptions

Subagents for verbose tasks: Use the Task tool for operations that generate large output (test runs, builds, searches). The verbose output stays in the subagent's context — only the summary returns to your main conversation.

6. Prompt Architecture (Claude Code and API)

How you write prompts has a direct, measurable impact on tokens — in both directions.

  • Be direct, put the ask first, say it once. Repetition doesn't increase compliance, it just bills.
  • Constrain output explicitly. "Under 50 words", "max 3 bullets", "JSON with keys X, Y, Z, no explanation." Open-ended prompts produce open-ended (expensive) responses.
  • Use XML tags (<instructions>, <context>, <output_format>) to reduce ambiguity.
  • Include only relevant context. Don't paste 500 lines when one function is enough.

7. API-Only Optimizations

If you're calling the Anthropic API directly (SDK, custom agents, production apps), these are the highest-impact levers — most are absent when using Claude Code because the harness handles them for you.

TechniqueSavingsNotes
Prompt caching90% on cached readsCache writes cost 1.25x, reads 0.1x. Pays for itself on 2nd call.
Batch API50% on all tokens<24h latency. Stacks with caching → up to 95% total.
effort: lowLarge reductionSkip deep reasoning for classification/extraction.
budget_tokens capProportional8K-16K is plenty for most tasks. Don't use 100K to format a date.
Prefill assistant turnRemoves preamble{"role": "assistant", "content": "{"} skips "Sure! Here's…".
Token-efficient tools~14% output avgDefault in Claude 4. Add token-efficient-tools-2025-02-19 header for 3.7.
Dynamic tool loadingScales with tool countEvery tool schema ships in every request. Only include what the task needs.
Token counting endpointDebuggingGet exact cost before running inference.

Critical cache gotchas:

  • Images break the cache. Adding or removing an image anywhere in the prompt invalidates it. If your flow sometimes sends images, treat it as a separate request pattern.
  • Anything before the cache breakpoint must be stable. Timestamps, session IDs, or the user message placed before the breakpoint defeat caching entirely — you pay the 1.25x write surcharge every time with zero reads.
  • Concurrency pitfall. Cache entries become available only after the first response starts streaming. Fire-and-forget 10 parallel requests → 9 cache misses. Fire one, wait for stream to start, then fan out.
  • Mind the minimum token threshold per breakpoint (2,048 for Sonnet 4.6; 4,096 for Opus 4.6 and Haiku 4.5). Below it, nothing caches and no error is raised. Verify cache_creation_input_tokens in the response.
Full details, pricing math, TTL tradeoffs, and a setup checklist: references/api-optimization-guide.md

Quick Wins Checklist

Apply these in order of impact:

  1. Run /context first → establishes your baseline before any changes
  2. Split large files (>150 lines) into focused modules → saves 18%+ tokens
  3. Optimize your CLAUDE.md → can reduce consumption 50-70%
  4. Use /clear between tasks → eliminates irrelevant context
  5. Use /compact in long conversations → compresses history
  6. Use subagents for verbose tasks → test output, build logs, and search results stay in subagent context instead of polluting your main conversation
  7. Use the right model → default to Sonnet for daily work, Haiku for simple tasks (18x cheaper than Opus), Opus only for genuinely complex architecture decisions
  8. Limit active MCPs to ≤10 → each unused MCP still costs tokens every turn because its tool descriptions are sent in every request
  9. Track cost with /cost → use it to see spend per session; configure the statusline to display it continuously
  10. API users: enable prompt caching → cache_control on system prompt and tools = 90% off on repeated input; see references/api-optimization-guide.md

Expected Savings

Results from our controlled experiment with an 814-line TypeScript e-commerce app:

OptimizationImpact
Modular files (focused tasks)-18.2% tokens
Noise reduction (lines processed)-92%
Optimized CLAUDE.md-50-70% consumption
Lazy loading context-54% initial tokens
Haiku vs Opus (simple tasks)-94% cost

Key insight: Focused tasks (bug fixes, specific changes — ~80% of daily work) benefit enormously from modular code. Cross-cutting tasks show minimal difference at small scale (+1-5%) but modular wins decisively at 5,000+ lines.

Note on scale: These results are from a controlled experiment with an 814-line codebase. At larger scales (5,000+ lines), the savings from modular architecture are even more significant because monolithic files start hitting context window limits while modular files maintain constant size (35-146 lines each).

For the complete experiment methodology and raw data, see references/metrics-report.md

Diagnostic Workflow

When activated, follow this process:

  1. Measure first: Always start by asking the user to run /context. Without a baseline number, you can't prove any optimization worked. This step is not optional.
  2. Read the user's code: Before recommending anything, look at their actual files and project structure. Scan for files >150 lines, check their CLAUDE.md size, and count active MCPs. Recommendations grounded in their real codebase are far more useful than generic advice.
  3. Identify: Determine the biggest source of waste (large files, bloated CLAUDE.md, accumulated context, too many MCPs)
  4. Recommend: Suggest the highest-impact optimization from the Quick Wins Checklist
  5. Verify: After changes, have the user re-run /context to measure improvement

Important guidelines:

  • Always diagnose first — don't dump all optimizations
  • Measure before and after — every optimization should be verified with /context
  • Focus on the user's specific problem — identify the most impactful change first
  • Be transparent about trade-offs — modular files save 18%+ on focused tasks but show minimal difference on cross-cutting tasks at small scale

Usage Examples

"My Claude Code sessions are getting expensive"

  1. Run /context to see current token consumption breakdown
  2. Audit CLAUDE.md size — if over 500 lines, trim to essentials
  3. Check for files >150 lines — identify candidates for splitting
  4. Count active MCPs — disable unused ones
  5. Review model usage — switch routine tasks to Sonnet/Haiku

"Organize my codebase for AI"

  1. Scan the project for files exceeding 150 lines
  2. Identify generic filenames (utils.ts, helpers.ts, index.ts with logic)
  3. Propose file splits by responsibility with new descriptive names
  4. Suggest a project structure following the organization guide

"My context window keeps filling up"

  1. Run /context to identify what's consuming tokens
  2. Check if CLAUDE.md has inline documentation that should be referenced instead
  3. Recommend /clear between tasks and /compact for long sessions
  4. Suggest moving verbose content to referenced files (lazy loading)

Troubleshooting

ProblemCauseSolution
No improvement after optimizationsNo baseline measurement takenRun /context before AND after each change
Don't know how many tokens I'm usingToken consumption not visible by defaultUse /context to see the full breakdown
/compact doesn't reduce enoughCompresses but keeps essentialsUse /clear if prior context is irrelevant
Cross-cutting tasks slower after splittingMultiple reads needed (1-5% more tokens)Expected and marginal — focused tasks (80% of work) still save 18%+
API: cache seems not to work, writes every callContent before breakpoint changes every request (timestamp, session ID, user msg) OR below minimum tokens OR image added/removedCheck cache_creation_input_tokens — move volatile content after the breakpoint and meet per-model minimums
API: parallel requests all miss cacheCache entry only exists after first response streamsFire first request, wait for stream to start, then fan out the rest
API: thinking tokens making requests expensiveDefault budget_tokens can be tens of thousandsCap budget_tokens at 8K-16K, or set effort: low, or disable thinking for formatting/lookup tasks

Reference Materials

  • references/file-organization-guide.md — Naming conventions, project structure templates, and implementation checklist
  • references/context-management-guide.md — Lazy loading, subagents, MCP management, and model selection strategies
  • references/metrics-report.md — Complete experiment data and methodology with raw numbers
  • references/claude-md-template.md — Ready-to-use optimized CLAUDE.md template
  • references/api-optimization-guide.md — Prompt caching, Batch API, effort/thinking budget, prefill, token-efficient tools, and monitoring for direct API users

平台分布

Codex

32.81%
按下载量换算177

Claude

31.17%
按下载量换算168

Cursor

18.38%
按下载量换算99

Gemini CLI

9.6%
按下载量换算52

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills