Optimise Claude
Use this skill when auditing AI skill files for size, structure, duplication, or bloated AGENTS.md inline blocks.
Scope
All operations are strictly limited to project-level skill directories:
.agents/skills/ (relative to project root)
.claude/skills/ (relative to project root)
NEVER touch user-level (home directory) skill locations:
~/.agents/skills/
~/.claude/skills/
Never read, write, list, or modify any file outside the current project root ($PWD).
When to Use
- Skill files exceed ~120 lines.
- Frontmatter or section order is non-canonical.
- Multiple skills contain duplicated content.
- An AGENTS.md file has inline instruction blocks >30 lines that should be skills.
Workflow
Run phases sequentially. Skip any phase that does not apply. Only operate on files within the current project repo.
Phase 1 — Inventory & Triage
- List every
SKILL.md under the project's .agents/skills/.
- For each file, record: name, line count, has frontmatter (y/n), has 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 |
|-------|------:|----|----------|------------|
Phase 2 — Reduce Token Usage
For each flagged skill:
- Trim prose to imperative bullets.
- Collapse verbose examples to minimal code fences.
- Remove redundant explanations already covered by parent AGENTS.md.
- Remove blank lines between list items.
- Target <=120 lines. If still over, split into focused sub-skills.
Phase 3 — Fix Structure & Frontmatter
For each skill:
- Ensure YAML frontmatter has
name matching directory and description starting with "Use when".
- Enforce canonical section order: H1 title, scope line, When to Use, Rules/Instructions, Quick Reference, Validation.
- Remove empty or placeholder sections.
- Use imperative voice throughout.
Phase 4 — Cross-Skill Deduplication
- Identify repeated content blocks across project skills (>5 similar lines).
- Move shared content to the project's root
AGENTS.md or a dedicated shared skill within .agents/skills/.
- Replace duplicates with a one-line pointer: "See
<skill-name> for …".
- Reword overlapping
description fields so each skill has a unique trigger.
Phase 5 — Extract Bloated AGENTS.md Blocks
- Scan
AGENTS.md files within the project for inline instruction blocks >30 lines.
- For each block, create a new skill at
.agents/skills/<name>/SKILL.md within the project. Never create files outside the project repo.
- Replace the original block with a slim pointer + Quick Reference.
- If the project has a skill sync script, run it to sync
.agents/skills/ to .claude/skills/ within the project.
Output Format
After all phases, produce a summary report:
## Optimisation Report
| Skill | Before | After | Delta |
|-------|-------:|------:|------:|
| ... | 250 | 110 | -140 |
Total skills: N
Total lines saved: N
New skills created: N
Quick Reference
- Only operate on project-level
.agents/skills/ and .claude/skills/ — never ~/.agents/skills/ or ~/.claude/skills/.
- Source of truth: project's
.agents/skills/ — never edit .claude/skills/ directly.
- Canonical section order: H1, scope, When to Use, Rules, Quick Reference, Validation.
- Target: <=120 lines per skill.
- Never read, write, list, or modify files outside the project root.
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 within the project has inline instruction blocks >30 lines without a skill pointer.
- No files outside the project root were modified.
- No files under
~/.agents/skills/ or ~/.claude/skills/ were read or modified.
1---2name: optimise-claude3description: Use when auditing, trimming, or restructuring AI skill files to reduce context-window consumption.4---56# Optimise Claude78Use this skill when auditing AI skill files for size, structure, duplication, or bloated AGENTS.md inline blocks.910## Scope1112All operations are strictly limited to **project-level** skill directories:13- `.agents/skills/` (relative to project root)14- `.claude/skills/` (relative to project root)1516**NEVER** touch user-level (home directory) skill locations:17- `~/.agents/skills/`18- `~/.claude/skills/`1920Never read, write, list, or modify any file outside the current project root (`$PWD`).2122## When to Use2324- Skill files exceed ~120 lines.25- Frontmatter or section order is non-canonical.26- Multiple skills contain duplicated content.27- An AGENTS.md file has inline instruction blocks >30 lines that should be skills.2829## Workflow3031Run phases sequentially. Skip any phase that does not apply. Only operate on files within the current project repo.3233### Phase 1 — Inventory & Triage34351. List every `SKILL.md` under the project's `.agents/skills/`.362. For each file, record: name, line count, has frontmatter (y/n), has canonical sections (y/n).373. Flag violations: >120 lines, missing/incorrect frontmatter, wrong section order.384. Output a triage table sorted by line count descending.3940```41| Skill | Lines | FM | Sections | Violations |42|-------|------:|----|----------|------------|43```4445### Phase 2 — Reduce Token Usage4647For each flagged skill:4849- Trim prose to imperative bullets.50- Collapse verbose examples to minimal code fences.51- Remove redundant explanations already covered by parent AGENTS.md.52- Remove blank lines between list items.53- Target <=120 lines. If still over, split into focused sub-skills.5455### Phase 3 — Fix Structure & Frontmatter5657For each skill:5859- Ensure YAML frontmatter has `name` matching directory and `description` starting with "Use when".60- Enforce canonical section order: H1 title, scope line, When to Use, Rules/Instructions, Quick Reference, Validation.61- Remove empty or placeholder sections.62- Use imperative voice throughout.6364### Phase 4 — Cross-Skill Deduplication65661. Identify repeated content blocks across project skills (>5 similar lines).672. Move shared content to the project's root `AGENTS.md` or a dedicated shared skill within `.agents/skills/`.683. Replace duplicates with a one-line pointer: "See `<skill-name>` for …".694. Reword overlapping `description` fields so each skill has a unique trigger.7071### Phase 5 — Extract Bloated AGENTS.md Blocks72731. Scan `AGENTS.md` files within the project for inline instruction blocks >30 lines.742. For each block, create a new skill at `.agents/skills/<name>/SKILL.md` within the project. Never create files outside the project repo.753. Replace the original block with a slim pointer + Quick Reference.764. If the project has a skill sync script, run it to sync `.agents/skills/` to `.claude/skills/` within the project.7778## Output Format7980After all phases, produce a summary report:8182```83## Optimisation Report8485| Skill | Before | After | Delta |86|-------|-------:|------:|------:|87| ... | 250 | 110 | -140 |8889Total skills: N90Total lines saved: N91New skills created: N92```9394## Quick Reference9596- Only operate on project-level `.agents/skills/` and `.claude/skills/` — never `~/.agents/skills/` or `~/.claude/skills/`.97- Source of truth: project's `.agents/skills/` — never edit `.claude/skills/` directly.98- Canonical section order: H1, scope, When to Use, Rules, Quick Reference, Validation.99- Target: <=120 lines per skill.100- Never read, write, list, or modify files outside the project root.101102## Validation103104- `wc -l .agents/skills/*/SKILL.md` — no file exceeds 120 lines.105- Every `SKILL.md` has valid YAML frontmatter with `name` and `description`.106- No two skills share >5 identical lines.107- No `AGENTS.md` within the project has inline instruction blocks >30 lines without a skill pointer.108- No files outside the project root were modified.109- No files under `~/.agents/skills/` or `~/.claude/skills/` were read or modified.