token-coach
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseToken Coach: Plan Token-Efficient Before You Build
Token Coach:在构建前规划Token高效方案
Interactive coaching for Claude Code architecture decisions. Analyzes your setup, identifies patterns (good and bad), and gives personalized advice with real numbers.
Use when: Building something new, existing setup feels slow, designing multi-agent systems, or want a quick health check.
针对Claude Code架构决策的交互式指导工具。分析你的配置,识别优劣模式,并结合真实数据给出个性化建议。
适用场景:构建新项目、现有配置运行缓慢、设计多Agent系统,或需要快速进行健康检查时。
Phase 0: Initialize
阶段0:初始化
- Resolve measure.py path (same as token-optimizer):
bash
MEASURE_PY=""
if [ -f "$HOME/.claude/skills/token-optimizer/scripts/measure.py" ]; then
MEASURE_PY="$HOME/.claude/skills/token-optimizer/scripts/measure.py"
else
MEASURE_PY="$(find "$HOME/.claude/plugins/cache" -path "*/token-optimizer/scripts/measure.py" 2>/dev/null | head -1)"
fi
[ -z "$MEASURE_PY" ] || [ ! -f "$MEASURE_PY" ] && { echo "[Error] measure.py not found. Is Token Optimizer installed?"; exit 1; }- Collect coaching data:
bash
python3 $MEASURE_PY coach --jsonParse the JSON output. This gives you: snapshot (current measurements), detected patterns, coaching questions, and focus suggestions.
- Check context quality (v2.0):
bash
python3 $MEASURE_PY quality current --json 2>/dev/nullIf available, parse the quality score and issues. This enriches coaching with session-level insights (not just setup overhead). If the command fails (pre-v2.0 install), skip gracefully.
- 解析measure.py路径(与token-optimizer路径一致):
bash
MEASURE_PY=""
if [ -f "$HOME/.claude/skills/token-optimizer/scripts/measure.py" ]; then
MEASURE_PY="$HOME/.claude/skills/token-optimizer/scripts/measure.py"
else
MEASURE_PY="$(find "$HOME/.claude/plugins/cache" -path "*/token-optimizer/scripts/measure.py" 2>/dev/null | head -1)"
fi
[ -z "$MEASURE_PY" ] || [ ! -f "$MEASURE_PY" ] && { echo "[Error] measure.py not found. Is Token Optimizer installed?"; exit 1; }- 收集指导数据:
bash
python3 $MEASURE_PY coach --json解析JSON输出。你将获得:快照(当前测量数据)、检测到的模式、指导问题及重点建议。
- 检查上下文质量(v2.0版本):
bash
python3 $MEASURE_PY quality current --json 2>/dev/null如果可用,解析质量分数和问题。这会为指导增加会话级别的洞察(不仅是配置开销)。如果命令执行失败(安装版本低于v2.0),请优雅跳过。
Phase 1: Intake
阶段1:需求收集
Ask ONE question:
What's your goal today? a) Building something new, want it token-efficient from the start b) Existing project feels sluggish / context fills too fast c) Designing a multi-agent system, want architecture advice d) Quick health check with actionable tips
Wait for the answer. Don't dump info before they choose.
提出一个问题:
你今天的目标是什么? a) 构建新项目,希望从一开始就实现Token高效 b) 现有项目运行缓慢 / 上下文填充过快 c) 设计多Agent系统,需要架构建议 d) 快速健康检查并获取可操作建议
等待用户回答。在用户选择前不要输出大量信息。
Phase 2: Load Context (based on intake)
阶段2:加载上下文(基于需求收集结果)
Resolve the token-coach skill directory:
bash
COACH_DIR=""
if [ -d "$HOME/.claude/skills/token-coach" ]; then
COACH_DIR="$HOME/.claude/skills/token-coach"
elif [ -d "$HOME/.claude/skills/token-optimizer/../token-coach" ]; then
COACH_DIR="$HOME/.claude/skills/token-optimizer/../token-coach"
else
COACH_DIR="$(find "$HOME/.claude/plugins/cache" -path "*/token-coach" -type d 2>/dev/null | head -1)"
fiLoad references based on intake choice:
- Option a or b: Read +
$COACH_DIR/references/coach-patterns.md$COACH_DIR/references/quick-reference.md - Option c: Read +
$COACH_DIR/references/agentic-systems.md$COACH_DIR/references/quick-reference.md - Option d: Read only (fast path)
$COACH_DIR/references/quick-reference.md
Read the matching example from as a few-shot template:
$COACH_DIR/examples/- Option a:
coaching-session-new-project.md - Option b:
coaching-session-heavy-setup.md - Option c:
coaching-session-agentic.md - Option d: Skip example (keep it fast)
Read for conversation structure.
$COACH_DIR/references/coaching-scripts.md解析token-coach技能目录:
bash
COACH_DIR=""
if [ -d "$HOME/.claude/skills/token-coach" ]; then
COACH_DIR="$HOME/.claude/skills/token-coach"
elif [ -d "$HOME/.claude/skills/token-optimizer/../token-coach" ]; then
COACH_DIR="$HOME/.claude/skills/token-optimizer/../token-coach"
else
COACH_DIR="$(find "$HOME/.claude/plugins/cache" -path "*/token-coach" -type d 2>/dev/null | head -1)"
fi根据用户选择加载参考资料:
- 选项a或b:读取+
$COACH_DIR/references/coach-patterns.md$COACH_DIR/references/quick-reference.md - 选项c:读取+
$COACH_DIR/references/agentic-systems.md$COACH_DIR/references/quick-reference.md - 选项d:仅读取(快速路径)
$COACH_DIR/references/quick-reference.md
从中读取匹配的示例作为少样本模板:
$COACH_DIR/examples/- 选项a:
coaching-session-new-project.md - 选项b:
coaching-session-heavy-setup.md - 选项c:
coaching-session-agentic.md - 选项d:跳过示例(保持快速)
读取以获取对话结构。
$COACH_DIR/references/coaching-scripts.mdPhase 3: Coach (conversation, not report)
阶段3:指导(对话形式,而非报告)
This is a CONVERSATION. Not a wall of text.
- Lead with the 1-2 most impactful findings from the coaching data
- If quality data is available and score < 70, lead with that instead: "Your current session quality is [X]/100. [Top issue] is eating [Y tokens]."
- Reference their actual numbers ("You have 47 skills costing ~4,700 tokens at startup")
- Ask a follow-up question. Don't dump everything at once.
- For agentic systems (option c): walk through their architecture step by step
- Use the coaching scripts for structure, but keep it natural
Tone: Knowledgeable friend, not corporate consultant. Be direct about what matters and why. Use real numbers from their data.
Anti-patterns to call out: Reference the anti-patterns from coach-patterns.md. Name them ("You've got the 50-Skill Trap going on").
Continue the conversation for 2-4 exchanges. Let the user ask questions. Adjust advice based on what they tell you about their workflow.
这是一场对话,不是长篇大论。
- 先从指导数据中提出1-2个最具影响力的发现
- 如果质量数据可用且分数低于70,则优先说明:"你当前的会话质量为[X]/100。[首要问题]消耗了[Y]个Token。"
- 引用真实数据("你有47个技能,启动时约消耗4700个Token")
- 提出后续问题。不要一次性输出所有内容。
- 对于Agent系统(选项c):逐步梳理其架构
- 参考指导脚本的结构,但保持对话自然
语气:像知识渊博的朋友,而非企业顾问。直接说明关键问题及其原因。使用数据中的真实数字。
需要指出的反模式:参考coach-patterns.md中的反模式,直接点名("你陷入了50技能陷阱")。
持续对话2-4轮。允许用户提问。根据用户告知的工作流程调整建议。
Phase 4: Action Plan
阶段4:行动计划
After the conversation, generate a prioritized action plan:
- Summarize 3-5 concrete actions, ordered by impact
- Include estimated token savings for each action (use the numbers from quick-reference.md)
- If quality score < 70: include "Set up Smart Compaction" as a recommended action ()
python3 $MEASURE_PY setup-smart-compact - If quality score < 50: recommend immediate or
/compactbefore continuing/clear - Flag which actions are quick wins vs deeper changes
- Offer to run for the full audit + implementation if they want to go beyond coaching
/token-optimizer
Format: Keep it scannable. Numbered list with bold action names, one-line description, estimated savings.
对话结束后,生成优先级明确的行动计划:
- 总结3-5项具体行动,按影响力排序
- 包含每项行动的预估Token节省量(参考quick-reference.md中的数据)
- 如果质量分数低于70:将"设置智能压缩"列为推荐行动()
python3 $MEASURE_PY setup-smart-compact - 如果质量分数低于50:建议立即执行或
/compact后再继续/clear - 标记哪些行动是快速见效的,哪些是深度改进
- 如果用户希望超越指导范围,提供运行进行完整审计和实施的选项
/token-optimizer
格式:保持易读性。使用编号列表,包含加粗的行动名称、一行描述和预估节省量。
Phase 5: Dashboard (optional)
阶段5:仪表板(可选)
If measure.py generated a coach dashboard tab, mention it:
"Your Token Health Score and pattern analysis are in the dashboard. Run to see it."
python3 $MEASURE_PY dashboard如果measure.py生成了指导仪表板标签页,请告知用户:
"你的Token健康分数和模式分析已在仪表板中。运行即可查看。"
python3 $MEASURE_PY dashboard