$npx -y skills add spencermarx/open-code-review --skill v3-cli-modernizationCLI modernization and hooks system enhancement for claude-flow v3. Implements interactive prompts, command decomposition, enhanced hooks integration, and intelligent workflow automation.
| 1 | # V3 CLI Modernization |
| 2 | |
| 3 | ## What This Skill Does |
| 4 | |
| 5 | Modernizes claude-flow v3 CLI with interactive prompts, intelligent command decomposition, enhanced hooks integration, performance optimization, and comprehensive workflow automation capabilities. |
| 6 | |
| 7 | ## Quick Start |
| 8 | |
| 9 | ```bash |
| 10 | # Initialize CLI modernization analysis |
| 11 | Task("CLI architecture", "Analyze current CLI structure and identify optimization opportunities", "cli-hooks-developer") |
| 12 | |
| 13 | # Modernization implementation (parallel) |
| 14 | Task("Command decomposition", "Break down large CLI files into focused modules", "cli-hooks-developer") |
| 15 | Task("Interactive prompts", "Implement intelligent interactive CLI experience", "cli-hooks-developer") |
| 16 | Task("Hooks enhancement", "Deep integrate hooks with CLI lifecycle", "cli-hooks-developer") |
| 17 | ``` |
| 18 | |
| 19 | ## CLI Architecture Modernization |
| 20 | |
| 21 | ### Current State Analysis |
| 22 | ``` |
| 23 | Current CLI Issues: |
| 24 | ├── index.ts: 108KB monolithic file |
| 25 | ├── enterprise.ts: 68KB feature module |
| 26 | ├── Limited interactivity: Basic command parsing |
| 27 | ├── Hooks integration: Basic pre/post execution |
| 28 | └── No intelligent workflows: Manual command chaining |
| 29 | |
| 30 | Target Architecture: |
| 31 | ├── Modular Commands: <500 lines per command |
| 32 | ├── Interactive Prompts: Smart context-aware UX |
| 33 | ├── Enhanced Hooks: Deep lifecycle integration |
| 34 | ├── Workflow Automation: Intelligent command orchestration |
| 35 | └── Performance: <200ms command response time |
| 36 | ``` |
| 37 | |
| 38 | ### Modular Command Architecture |
| 39 | ```typescript |
| 40 | // src/cli/core/command-registry.ts |
| 41 | interface CommandModule { |
| 42 | name: string; |
| 43 | description: string; |
| 44 | category: CommandCategory; |
| 45 | handler: CommandHandler; |
| 46 | middleware: MiddlewareStack; |
| 47 | permissions: Permission[]; |
| 48 | examples: CommandExample[]; |
| 49 | } |
| 50 | |
| 51 | export class ModularCommandRegistry { |
| 52 | private commands = new Map<string, CommandModule>(); |
| 53 | private categories = new Map<CommandCategory, CommandModule[]>(); |
| 54 | private aliases = new Map<string, string>(); |
| 55 | |
| 56 | registerCommand(command: CommandModule): void { |
| 57 | this.commands.set(command.name, command); |
| 58 | |
| 59 | // Register in category index |
| 60 | if (!this.categories.has(command.category)) { |
| 61 | this.categories.set(command.category, []); |
| 62 | } |
| 63 | this.categories.get(command.category)!.push(command); |
| 64 | } |
| 65 | |
| 66 | async executeCommand(name: string, args: string[]): Promise<CommandResult> { |
| 67 | const command = this.resolveCommand(name); |
| 68 | if (!command) { |
| 69 | throw new CommandNotFoundError(name, this.getSuggestions(name)); |
| 70 | } |
| 71 | |
| 72 | // Execute middleware stack |
| 73 | const context = await this.buildExecutionContext(command, args); |
| 74 | const result = await command.middleware.execute(context); |
| 75 | |
| 76 | return result; |
| 77 | } |
| 78 | |
| 79 | private resolveCommand(name: string): CommandModule | undefined { |
| 80 | // Try exact match first |
| 81 | if (this.commands.has(name)) { |
| 82 | return this.commands.get(name); |
| 83 | } |
| 84 | |
| 85 | // Try alias |
| 86 | const aliasTarget = this.aliases.get(name); |
| 87 | if (aliasTarget) { |
| 88 | return this.commands.get(aliasTarget); |
| 89 | } |
| 90 | |
| 91 | // Try fuzzy match |
| 92 | return this.findFuzzyMatch(name); |
| 93 | } |
| 94 | } |
| 95 | ``` |
| 96 | |
| 97 | ## Command Decomposition Strategy |
| 98 | |
| 99 | ### Swarm Commands Module |
| 100 | ```typescript |
| 101 | // src/cli/commands/swarm/swarm.command.ts |
| 102 | @Command({ |
| 103 | name: 'swarm', |
| 104 | description: 'Swarm coordination and management', |
| 105 | category: 'orchestration' |
| 106 | }) |
| 107 | export class SwarmCommand { |
| 108 | constructor( |
| 109 | private swarmCoordinator: UnifiedSwarmCoordinator, |
| 110 | private promptService: InteractivePromptService |
| 111 | ) {} |
| 112 | |
| 113 | @SubCommand('init') |
| 114 | @Option('--topology', 'Swarm topology (mesh|hierarchical|adaptive)', 'hierarchical') |
| 115 | @Option('--agents', 'Number of agents to spawn', 5) |
| 116 | @Option('--interactive', 'Interactive agent configuration', false) |
| 117 | async init( |
| 118 | @Arg('projectName') projectName: string, |
| 119 | options: SwarmInitOptions |
| 120 | ): Promise<CommandResult> { |
| 121 | |
| 122 | if (options.interactive) { |
| 123 | return this.interactiveSwarmInit(projectName); |
| 124 | } |
| 125 | |
| 126 | return this.quickSwarmInit(projectName, options); |
| 127 | } |
| 128 | |
| 129 | private async interactiveSwarmInit(projectName: string): Promise<CommandResult> { |
| 130 | console.log(`🚀 Initializing Swarm for ${projectName}`); |
| 131 | |
| 132 | // Interactive topology selection |
| 133 | const topology = await this.promptService.select({ |
| 134 | message: 'Select swarm topology:', |
| 135 | choices: [ |
| 136 | { name: 'Hierarchical (Queen-led coordination)', value: 'hierarchical' }, |
| 137 | { name: 'Mesh (Peer-to-peer collaboration)', value: 'mesh' }, |
| 138 | { name: 'Adaptive (Dynamic topology switching)', value: 'adaptive' } |
| 139 | ] |
| 140 | }); |
| 141 | |
| 142 | // Agent configuration |
| 143 | const agents = await this.promptAgentConfiguration(); |
| 144 | |
| 145 | // Initialize with configuration |
| 146 | const swarm = await this.swarmCoordinator.initialize({ |
| 147 | name: projectName, |
| 148 | topology, |
| 149 | agents, |
| 150 | hooks: { |
| 151 | onAgentSpawn: this.handleAgentSpawn.bind(this), |
| 152 | onTaskComplete: this.handleTaskComplete.bin |