Plugin Optimization
Execute plugin validation and optimization workflow. Target: $ARGUMENTS
Background Knowledge
Template Compliance: Components MUST conform to templates in ${CLAUDE_PLUGIN_ROOT}/examples/. See references/template-validation.md for complete requirements (instruction-type/knowledge-type skills, agents).
Tool Patterns: See references/tool-patterns.md for invocation styles. Key: Skill/AskUserQuestion/TaskCreate require explicit "Use [tool] tool" phrasing.
Initialization
Use TaskCreate tool to track all four phases before starting work.
Phase 1: Discovery & Validation
Goal: Validate structure and detect issues. Orchestrator MUST NOT apply fixes.
Actions:
- •Resolve path with
realpathand verify existence - •Validate
.claude-plugin/plugin.jsonexists - •Validate components against
${CLAUDE_PLUGIN_ROOT}/examples/templates - •Assess architecture (ask about command migration if needed)
- •Run validation:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/validate-plugin.py "$TARGET" - •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: Skip this phase if Phase 1 found no issues (proceed directly to Phase 4).
Actions:
- •Launch
plugin-optimizer:plugin-optimizeragent with the following prompt content:- •Target plugin path (absolute path from Phase 1)
- •Complete list of validation issues with severity levels
- •Template compliance results from Phase 1
- •Any user decisions from architecture assessment
- •Agent autonomously applies fixes (uses AskUserQuestion for template fix approvals)
- •Agent increments version in
.claude-plugin/plugin.jsonafter fixes (patch: fixes/optimizations, minor: new components, major: breaking changes)
Phase 3: Final Verification
Goal: Re-run validation to verify fixes.
Condition: Only execute if Phase 2 applied fixes.
Actions:
- •Re-run all validation scripts from Phase 1
- •Compare results with initial findings
- •If critical issues remain: resume agent with remaining issues
- •Document outcome (fixed vs remaining with rationale)
Phase 4: Final Deliverables
Goal: Deliver comprehensive optimization report and updated documentation to user.
Actions:
- •Generate complete validation report with all findings, fixes, and verification results
- •Produce component inventory summary showing plugin structure
- •Update README.md to accurately reflect current plugin state
- •See
./references/workflow-phases.mdfor detailed steps and./references/report-template.mdfor format