token-efficiency by delphine-l/claude_global
npx skills add https://github.com/delphine-l/claude_global --skill token-efficiency此技能为所有项目提供令牌优化策略,以实现经济高效的 Claude Code 使用。这些指南有助于在保持高质量协助的同时,最大限度地减少令牌消耗。
除非用户明确要求详细输出或完整文件内容,否则默认情况下始终遵循这些优化指南。
默认假设:用户偏好高效、经济实惠的协助。
为任务选择合适的模型以优化成本和性能:
在以下情况使用 Opus:
在以下情况使用 Sonnet(默认):
典型会话模式:
节省:与全程使用 Opus 相比,令牌成本降低约 50%。
误区: 在 .claude/skills/ 中拥有许多技能会增加令牌使用量。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
现实: 技能使用渐进式披露 - Claude 在会话开始时仅看到技能描述(4 个技能约 155 个令牌)。完整技能内容仅在激活时加载。
将多个技能符号链接到项目是安全的。 令牌浪费源于不必要地读取大文件,而非拥有可用的技能。
默认使用 --quiet、-q、--silent 标志。仅在用户明确要求时使用详细模式。
读取前始终进行过滤:tail -100、grep -i "error"、特定时间范围。
在读取大文件之前,先检查 git status --short、package.json、requirements.txt。
使用 Grep 工具搜索特定内容,而不是读取整个文件。
使用偏移量和限制参数。首先使用 wc -l 检查文件大小。
关键优化。 读取文件消耗令牌。Bash 命令不消耗。
| 操作 | 浪费方式 | 高效方式 |
|---|---|---|
| 复制文件 | 读取 + 写入 | cp source dest |
| 替换文本 | 读取 + 编辑 | sed -i '' 's/old/new/g' file |
| 追加 | 读取 + 写入 | echo "text" >> file |
| 删除行 | 读取 + 写入 | sed -i '' '/pattern/d' file |
| 合并文件 | 读取 + 读取 + 写入 | cat file1 file2 > combined |
| 统计行数 | 读取文件 | wc -l file |
| 检查内容 | 读取文件 | grep -q "term" file |
何时打破此规则: 复杂逻辑、需要代码感知的更改、需要验证、交互式审查。详情请参阅 strategies.md。
限制范围:head -50、find . -maxdepth 2、tree -L 2。
提供目录内容、代码结构、命令输出的结构化摘要。
head -100、tail -50,使用 head -500 | tail -100 从中间取样。
提取特定字段:jq '.metadata'、jq 'keys'。对于 CSV:head -20、wc -l。
首先获取概览(使用 find、grep 查找类/函数),仅读取结构,搜索特定代码,仅读取相关部分。
使用任务/探索子代理进行广泛的代码库探索。与直接的多文件探索相比,可节省 70-80% 的令牌。
并行批量处理 3-5 个相关搜索。立即保存结果。记录“未找到”的项目。
有关详细策略、bash 模式和大量示例,请参阅 strategies.md。
问自己:
在以下情况下覆盖效率规则:
在学习模式下:
对于情况 1-3,向用户解释令牌成本,并首先提供过滤视图。
模型选择(第一优先级):
在任何文件操作之前,问自己:
| 方法 | 令牌/周 | 备注 |
|---|---|---|
| 浪费(读取/编辑/写入所有内容) | 500K | 不必要地读取文件 |
| 中等(仅过滤读取) | 200K | 使用 grep/head/tail |
| 高效(bash 命令 + 过滤器) | 30-50K | 使用 cp/sed/awk 代替读取 |
应用这些规则平均可降低成本 90-95%。
此技能在以下情况下自动应用这些优化:
您始终可以通过以下方式覆盖:
| 文件 | 内容 | 何时加载 |
|---|---|---|
| strategies.md | 详细的 bash 命令策略、文件操作模式、sed/awk 示例、Jupyter notebook 操作、安全的 glob 模式、macOS/Linux 兼容性 | 在实施特定文件操作或需要详细 bash 模式时 |
| learning-mode.md | 战略性文件选择、有针对性的模式学习工作流、广泛的仓库探索策略、仓库类型识别 | 在进入学习模式或探索新代码库时 |
| examples.md | 包含前后对比的大量令牌节省示例、有针对性的学习示例(Galaxy 包装器、API 模式)、成本计算 | 在演示令牌节省或从示例中学习时 |
| project-patterns.md | 分析文件组织、使用 TodoWrite 进行任务管理、后台进程管理、仓库组织、MANIFEST 系统、高效文件操作 | 在组织项目、管理长时间运行的任务或设置导航模式时 |
核心座右铭:正确的模型。正确的工具。先过滤。选择性阅读。智能总结。
模型选择(影响最大):
工具选择(主要优化):
次要规则:
遵循这些指南,用户可以在保持高质量协助的同时,从 Claude 订阅中获得 5-10 倍的价值。
每周安装数
603
仓库
GitHub 星标数
10
首次出现
Jan 24, 2026
安全审计
安装于
opencode521
codex515
gemini-cli505
github-copilot484
cursor465
kimi-cli465
This skill provides token optimization strategies for cost-effective Claude Code usage across all projects. These guidelines help minimize token consumption while maintaining high-quality assistance.
ALWAYS follow these optimization guidelines by default unless the user explicitly requests verbose output or full file contents.
Default assumption: Users prefer efficient, cost-effective assistance.
Use the right model for the task to optimize cost and performance:
Use Opus when:
Use Sonnet (default) for:
Typical session pattern:
Savings: ~50% token cost vs all-Opus usage.
Myth: Having many skills in .claude/skills/ increases token usage.
Reality: Skills use progressive disclosure - Claude sees only skill descriptions at session start (~155 tokens for 4 skills). Full skill content loaded only when activated.
It's safe to symlink multiple skills to a project. Token waste comes from reading large files unnecessarily, not from having skills available.
Use --quiet, -q, --silent flags by default. Only use verbose when user explicitly asks.
Always filter before reading: tail -100, grep -i "error", specific time ranges.
Check git status --short, package.json, requirements.txt before reading large files.
Search for specific content with Grep tool instead of reading entire files.
Use offset and limit parameters. Check file size with wc -l first.
CRITICAL OPTIMIZATION. Reading files costs tokens. Bash commands don't.
| Operation | Wasteful | Efficient |
|---|---|---|
| Copy file | Read + Write | cp source dest |
| Replace text | Read + Edit | sed -i '' 's/old/new/g' file |
| Append | Read + Write | echo "text" >> file |
| Delete lines | Read + Write | sed -i '' '/pattern/d' file |
| Merge files | Read + Read + Write | cat file1 file2 > combined |
When to break this rule: Complex logic, code-aware changes, validation needed, interactive review. For details, see strategies.md.
Limit scope: head -50, find . -maxdepth 2, tree -L 2.
Provide structured summaries of directory contents, code structure, command output.
head -100, tail -50, sample from middle with head -500 | tail -100.
Extract specific fields: jq '.metadata', jq 'keys'. For CSV: head -20, wc -l.
Get overview first (find, grep for classes/functions), read structure only, search for specific code, read only relevant sections.
Use Task/Explore subagent for broad codebase exploration. Saves 70-80% tokens vs direct multi-file exploration.
Batch 3-5 related searches in parallel. Save results immediately. Document "not found" items.
For detailed strategies, bash patterns, and extensive examples, see strategies.md.
Ask yourself:
Override efficiency rules when:
In learning mode:
In cases 1-3, explain token cost to user and offer filtered view first.
Model Selection (First Priority):
Before ANY file operation, ask yourself:
| Approach | Tokens/Week | Notes |
|---|---|---|
| Wasteful (Read/Edit/Write everything) | 500K | Reading files unnecessarily |
| Moderate (filtered reads only) | 200K | Grep/head/tail usage |
| Efficient (bash commands + filters) | 30-50K | Using cp/sed/awk instead of Read |
Applying these rules reduces costs by 90-95% on average.
This skill automatically applies these optimizations when:
You can always override by saying:
| File | Content | When to load |
|---|---|---|
| strategies.md | Detailed bash command strategies, file operation patterns, sed/awk examples, Jupyter notebook manipulation, safe glob patterns, macOS/Linux compatibility | When implementing specific file operations or need detailed bash patterns |
| learning-mode.md | Strategic file selection, targeted pattern learning workflows, broad repository exploration strategies, repository type identification | When entering learning mode or exploring a new codebase |
| examples.md | Extensive token savings examples with before/after comparisons, targeted learning examples (Galaxy wrappers, API patterns), cost calculations | When demonstrating token savings or learning from examples |
| project-patterns.md | Analysis file organization, task management with TodoWrite, background process management, repository organization, MANIFEST system, efficient file operations | When organizing projects, managing long-running tasks, or setting up navigation patterns |
Core motto: Right model. Right tool. Filter first. Read selectively. Summarize intelligently.
Model selection (highest impact):
Tool selection (primary optimization):
Secondary rules:
By following these guidelines, users can get 5-10x more value from their Claude subscription while maintaining high-quality assistance.
Weekly Installs
603
Repository
GitHub Stars
10
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode521
codex515
gemini-cli505
github-copilot484
cursor465
kimi-cli465
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
103,800 周安装
| Count lines | Read file | wc -l file |
| Check content | Read file | grep -q "term" file |