Convert oversized commands (500-2400 lines) to lean declarative definitions (40-300 lines) by removing duplication, extracting domain knowledge to agents, and adopting the forge.md pattern.
Command retains WHAT and success criteria. Agent owns HOW.
2c: Delete dead content
Remove: deprecated format references | Aspirational unimplemented features | Verbose JSON contradicting current format | BUILD:INJECT placeholders | Mixed-language comments
2d: Reduce aggressive language
"CRITICAL: You MUST extract..." -> "Extract..."
"MANDATORY: Use the Task tool" -> "Use the Task tool"
For orchestrators, add Phases section between overview and agent invocation.
Phase 4: Validate
[ ] Under size target (dispatchers: 40-150, orchestrators: 100-300)
[ ] No duplicated boilerplate
[ ] No domain knowledge belonging in agents
[ ] No aggressive language (CRITICAL/MANDATORY/MUST count = 0)
[ ] 2-3 examples max
[ ] No dead code or deprecated references
[ ] Declarative structure (WHAT not HOW)
[ ] Measurable success criteria
[ ] Clear agent invocation pattern
Phase 5: Measure and Report
Report before/after: Line count (target 60-80% reduction for large files) | Content categories removed/moved | Aggressive language removed | Dependencies created (shared preamble, agent skill additions)
Special Case: develop.md (Mega-Orchestrator)
develop.md at 2,394 lines requires special handling:
Embeds 6+ sub-command workflows inline
Should reference sub-commands, not embed them
Orchestration logic (phase sequencing, resume) is legitimate -- keep it
Agent prompt templates for sub-commands -> replace with references
Target: 200-300 lines of pure orchestration
Approach: extract orchestration phases as lean sequence (which agent, which command, what context, what gate), remove all embedded sub-command content.
Shared Orchestrator Preamble
Extract common orchestrator knowledge to single shared skill:
Architectural constraint about sub-agent tool access
Valid agent list with brief capabilities
Standard parameter parsing rules
Pre-invocation validation pattern
Correct/wrong invocation examples (2 each)
Estimated: ~60-80 lines. Replaces ~620 lines duplicated across commands.
How to use it
Copy the folder
Take nwave-ai/nw-command-optimization-workflow from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
Check the name does not clash
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.