plugins/plugin-creator/skills/optimize-claude-md/SKILL.md
Optimize existing CLAUDE.md, SKILL.md, agent definitions, and other AI-facing files for Claude comprehension and economy. Scope: optimization of existing content only — not upstream sync, not read-only auditing. Measures baseline metrics, delegates to @contextual-ai-documentation-optimizer agent with file-type-specific context, runs independent verification via second agent, measures post-optimization metrics, and presents comprehensive before/after report. Supports iterative mode for large targets. Use when improving prompt effectiveness, reducing token waste, or rewriting instructions for LLM consumption. Invoke with /optimize-claude-md <file-or-directory>.
npx skillsauth add jamie-bitflight/claude_skills optimize-claude-mdInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Orchestrate multi-phase optimization of AI-facing documentation with measurement, delegation, verification, and comprehensive reporting.
/optimize-claude-md <path>
Where <path> is one of:
./CLAUDE.md, .claude/skills/my-skill/SKILL.md, .claude/agents/my-agent.md).claude/skills/my-skill/) — optimizes SKILL.md and all reference filesplugins/my-plugin/) — optimizes CLAUDE.md, all skills, and all agents<user_provided_target>$ARGUMENTS</user_provided_target>
<PWD> !pwd </PWD>
If <user_provided_target> is empty, ask the user for a target path before proceeding.
If <user_provided_target> is not an absolute path, prepend the value of <PWD> to produce the absolute path. Use that absolute path for all subsequent operations.
Verify the resolved absolute path exists. Determine scope (single file, skill directory, or plugin directory).
For all files:
uvx skilllint@latest check --check <file>For SKILL.md files only:
Record metrics for reporting.
Spawn the optimization agent via Agent tool with enhanced delegation template (see below). Pass file-type-specific context, baseline metrics, and constraints.
<delegation_template>
TARGET: {resolved path(s)}
FILE TYPE: {CLAUDE.md | SKILL.md | agent definition | reference file}
BASELINE TOKEN COUNT: {N tokens}
BASELINE COMPLETENESS SCORE: {X/24} (SKILL.md only)
TASK:
1. Run RT-ICA pre-check — verify file type, intent, audience, constraints
2. Enable the prompt-optimization skill
3. Read the complete target file(s)
4. Analyze against the 8 optimization principles:
- Positive framing (replace prohibitions with directives)
- Motivation (explain why rules exist)
- Concrete examples (show correct and incorrect patterns)
- Front-loaded priorities (critical info first)
- Concise language (economy without ambiguity)
- Explicit format control (structure instructions clearly)
- Strategic XML tagging (semantic boundaries for complex prompts)
- Structural enforcement (decision flows, tables, checklists for determinism)
5. Apply transformations — preserve original intent, improve execution economy
6. Run CoVe post-check — generate falsifiable verification questions, answer independently
7. Report token impact for each transformation
8. Signal completion status: DONE or BLOCKED
CONSTRAINTS:
- Preserve all original intent and functional behavior
- Maintain file structure conventions (frontmatter format, heading hierarchy)
- Apply compression only where it improves clarity — brevity is not the sole goal
- Verify technical terms are exact (tool names, file paths, command syntax)
- Report token impact for each transformation
- For SKILL.md: evaluate against 8 completeness categories, keep description <1024 chars, no YAML multiline indicators
- For agent files: preserve required frontmatter fields (name, description)
- For CLAUDE.md: front-load critical instructions, use decision flow diagrams for complex logic
- For CLAUDE.md: read `.claude/skills/optimize-claude-md/references/claude-rules-extraction.md` before analyzing; perform rules extraction phase after optimization analysis, before CoVe
- Signal DONE when optimization complete, BLOCKED when missing required inputs
OUTPUT STRUCTURE:
- RT-ICA Pre-Check Results
- Analysis of Optimization Opportunities
- Optimized Content (complete file)
- Changes Applied with Principle Citations
- Token Impact Per Transformation
- CoVe Verification Results
- Status: DONE or BLOCKED (with blocking reason if BLOCKED)
</delegation_template>
Routing within contextual-ai-documentation-optimizer:
plugin-creator:contextual-ai-documentation-optimizer (this skill uses this path)/plugin-creator:audit-skill-completeness skill directlyskill-content-updater lands (backlog #1899)/plugin-creator:write-frontmatter-description skill directlyIf agent signals BLOCKED:
If agent signals DONE:
Spawn a SECOND agent (general-purpose, NOT the same agent that optimized) to verify optimization quality.
Verification Template:
ORIGINAL FILE: {path to original}
OPTIMIZED FILE: {path to optimized version}
TASK:
Compare the original and optimized files. Verify:
1. Original intent preserved — no functional behaviors lost
2. Technical terms exact — tool names, file paths, command syntax unchanged
3. Structural conventions maintained — frontmatter format, heading hierarchy intact
4. No regressions introduced — edge cases still handled, constraints still enforced
CONSTRAINTS:
- You have NO context from the optimization process
- Base verification ONLY on comparing the two files
- Report any regressions, ambiguities, or losses of specificity
- Signal PASS if optimization preserves all original intent
- Signal REGRESSION if any functional behavior was lost or technical terms changed incorrectly
OUTPUT:
- Verification Status: PASS or REGRESSION
- Regressions Found (if any) with line number references
- Preserved Behaviors (summary)
Handle verification result:
For all files:
(post - baseline) / baseline * 100For SKILL.md files only:
post - baseline (absolute change)Record metrics for reporting.
Report to user with structure:
## Optimization Report: {filename}
### Baseline Metrics
- Token Count: {N tokens}
- Completeness Score: {X/24} (SKILL.md only)
### Post-Optimization Metrics
- Token Count: {M tokens} ({+/-Y%})
- Completeness Score: {Z/24} (delta: {+/-D}) (SKILL.md only)
### Changes Applied
{List of transformations with principle citations from agent report}
### CoVe Verification Results
{Agent's falsifiable verification questions and answers}
### Independent Verification
- Status: {PASS | REGRESSION}
- {Regression details if any}
### Structural Upgrade Candidates
{Sections that could benefit from decision flows, tables, checklists}
### Before/After Diff
{Diff output showing exact changes}
### Recommendation
{Proceed with optimization | Revise based on regressions | Keep original}
Write optimized content ONLY after user confirms. Do not auto-apply.
For files exceeding TOKEN_WARNING_THRESHOLD (defined in skilllint) or plugin directories, offer iterative optimization:
Pass 1: Structural Changes
Pass 2: Content Optimization
Pass 3: Polish
Convergence: Terminate when completeness score stops improving between passes (delta <1 point) or token reduction plateaus (delta <2%).
When target is a skill directory:
references/ (secondary)When target is a plugin directory:
TOKEN_WARNING_THRESHOLD): Offer iterative mode with multi-pass optimizationdevelopment
When an application needs to store config, data, cache, or state files. When designing where user-specific files should live. When code writes to ~/.appname or hardcoded home paths. When implementing cross-platform file storage with platformdirs.
testing
Enforce mandatory pre-action verification checkpoints to prevent pattern-matching from overriding explicit reasoning. Use this skill when about to execute implementation actions (Bash, Write, Edit) to verify hypothesis-action alignment. Blocks execution when hypothesis unverified or action targets different system than hypothesis identified. Critical for preventing cognitive dissonance where correct diagnosis leads to wrong implementation.
tools
Reference guide for the Twelve-Factor App methodology — 15 principles (12 original + 3 modern extensions) for building portable, resilient, cloud-native applications. Use when evaluating application architecture, designing cloud-native services, reviewing codebases for methodology compliance, advising on configuration, scaling, observability, security, and deployment patterns. Incorporates the 2025 open-source community evolution and cloud-native reinterpretations of each factor.
tools
Converts user-facing documentation (how-to guides, tutorials, API references, examples) in any format — Markdown, PDF, DOCX, PPTX, XLSX, AsciiDoc, RST, HTML, Jupyter notebooks, man pages, TOML/YAML/JSON configs, and plain text — into Claude Code skill directories with SKILL.md plus thematically grouped references/*.md files. Use when given a docs directory or mixed-format documentation to transform into an AI skill. Uses MCP file-reader server for binary formats.