optimise-claude
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOptimise Claude
优化Claude
Audit AI skill files for size, structure, and duplication. Every SKILL.md line costs tokens on every invocation — keeping skills lean directly reduces latency and cost.
审核AI技能文件的大小、结构和重复内容。每次调用时,SKILL.md的每一行都会消耗token —— 保持技能精简可以直接降低延迟和成本。
Scope
适用范围
All operations are scoped to the current project root (). Never modify files outside the project repository.
$PWD所有操作的范围均限定在当前项目根目录()。切勿修改项目仓库外的文件。
$PWDWhen to Use
适用场景
- Skill files exceed ~120 lines
- Frontmatter or section order is non-canonical
- Multiple skills contain duplicated content
- An AGENTS.md has inline instruction blocks >30 lines that should be skills
- 技能文件超过约120行
- 前置元数据或章节顺序不符合规范
- 多个技能包含重复内容
- AGENTS.md中存在超过30行的内联指令块,应当封装为技能
Workflow
工作流
Run phases sequentially. Skip any that don't apply.
按顺序执行各阶段,跳过不适用的阶段。
Phase 1 — Inventory & Triage
阶段1 —— 盘点与分类
- List every under
SKILL.md.agents/skills/ - Record: name, line count, has frontmatter (y/n), canonical sections (y/n)
- Flag violations: >120 lines, missing/incorrect frontmatter, wrong section order
- Output a triage table sorted by line count descending
| Skill | Lines | FM | Sections | Violations |
|-------|------:|----|----------|------------|- 列出目录下所有的
.agents/skills/文件SKILL.md - 记录:名称、行数、是否有前置元数据(是/否)、是否符合规范章节结构(是/否)
- 标记违规项:超过120行、前置元数据缺失/错误、章节顺序错误
- 输出按行数降序排序的分类表
| Skill | Lines | FM | Sections | Violations |
|-------|------:|----|----------|------------|Phase 2 — Reduce Token Usage
阶段2 —— 降低Token用量
For each flagged skill:
- Trim prose to imperative bullets
- Collapse verbose examples to minimal code fences
- Remove redundant explanations covered by parent AGENTS.md
- Remove blank lines between list items
- Target ≤120 lines; if still over, split into focused sub-skills
对每个标记的违规技能执行以下操作:
- 将散文式描述精简为祈使句要点
- 将冗长的示例压缩为最简代码块
- 移除父级AGENTS.md中已覆盖的冗余说明
- 移除列表项之间的空行
- 目标为行数≤120行;如果仍超出,拆分为聚焦的子技能
Phase 3 — Fix Structure & Frontmatter
阶段3 —— 修复结构与前置元数据
- Ensure YAML frontmatter has matching directory,
namestarting with "Use when"description - Enforce section order: H1 title → When to Use → Rules/Instructions → Quick Reference → Validation
- Remove empty or placeholder sections
- Use imperative voice throughout
- 确保YAML前置元数据中的与目录名称匹配,
name以"Use when"开头description - 强制章节顺序:H1标题 → 适用场景 → 规则/指令 → 快速参考 → 验证
- 移除空章节或占位章节
- 全程使用祈使语气
Phase 4 — Cross-Skill Deduplication
阶段4 —— 跨技能去重
- Identify repeated content blocks across skills (>5 similar lines)
- Move shared content to root or a shared skill
AGENTS.md - Replace duplicates with a one-line pointer: "See for …"
<skill-name> - Reword overlapping fields so each skill has a unique trigger
description
- 识别不同技能间的重复内容块(超过5行相似内容)
- 将共享内容移动到根目录的或共享技能中
AGENTS.md - 用单行引用替换重复内容:"See for …"
<skill-name> - 重写存在重叠的字段,确保每个技能有唯一的触发条件
description
Phase 5 — Extract Bloated AGENTS.md Blocks
阶段5 —— 提取AGENTS.md中的臃肿块
- Scan for inline instruction blocks >30 lines
AGENTS.md - Create a new skill at
.agents/skills/<name>/SKILL.md - Replace the original block with a slim pointer + Quick Reference
- If a skill sync script exists, run it
- 扫描中超过30行的内联指令块
AGENTS.md - 在路径下创建新技能
.agents/skills/<name>/SKILL.md - 用精简引用+快速参考替换原有的臃肿块
- 如果存在技能同步脚本,运行该脚本
Output Format
输出格式
undefinedundefinedOptimisation Report
Optimisation Report
| Skill | Before | After | Delta |
|---|---|---|---|
| ... | 250 | 110 | -140 |
Total skills: N
Total lines saved: N
New skills created: N
undefined| Skill | Before | After | Delta |
|---|---|---|---|
| ... | 250 | 110 | -140 |
Total skills: N
Total lines saved: N
New skills created: N
undefinedValidation
验证
- — no file exceeds 120 lines
wc -l .agents/skills/*/SKILL.md - Every has valid YAML frontmatter with
SKILL.mdandnamedescription - No two skills share >5 identical lines
- No has inline instruction blocks >30 lines without a skill pointer
AGENTS.md
- —— 无文件超过120行
wc -l .agents/skills/*/SKILL.md - 每个都包含有效的YAML前置元数据,且带有
SKILL.md和name字段description - 任意两个技能的相同内容不超过5行
- 中不存在超过30行且未关联技能引用的内联指令块
AGENTS.md