Files
knowledge-base/6 - Zettelkasten/20260308213200 Everything Claude Code Token 优化.md
Yaojia Wang 232b045e03 vault: align ECC docs with current repo and add orchestration manual
Updated ECC notes to match the current state of affaan-m/everything-claude-code
docs/token-optimization.md and docs/SKILL-PLACEMENT-POLICY.md:

- Drop CLAUDE_AUTOCOMPACT_PCT_OVERRIDE recommendations (now warned against
  upstream — variable can only lower threshold, opposite of intent)
- Add CLAUDE_CODE_SUBAGENT_MODEL=haiku as the new core token-saving setting
- Flag the default `memory` MCP for disablement (no skill/agent/hook references)
- Add Skill Placement Policy section (curated/learned/imported/evolved + provenance)
- Cover missing commands: /checkpoint, /sessions, /security-scan, /claw, /projects

Add new resource: ECC 编排实战手册.md (721 lines). Six orchestration patterns
(dmux+worktree, sequential claude -p, continuous-claude, Ralphinho RFC-DAG,
santa-loop, Task in-process) with real commands, real plan.json structures,
real CLI flags, and explicit "could not verify online" markers for /multi-*
and /feature-dev. All sourced to specific commands/*.md or skills/*.md files.

Cross-link the new manual from 完整指南 and 用法速查.
2026-04-26 12:17:47 +02:00

2.0 KiB
Raw Blame History

created, type, tags, source
created type tags source
2026-03-08 21:32 zettel
zettel
claude-code
token-optimization
cost
https://github.com/affaan-m/everything-claude-code

Everything Claude Code Token 优化

节省 60%+ 成本的四个策略

1. 模型路由

90% 任务用 SonnetHaiku 做搜索/文档Opus 只用于架构和安全。用 /model-route 自动路由。

子 agent 强制用 Haiku —— 设置 CLAUDE_CODE_SUBAGENT_MODEL=haiku,所有通过 Task 工具派发的子 agent 都跑 Haiku比默认便宜约 80%,文件读取/探索质量基本无损。这是新版的省钱大头。

2. MCP 精简

  • 保持 < 10 个 MCP 启用
  • 用 CLI + skill 替代 MCP wrappergh 替代 GitHub MCP、aws 替代 AWS MCP
  • 默认安装的 memory MCP 没有任何 skill/agent/hook 引用 → 优先关掉
  • 每个 MCP 消耗上下文窗口,多到一定程度 200k 变 70k

3. 工具替换

mgrep 替代 grep/ripgrep在 50 任务 benchmark 中减少约 2x token 使用。

4. 代码模块化

文件保持 200-400 行(最大 800。模块化代码库让 agent 不需要读取大文件,减少上下文消耗,且首次成功率更高。

配置

{
  "model": "sonnet",
  "env": {
    "MAX_THINKING_TOKENS": "10000",
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku"
  }
}

⚠️ 不要再设 CLAUDE_AUTOCOMPACT_PCT_OVERRIDE。仓库 docs/token-optimization.md 已警告:该变量在新版 Claude Code 上只能"降低阈值"(让压缩更早触发),与延后压缩的目的相反。改用手动 /compact + strategic-compact skill 控制压缩时机。

Skill 的渐进式加载

Skill 启动时只读描述(约 100 tokens只在相关时才加载完整内容。这比把所有内容放在 CLAUDE.md 系统提示中高效得多。