optimise-claude

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Optimise 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 (
$PWD
). Never modify files outside the project repository.
所有操作的范围均限定在当前项目根目录(
$PWD
)。切勿修改项目仓库外的文件。

When 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 —— 盘点与分类

  1. List every
    SKILL.md
    under
    .agents/skills/
  2. Record: name, line count, has frontmatter (y/n), canonical sections (y/n)
  3. Flag violations: >120 lines, missing/incorrect frontmatter, wrong section order
  4. Output a triage table sorted by line count descending
| Skill | Lines | FM | Sections | Violations |
|-------|------:|----|----------|------------|
  1. 列出
    .agents/skills/
    目录下所有的
    SKILL.md
    文件
  2. 记录:名称、行数、是否有前置元数据(是/否)、是否符合规范章节结构(是/否)
  3. 标记违规项:超过120行、前置元数据缺失/错误、章节顺序错误
  4. 输出按行数降序排序的分类表
| 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
    name
    matching directory,
    description
    starting with "Use when"
  • Enforce section order: H1 title → When to Use → Rules/Instructions → Quick Reference → Validation
  • Remove empty or placeholder sections
  • Use imperative voice throughout
  • 确保YAML前置元数据中的
    name
    与目录名称匹配,
    description
    以"Use when"开头
  • 强制章节顺序:H1标题 → 适用场景 → 规则/指令 → 快速参考 → 验证
  • 移除空章节或占位章节
  • 全程使用祈使语气

Phase 4 — Cross-Skill Deduplication

阶段4 —— 跨技能去重

  1. Identify repeated content blocks across skills (>5 similar lines)
  2. Move shared content to root
    AGENTS.md
    or a shared skill
  3. Replace duplicates with a one-line pointer: "See
    <skill-name>
    for …"
  4. Reword overlapping
    description
    fields so each skill has a unique trigger
  1. 识别不同技能间的重复内容块(超过5行相似内容)
  2. 将共享内容移动到根目录的
    AGENTS.md
    或共享技能中
  3. 用单行引用替换重复内容:"See
    <skill-name>
    for …"
  4. 重写存在重叠的
    description
    字段,确保每个技能有唯一的触发条件

Phase 5 — Extract Bloated AGENTS.md Blocks

阶段5 —— 提取AGENTS.md中的臃肿块

  1. Scan
    AGENTS.md
    for inline instruction blocks >30 lines
  2. Create a new skill at
    .agents/skills/<name>/SKILL.md
  3. Replace the original block with a slim pointer + Quick Reference
  4. If a skill sync script exists, run it
  1. 扫描
    AGENTS.md
    中超过30行的内联指令块
  2. .agents/skills/<name>/SKILL.md
    路径下创建新技能
  3. 用精简引用+快速参考替换原有的臃肿块
  4. 如果存在技能同步脚本,运行该脚本

Output Format

输出格式

undefined
undefined

Optimisation Report

Optimisation Report

SkillBeforeAfterDelta
...250110-140
Total skills: N Total lines saved: N New skills created: N
undefined
SkillBeforeAfterDelta
...250110-140
Total skills: N Total lines saved: N New skills created: N
undefined

Validation

验证

  • wc -l .agents/skills/*/SKILL.md
    — no file exceeds 120 lines
  • Every
    SKILL.md
    has valid YAML frontmatter with
    name
    and
    description
  • No two skills share >5 identical lines
  • No
    AGENTS.md
    has inline instruction blocks >30 lines without a skill pointer
  • wc -l .agents/skills/*/SKILL.md
    —— 无文件超过120行
  • 每个
    SKILL.md
    都包含有效的YAML前置元数据,且带有
    name
    description
    字段
  • 任意两个技能的相同内容不超过5行
  • AGENTS.md
    中不存在超过30行且未关联技能引用的内联指令块