Plugin Optimization
Execute plugin validation and optimization workflow. Target: $ARGUMENTS
Background Knowledge
Load plugin-optimizer:plugin-best-practices skill using the Skill tool for component templates, tool invocation rules, and type classification.
Phase 1: Discovery & Validation
Goal: Validate structure and detect issues. Orchestrator MUST NOT apply fixes.
Actions:
- Resolve path with
realpath and verify existence
- Validate
.claude-plugin/plugin.json exists
- Find component directories:
commands/, agents/, skills/, hooks/
- Validate components against
${CLAUDE_PLUGIN_ROOT}/examples/ templates
- Assess architecture: if
commands/ exists with .md files, use AskUserQuestion tool to ask about migrating to skills structure
- Run validation:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-plugin.py "$TARGET"
- Options:
--check=structure,manifest,frontmatter,tools,tokens
- JSON output:
--json
- Verbose:
-v, --verbose
- Compile issues by severity (Critical, Warning, Info)
Phase 2: Agent-Based Optimization
Goal: Launch agent to apply ALL fixes. Orchestrator does NOT make fixes directly.
Condition: Always execute.
Actions:
- Launch
plugin-optimizer:plugin-optimizer agent with the following prompt content:
- Target plugin path (absolute path from Phase 1)
- Validation console output (issues list from Phase 1)
- Template validation results
- User decisions (migration choice if applicable)
- INSTRUCTION: Analyze the validation output to identify issues
- Agent autonomously applies fixes (MUST use
AskUserQuestion tool before applying template fixes, presenting violations with specific examples and before/after comparison)
- Agent increments version in
.claude-plugin/plugin.json after fixes:
- Patch (x.y.Z+1): Bug fixes
- Minor (x.Y+1.0): New components
- Major (X+1.0.0): Breaking changes
- Wait for agent to complete
Path Reference Rules:
- Same directory: Use relative paths (
./reference.md)
- Outside directory: Use
${CLAUDE_PLUGIN_ROOT} paths
- Component templates: See
${CLAUDE_PLUGIN_ROOT}/examples/
Redundancy & Efficiency:
- Redundancy: Allow strategic repetition of critical content (MUST/SHOULD requirements). Favor concise restatement.
- Efficiency: Agent detects if tasks need Agent Teams (Parallelizable > 5 files, Multi-domain).
Phase 3: Verification & Deliverables
Goal: Verify fixes, generate report, and update documentation.
Actions:
- Execute validation script:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-plugin.py "$TARGET"
- Analyze results: compare with Phase 1 findings, confirm critical issues resolved
- If critical issues remain, resume agent execution
- Generate final validation report using template below
- Update
README.md to reflect current state (metadata, directory structure, usage instructions; do not append version history log)
Validation Report Template
## Plugin Validation Report
### Plugin: [name]
Location: [absolute-path]
Version: [old] -> [new]
### Summary
[2-3 sentences with key statistics]
### Phase 1: Issues Detected
#### Critical ([count])
- `file/path` - [Issue description]
#### Warnings ([count])
- `file/path` - [Issue description]
### Phase 2: Fixes Applied
#### Structure Fixes
- [Fix description]
#### Template Conformance
- **Agents**: [Count] validated, [count] fixed
- **Instruction-type Skills**: [Count] validated, [count] fixed
- **Knowledge-type Skills**: [Count] validated, [count] fixed
#### Redundancy Fixes
- [Consolidations applied]
### Phase 3: Verification Results
- Structure validation: [PASS/FAIL]
- Manifest validation: [PASS/FAIL]
- Component validation: [PASS/FAIL]
- Tool patterns validation: [PASS/FAIL]
- Token budgets validation: [PASS/FAIL]
### Token Budget Analysis
- Skills analyzed: [count]
- Tier 1 (Metadata ~100): [OK count], [WARNING count]
- Tier 2 (SKILL.md under 5k): [OK count], [WARNING count], [CRITICAL count]
- Tier 3 (References, effectively unlimited): [total tokens]
### Component Inventory
- Commands: [count] found, [count] valid
- Agents: [count] found, [count] valid
- Skills: [count] found, [count] valid
### Remaining Issues
[Issues that couldn't be auto-fixed with explanations]
### Overall Assessment
[PASS/FAIL] - [Detailed reasoning]
1---2name: optimize-plugin3description: This skill should be used when the user asks to "validate a plugin", "optimize plugin", "check plugin quality", "review plugin structure", or "run plugin optimizer".4argument-hint: <plugin-path>5user-invocable: true6allowed-tools: ["Read", "Glob", "Bash(realpath:*)", "Bash(python3:*)", "AskUserQuestion", "TaskCreate", "TaskUpdate", "Skill", "Task"]7metadata:8 source: https://skillmd.com/skills/fradser/optimize-plugin9---1011# Plugin Optimization1213Execute plugin validation and optimization workflow. **Target:** $ARGUMENTS1415## Background Knowledge1617Load `plugin-optimizer:plugin-best-practices` skill using the Skill tool for component templates, tool invocation rules, and type classification.1819## Phase 1: Discovery & Validation2021**Goal**: Validate structure and detect issues. Orchestrator MUST NOT apply fixes.2223**Actions**:241. Resolve path with `realpath` and verify existence252. Validate `.claude-plugin/plugin.json` exists263. Find component directories: `commands/`, `agents/`, `skills/`, `hooks/`274. Validate components against `${CLAUDE_PLUGIN_ROOT}/examples/` templates285. Assess architecture: if `commands/` exists with `.md` files, use `AskUserQuestion` tool to ask about migrating to skills structure296. Run validation: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-plugin.py "$TARGET"`30 - Options: `--check=structure,manifest,frontmatter,tools,tokens`31 - JSON output: `--json`32 - Verbose: `-v, --verbose`337. Compile issues by severity (Critical, Warning, Info)3435## Phase 2: Agent-Based Optimization3637**Goal**: Launch agent to apply ALL fixes. Orchestrator does NOT make fixes directly.3839**Condition**: Always execute.4041**Actions**:421. Launch `plugin-optimizer:plugin-optimizer` agent with the following prompt content:43 - Target plugin path (absolute path from Phase 1)44 - Validation console output (issues list from Phase 1)45 - Template validation results46 - User decisions (migration choice if applicable)47 - INSTRUCTION: Analyze the validation output to identify issues482. Agent autonomously applies fixes (MUST use `AskUserQuestion` tool before applying template fixes, presenting violations with specific examples and before/after comparison)493. Agent increments version in `.claude-plugin/plugin.json` after fixes:50 - Patch (x.y.Z+1): Bug fixes51 - Minor (x.Y+1.0): New components52 - Major (X+1.0.0): Breaking changes534. Wait for agent to complete5455**Path Reference Rules**:56- Same directory: Use relative paths (`./reference.md`)57- Outside directory: Use `${CLAUDE_PLUGIN_ROOT}` paths58- Component templates: See `${CLAUDE_PLUGIN_ROOT}/examples/`5960**Redundancy & Efficiency**:61- Redundancy: Allow strategic repetition of critical content (MUST/SHOULD requirements). Favor concise restatement.62- Efficiency: Agent detects if tasks need Agent Teams (Parallelizable > 5 files, Multi-domain).6364## Phase 3: Verification & Deliverables6566**Goal**: Verify fixes, generate report, and update documentation.6768**Actions**:691. Execute validation script: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-plugin.py "$TARGET"`702. Analyze results: compare with Phase 1 findings, confirm critical issues resolved713. If critical issues remain, resume agent execution724. Generate final validation report using template below735. Update `README.md` to reflect current state (metadata, directory structure, usage instructions; do not append version history log)7475## Validation Report Template7677```markdown78## Plugin Validation Report7980### Plugin: [name]81Location: [absolute-path]82Version: [old] -> [new]8384### Summary85[2-3 sentences with key statistics]8687### Phase 1: Issues Detected88#### Critical ([count])89- `file/path` - [Issue description]9091#### Warnings ([count])92- `file/path` - [Issue description]9394### Phase 2: Fixes Applied95#### Structure Fixes96- [Fix description]9798#### Template Conformance99- **Agents**: [Count] validated, [count] fixed100- **Instruction-type Skills**: [Count] validated, [count] fixed101- **Knowledge-type Skills**: [Count] validated, [count] fixed102103#### Redundancy Fixes104- [Consolidations applied]105106### Phase 3: Verification Results107- Structure validation: [PASS/FAIL]108- Manifest validation: [PASS/FAIL]109- Component validation: [PASS/FAIL]110- Tool patterns validation: [PASS/FAIL]111- Token budgets validation: [PASS/FAIL]112113### Token Budget Analysis114- Skills analyzed: [count]115- Tier 1 (Metadata ~100): [OK count], [WARNING count]116- Tier 2 (SKILL.md under 5k): [OK count], [WARNING count], [CRITICAL count]117- Tier 3 (References, effectively unlimited): [total tokens]118119### Component Inventory120- Commands: [count] found, [count] valid121- Agents: [count] found, [count] valid122- Skills: [count] found, [count] valid123124### Remaining Issues125[Issues that couldn't be auto-fixed with explanations]126127### Overall Assessment128[PASS/FAIL] - [Detailed reasoning]129```