# Nw Command Optimization Workflow

Step-by-step workflow for converting bloated command files to lean declarative definitions

- Repository: https://github.com/nWave-ai/nWave (628 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add nWave-ai/nWave --skill nw-command-optimization-workflow -g -a claude-code -y`
Codex: `npx skills add nWave-ai/nWave --skill nw-command-optimization-workflow -g -a codex -y`
Cursor: `npx skills add nWave-ai/nWave --skill nw-command-optimization-workflow -g -a cursor -y`
Gemini CLI: `npx skills add nWave-ai/nWave --skill nw-command-optimization-workflow -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add nWave-ai/nWave`

## Description

Step-by-step workflow for converting bloated command files to lean declarative definitions

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Command Optimization Workflow

## Overview

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.

## Phase 1: Analyze

1. **Classify**: dispatcher, orchestrator, or simple
2. **Measure**: `wc -l` the file
3. **Identify content categories** (approximate %): parameter parsing/validation | Workflow/orchestration logic | Agent prompt templates | Examples/documentation | Error handling | Boilerplate (orchestrator briefing, agent registry)
4. **Flag reducible content**: Duplication from other commands (orchestrator briefing, agent registry, parameter parsing) | Domain knowledge belonging in agents (TDD phases, review criteria, methodology) | Dead code (deprecated formats, aspirational features, old signatures) | Verbose examples (JSON blocks exceeding 3 examples) | Aggressive language (count CRITICAL/MANDATORY/MUST)

## Phase 2: Extract

### 2a: Remove shared boilerplate
These blocks appear in 5-12 commands, extract to shared orchestrator preamble skill:
- "Sub-agents have NO ACCESS to Skill tool" briefing (~20-30 lines/file)
- Agent registry with capabilities (~15-20 lines/file)
- Parameter parsing rules (~10-15 lines/file)
- Pre-invocation validation checklist (~10-15 lines/file)
- "What NOT to include" blocks (~8-12 lines/file)

After extraction, command references preamble.

### 2b: Move domain knowledge to agents
If command contains HOW the agent works, move to agent definition or skill:
- TDD phase details -> nw-software-crafter | DIVIO templates -> nw-documentarist | Refactoring hierarchies -> nw-software-crafter | BDD/Gherkin -> nw-acceptance-designer | Review criteria -> reviewer agent | Mutation testing config -> nw-software-crafter

Command retains WHAT and success criteria. Agent owns HOW.

The rest: https://github.com/nWave-ai/nWave/blob/HEAD/nWave/skills/nw-command-optimization-workflow/SKILL.md
