Skill Enhancer
Purpose: This meta-skill analyzes other skills for compliance with TDD, CSO, and Script-First standards, guiding the agent through upgrades.
1. Red Flags (Anti-Rationalization)
STOP and READ THIS if you are thinking:
- "I'll just add the sections blindly" -> WRONG. You must understand why the skill fails before fixing it.
- "The description is close enough" -> WRONG. It must start with "Use when".
- "Examples are optional" -> WRONG. "Rich Skills" mandate examples.
- "It's just a small 20-line example" -> WRONG. Inline blocks > 12 lines are prohibited. Extract them.
- "I'll instruct the agent to parse the file line-by-line in text" -> WRONG. Use "Script-First".
2. Capabilities
- Audit: Detect gaps (missing Red Flags, oversized inline blocks, poor CSO, weak language) using
analyze_gaps.py.
- Rule scoping: the analyser reads prose, not code. Fenced blocks and inline
code spans are masked before the prose rules run,
[--flag VALUE] is CLI usage
notation rather than an unfilled slot, and /tmp/out.pdf in a reproducible
command is not the absolute-path anti-pattern — only a path naming one machine
or one user's account is (WI-033).
- Execution Policy Audit: Detect missing
Execution Mode, Script Contract, Safety Boundaries, and Validation Evidence sections.
- Security Remediation: Fix vulnerabilities flagged by
skill-validator (e.g., curl | bash, secrets, weak permissions).
- Plan: Propose specific content improvements using
references/refactoring_patterns.md.
- Execute: Apply refactoring patterns to upgrade the skill.
2.5. Execution Mode
- Mode:
hybrid
- Rationale: gap triage and refactoring decisions are prompt-driven, while gap detection is script-driven.
2.6. Script Contract
- Primary Command:
python3 scripts/analyze_gaps.py <target-skill-path> [--json] [--strict]
- Inputs: target skill path + optional output mode.
- Outputs: two lists and a status —
gaps (blocking) and advisories
(reported, non-blocking).
- Failure Semantics: non-zero exit when blocking gaps exist (deterministic
gate behavior). Advisories are printed and leave the exit code at 0;
--strict
promotes them to blocking. The split mirrors validate_skill.py, which already
passes a skill that has only warnings — without it the two gates return
different verdicts on the same file (WI-033).
- Advisory classes:
[Language] (the graduated-wording call is per
instruction, not mechanical) and [Execution Policy] (a declared warning-first
migration), plus the minor tier of [Token Efficiency].
2.7. Safety Boundaries
- Scope: apply edits only to explicitly selected target skill.
- Default Exclusions: do not refactor unrelated skills or global docs by default.
- Destructive Actions: full-file overwrite is prohibited unless explicitly requested and reviewed.
2.8. Validation Evidence
- Primary Evidence: before/after
analyze_gaps.py output.
- Secondary Evidence: targeted diffs proving that each reported gap was addressed.
- Quality Gate: no unresolved critical structure gaps after refactor.
3. Instructions
Phase 1: Audit
- Run Analyzer:
python3 scripts/analyze_gaps.py <target-skill-path>.
- Manual Checks:
- Graduated Language Review: Check instruction language against the graduated approach:
- Safety-critical steps (data loss, destructive ops): Must use
MUST/ALWAYS + explanation why — if the explanation is missing, add it
- Behavioral steps (formatting, style): Apply explain-why + imperative style — if bare
MUST without rationale, add the rationale; if weak "should"/"could", strengthen to imperative + reason
- Do NOT blindly replace every "should" with "MUST" — evaluate whether the instruction is safety-critical or behavioral first
- Script-First Gap: Identify if complex logic steps (> 5 lines of text) MUST be converted to a
script/.
- Review Gaps: Read the analyzer output and your manual findings.
Phase 1.5: Execution-Policy Audit
- Verify
Execution Mode section exists and is explicit (prompt-first, script-first, or hybrid).
- If skill uses
scripts/, verify Script Contract section defines command, inputs, outputs, and exit behavior.
- Verify
Safety Boundaries section defines scope limits and non-default destructive behavior.
- Verify
Validation Evidence section defines objective verification outputs.
4a. Check its size. validate_skill.py warns past
quality_checks.max_validation_evidence_lines (skill_standards_default.yaml), which means
the section is carrying an investigation rather than a verdict. Refactor: keep date, commands,
counts and pass/fail in SKILL.md; move figures, refuted hypotheses and worked examples into
references/<topic>.md and link them. This is a gap to fix, not prose to trim arbitrarily —
nothing is deleted, it moves.
- Mark missing pieces as migration gaps (warning-first for legacy skills).
Phase 1.7: Behavioral Analysis (If Usage Logs Available)
If transcripts or logs from real skill usage exist, analyze them for patterns:
- Repeated Code: Did the agent write the same helper script across multiple runs? → Extract to
scripts/.
- Repeated Questions: Did the agent ask the same questions or re-discover the same context? → Add to
references/.
- Excessive Token Usage: Did the agent spend tokens reading large inline blocks? → Plan extraction to external files.
- Unused Sections: Did the agent skip reading certain sections entirely? → Consider trimming or consolidating.
If no usage logs are available, skip this phase — it will become relevant after the skill is deployed.
Phase 2: Plan
- Read Target Skill: Read the content of the target skill.
- Draft Improvements:
- Token Efficiency: Identify blocks > 12 lines and plan extraction to
examples/, assets/, or references/.
- Script-First: Identify logic blocks > 5 lines and plan extraction to
scripts/.
- Execution Policy: Add missing policy sections and scope constraints.
- Graduated Language: Replace weak words using the graduated approach —
MUST + why for safety, explain-why + imperative for behavioral.
- Red Flags: Identify 2-3 likely agent excuses for this specific task.
- CSO & Pushiness: Rewrite description to "Use when [TRIGGER]...". Check if description is "pushy" enough to prevent under-triggering — add edge-case triggers and phrases like "even if the user doesn't explicitly ask for…".
- Generalization: Check if instructions are overfitted to specific examples. A skill must work across many prompts, not just the test cases it was developed with.
- Confirm: Ensure improvements align with the "Skills as Code" philosophy.
Phase 3: Execute
- Update File: Edit the target
SKILL.md to insert the new sections.
- CRITICAL: Use
replace_file_content or multi_replace_file_content.
- DO NOT use
write_to_file to overwrite existing content (Data Loss Risk).
- Tip: Use
references/refactoring_patterns.md for the style guide.
- Verify: Re-run
analyze_gaps.py. Expect "No Gaps Found", or "No blocking
gaps" with the advisories listed. An advisory is closed by fixing it or by
writing down why it stands — never by editing correct documentation to
satisfy a rule that is reading it wrong. If a rule fires on correct content,
narrow the rule and pin both halves in scripts/tests/test_rule_scoping.py:
what it now ignores, and the defect it must still catch.
Phase 3.5: Security Repair (If triggered by Validator)
- Analyze Report: Read the
skill-validator JSON output.
- Consult Guide: Use
references/security_refactoring.md to find safe alternatives for flagged patterns.
- Apply Fixes:
- Shell Injection: Replace direct execution with argument arrays.
- Downloads: Replace
curl | bash with download -> inspect -> execute.
- Secrets: Move hardcoded keys to environment variables.
Phase 4: Final VDD Check
- Read Checklist: Open
references/vdd_checklist.md.
- Self-Correction: Verify your work against the 5 criteria (Data Safety, Anti-Laziness, etc.).
- Refine: If any check fails (e.g., found "TODO", found unmotivated "should"), fix it immediately.
- Test Coverage: Verify the skill has at least 2-3 test prompts — either in
evals/evals.json or documented inline. If none exist, create them based on the skill's intended use cases.
4. Best Practices
| DO THIS |
DO NOT DO THIS |
| Specific Red Flags: "Don't skip tests" |
Generic Red Flags: "Don't be lazy" |
| Trigger-Based Desc: "Use when debugging race conditions" |
Summary Desc: "Guide for debugging" |
| Strong Verbs: "MUST", "EXECUTE", "VERIFY" |
Weak Verbs: "should", "consider", "try" |
Rationalization Table
| Agent Excuse |
Reality / Counter-Argument |
| "The skill is too simple for Red Flags" |
Simple skills are skipped most often. Explicit rules prevent this. |
| "I don't have time to write examples" |
Examples save time by preventing hallucinations later. |
| "It's easier to write logic in text" |
Text logic is unreliable. Scripts are deterministic. |
5. Examples (Few-Shot)
[!TIP]
See examples/usage_example.md for a complete Before & After walkthrough of upgrading a legacy skill.
Input:
python3 scripts/analyze_gaps.py ../target-skill
Output:
⚠️ Gaps Detected...
Recommendation: Run 'Execute Improvement Plan'...
6. Resources
scripts/analyze_gaps.py: The gap detection tool.
references/writing_skills_best_practices_anthropic.md: The authoritative "Gold Standard" guide used to verify compliance.
references/testing-skills-with-subagents.md: Methodology for verifying fixes using TDD (Red-Green-Refactor).
../skill-creator/agents/grader.md: Prompt for evaluating skill execution results against expectations.
../skill-creator/agents/comparator.md: Prompt for blind A/B comparison of two skill outputs.
../skill-creator/agents/analyzer.md: Prompt for post-hoc analysis — identifies why one skill version outperforms another.
1---2name: skill-enhancer3description: Use when you need to audit, fix, or improve an existing agent skill to meet Gold Standard compliance.4tier: 25version: 1.46---78# Skill Enhancer910**Purpose**: This meta-skill analyzes other skills for compliance with TDD, CSO, and Script-First standards, guiding the agent through upgrades.1112## 1. Red Flags (Anti-Rationalization)13**STOP and READ THIS if you are thinking:**14- "I'll just add the sections blindly" -> **WRONG**. You must understand *why* the skill fails before fixing it.15- "The description is close enough" -> **WRONG**. It must start with "Use when".16- "Examples are optional" -> **WRONG**. "Rich Skills" mandate examples.17- "It's just a small 20-line example" -> **WRONG**. Inline blocks > 12 lines are prohibited. Extract them.18- "I'll instruct the agent to parse the file line-by-line in text" -> **WRONG**. Use "Script-First".1920## 2. Capabilities21- **Audit**: Detect gaps (missing Red Flags, oversized inline blocks, poor CSO, weak language) using `analyze_gaps.py`.22- **Rule scoping**: the analyser reads prose, not code. Fenced blocks and inline23 code spans are masked before the prose rules run, `[--flag VALUE]` is CLI usage24 notation rather than an unfilled slot, and `/tmp/out.pdf` in a reproducible25 command is not the absolute-path anti-pattern — only a path naming one machine26 or one user's account is (WI-033).27- **Execution Policy Audit**: Detect missing `Execution Mode`, `Script Contract`, `Safety Boundaries`, and `Validation Evidence` sections.28- **Security Remediation**: Fix vulnerabilities flagged by `skill-validator` (e.g., `curl | bash`, secrets, weak permissions).29- **Plan**: Propose specific content improvements using `references/refactoring_patterns.md`.30- **Execute**: Apply refactoring patterns to upgrade the skill.3132## 2.5. Execution Mode33- **Mode**: `hybrid`34- **Rationale**: gap triage and refactoring decisions are prompt-driven, while gap detection is script-driven.3536## 2.6. Script Contract37- **Primary Command**: `python3 scripts/analyze_gaps.py <target-skill-path> [--json] [--strict]`38- **Inputs**: target skill path + optional output mode.39- **Outputs**: two lists and a status — `gaps` (blocking) and `advisories`40 (reported, non-blocking).41- **Failure Semantics**: non-zero exit when **blocking gaps** exist (deterministic42 gate behavior). Advisories are printed and leave the exit code at 0; `--strict`43 promotes them to blocking. The split mirrors `validate_skill.py`, which already44 passes a skill that has only warnings — without it the two gates return45 different verdicts on the same file (WI-033).46- **Advisory classes**: `[Language]` (the graduated-wording call is per47 instruction, not mechanical) and `[Execution Policy]` (a declared warning-first48 migration), plus the minor tier of `[Token Efficiency]`.4950## 2.7. Safety Boundaries51- **Scope**: apply edits only to explicitly selected target skill.52- **Default Exclusions**: do not refactor unrelated skills or global docs by default.53- **Destructive Actions**: full-file overwrite is prohibited unless explicitly requested and reviewed.5455## 2.8. Validation Evidence56- **Primary Evidence**: before/after `analyze_gaps.py` output.57- **Secondary Evidence**: targeted diffs proving that each reported gap was addressed.58- **Quality Gate**: no unresolved critical structure gaps after refactor.5960## 3. Instructions6162### Phase 1: Audit631. **Run Analyzer**: `python3 scripts/analyze_gaps.py <target-skill-path>`.642. **Manual Checks**:65 * **Graduated Language Review**: Check instruction language against the graduated approach:66 - **Safety-critical** steps (data loss, destructive ops): Must use `MUST`/`ALWAYS` **+ explanation why** — if the explanation is missing, add it67 - **Behavioral** steps (formatting, style): Apply **explain-why + imperative** style — if bare `MUST` without rationale, add the rationale; if weak "should"/"could", strengthen to imperative + reason68 - Do NOT blindly replace every "should" with "MUST" — evaluate whether the instruction is safety-critical or behavioral first69 * **Script-First Gap**: Identify if complex logic steps (> 5 lines of text) **MUST** be converted to a `script/`.703. **Review Gaps**: Read the analyzer output and your manual findings.7172### Phase 1.5: Execution-Policy Audit731. Verify `Execution Mode` section exists and is explicit (`prompt-first`, `script-first`, or `hybrid`).742. If skill uses `scripts/`, verify `Script Contract` section defines command, inputs, outputs, and exit behavior.753. Verify `Safety Boundaries` section defines scope limits and non-default destructive behavior.764. Verify `Validation Evidence` section defines objective verification outputs.774a. **Check its size.** `validate_skill.py` warns past78 `quality_checks.max_validation_evidence_lines` (`skill_standards_default.yaml`), which means79 the section is carrying an investigation rather than a verdict. Refactor: keep date, commands,80 counts and pass/fail in `SKILL.md`; move figures, refuted hypotheses and worked examples into81 `references/<topic>.md` and link them. This is a gap to fix, not prose to trim arbitrarily —82 nothing is deleted, it moves.835. Mark missing pieces as migration gaps (warning-first for legacy skills).8485### Phase 1.7: Behavioral Analysis (If Usage Logs Available)86If transcripts or logs from real skill usage exist, analyze them for patterns:871. **Repeated Code**: Did the agent write the same helper script across multiple runs? → Extract to `scripts/`.882. **Repeated Questions**: Did the agent ask the same questions or re-discover the same context? → Add to `references/`.893. **Excessive Token Usage**: Did the agent spend tokens reading large inline blocks? → Plan extraction to external files.904. **Unused Sections**: Did the agent skip reading certain sections entirely? → Consider trimming or consolidating.9192If no usage logs are available, skip this phase — it will become relevant after the skill is deployed.9394### Phase 2: Plan951. **Read Target Skill**: Read the content of the target skill.962. **Draft Improvements**:97 * *Token Efficiency*: Identify blocks > 12 lines and plan extraction to `examples/`, `assets/`, or `references/`.98 * *Script-First*: Identify logic blocks > 5 lines and plan extraction to `scripts/`.99 * *Execution Policy*: Add missing policy sections and scope constraints.100 * *Graduated Language*: Replace weak words using the graduated approach — `MUST + why` for safety, `explain-why + imperative` for behavioral.101 * *Red Flags*: Identify 2-3 likely agent excuses for *this specific task*.102 * *CSO & Pushiness*: Rewrite description to "Use when [TRIGGER]...". Check if description is "pushy" enough to prevent under-triggering — add edge-case triggers and phrases like "even if the user doesn't explicitly ask for…".103 * *Generalization*: Check if instructions are overfitted to specific examples. A skill must work across many prompts, not just the test cases it was developed with.1043. **Confirm**: Ensure improvements align with the "Skills as Code" philosophy.105106### Phase 3: Execute1071. **Update File**: Edit the target `SKILL.md` to insert the new sections.108 * **CRITICAL**: Use `replace_file_content` or `multi_replace_file_content`.109 * **DO NOT** use `write_to_file` to overwrite existing content (Data Loss Risk).110 * *Tip*: Use `references/refactoring_patterns.md` for the style guide.1112. **Verify**: Re-run `analyze_gaps.py`. Expect "No Gaps Found", or "No blocking112 gaps" with the advisories listed. An advisory is closed by fixing it or by113 writing down why it stands — never by editing correct documentation to114 satisfy a rule that is reading it wrong. If a rule fires on correct content,115 narrow the rule and pin both halves in `scripts/tests/test_rule_scoping.py`:116 what it now ignores, and the defect it must still catch.117118### Phase 3.5: Security Repair (If triggered by Validator)1191. **Analyze Report**: Read the `skill-validator` JSON output.1202. **Consult Guide**: Use `references/security_refactoring.md` to find safe alternatives for flagged patterns.1213. **Apply Fixes**:122 * *Shell Injection*: Replace direct execution with argument arrays.123 * *Downloads*: Replace `curl | bash` with download -> inspect -> execute.124 * *Secrets*: Move hardcoded keys to environment variables.125126### Phase 4: Final VDD Check1271. **Read Checklist**: Open `references/vdd_checklist.md`.1282. **Self-Correction**: Verify your work against the 5 criteria (Data Safety, Anti-Laziness, etc.).1293. **Refine**: If any check fails (e.g., found "TODO", found unmotivated "should"), fix it immediately.1304. **Test Coverage**: Verify the skill has at least 2-3 test prompts — either in `evals/evals.json` or documented inline. If none exist, create them based on the skill's intended use cases.131132## 4. Best Practices133134| DO THIS | DO NOT DO THIS |135| :--- | :--- |136| **Specific Red Flags**: "Don't skip tests" | **Generic Red Flags**: "Don't be lazy" |137| **Trigger-Based Desc**: "Use when debugging race conditions" | **Summary Desc**: "Guide for debugging" |138| **Strong Verbs**: "MUST", "EXECUTE", "VERIFY" | **Weak Verbs**: "should", "consider", "try" |139140### Rationalization Table141| Agent Excuse | Reality / Counter-Argument |142| :--- | :--- |143| "The skill is too simple for Red Flags" | Simple skills are skipped most often. Explicit rules prevent this. |144| "I don't have time to write examples" | Examples save time by preventing hallucinations later. |145| "It's easier to write logic in text" | Text logic is unreliable. Scripts are deterministic. |146147## 5. Examples (Few-Shot)148> [!TIP]149> See `examples/usage_example.md` for a complete **Before & After** walkthrough of upgrading a legacy skill.150151**Input:**152```bash153python3 scripts/analyze_gaps.py ../target-skill154```155156**Output:**157```text158⚠️ Gaps Detected...159Recommendation: Run 'Execute Improvement Plan'...160```161162## 6. Resources163- `scripts/analyze_gaps.py`: The gap detection tool.164- `references/writing_skills_best_practices_anthropic.md`: The authoritative "Gold Standard" guide used to verify compliance.165- `references/testing-skills-with-subagents.md`: Methodology for verifying fixes using TDD (Red-Green-Refactor).166- `../skill-creator/agents/grader.md`: Prompt for evaluating skill execution results against expectations.167- `../skill-creator/agents/comparator.md`: Prompt for blind A/B comparison of two skill outputs.168- `../skill-creator/agents/analyzer.md`: Prompt for post-hoc analysis — identifies why one skill version outperforms another.