Skip to main content

v3-cli-modernization

CLI modernization and hooks system enhancement for claude-flow v3. Implements interactive prompts, command decomposition, enhanced hooks integration, and intelligent workflow automation.

Source facts

Repository
ruvnet/agentic-flow
Last source activity
February 13, 2026 at 16:43
Detected SKILL.md language
English
Stars
816
Forks
178

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
V3 CLI Modernization
description
CLI modernization and hooks system enhancement for claude-flow v3. Implements interactive prompts, command decomposition, enhanced hooks integration, and intelligent workflow automation.
# V3 CLI Modernization ## What This Skill Does Modernizes claude-flow v3 CLI with interactive prompts, intelligent command decomposition, enhanced hooks integration, performance optimization, and comprehensive workflow automation capabilities. ## Quick Start ```bash # Initialize CLI modernization analysis Task("CLI architecture", "Analyze current CLI structure and identify optimization opportunities", "cli-hooks-developer") # Modernization implementation (parallel) Task("Command decomposition", "Break down large CLI files into focused modules", "cli-hooks-developer") Task("Interactive prompts", "Implement intelligent interactive CLI experience", "cli-hooks-developer") Task("Hooks enhancement", "Deep integrate hooks with CLI lifecycle", "cli-hooks-developer") ``` ## CLI Architecture Modernization ### Current State Analysis ``` Current CLI Issues: ├── index.ts: 108KB monolithic file ├── enterprise.ts: 68KB feature module ├── Limited interactivity: Basic command parsing ├── Hooks integration: Basic pre/post execution └── No intelligent workflows: Manual command chaining Target Architecture: ├── Modular Commands: <500 lines per command ├── Interactive Prompts: Smart context-aware UX ├── Enhanced Hooks: Deep lifecycle integration ├── Workflow Automation: Intelligent command orchestration └── Performance: <200ms command response time ``` ### Modular Command Architecture ```typescript // src/cli/core/command-registry.ts interface CommandModule { name: string; description: string; category: CommandCategory; handler: CommandHandler; middleware: MiddlewareStack; permissions: Permission[]; examples: CommandExample[]; } export class ModularCommandRegistry { private commands = new Map<string, CommandModule>(); private categories = new Map<CommandCategory, CommandModule[]>(); private aliases = new Map<string, string>(); registerCommand(command: CommandModule): void { this.commands.set(command.name, command); // Register in category index if (!this.categories.has(command.category)) { this.categories.set(command.category, []); } this.categories.get(command.category)!.push(command); } async executeCommand(name: string, args: string[]): Promise<CommandResult> { const command = this.resolveCommand(name); if (!command) { throw new CommandNotFoundError(name, this.getSuggestions(name)); } // Execute middleware stack const context = await this.buildExecutionContext(command, args); const result = await command.middleware.execute(context); return result; } private resolveCommand(name: string): CommandModule | undefined { // Try exact match first if (this.commands.has(name)) { return this.commands.get(name); } // Try alias const aliasTarget = this.aliases.get(name); if (aliasTarget) { return this.commands.get(aliasTarget); } // Try fuzzy match return this.findFuzzyMatch(name); } } ``` ## Command Decomposition Strategy ### Swarm Commands Module ```typescript // src/cli/commands/swarm/swarm.command.ts @Command({ name: "swarm", description: "Swarm coordination and management", category: "orchestration", }) export class SwarmCommand { constructor( private swarmCoordinator: UnifiedSwarmCoordinator, private promptService: InteractivePromptService, ) {} @SubCommand("init") @Option( "--topology", "Swarm topology (mesh|hierarchical|adaptive)", "hierarchical", ) @Option("--agents", "Number of agents to spawn", 5) @Option("--interactive", "Interactive agent configuration", false) async init( @Arg("projectName") projectName: string, options: SwarmInitOptions, ): Promise<CommandResult> { if (options.interactive) { return this.interactiveSwarmInit(projectName); } return this.quickSwarmInit(projectName, options); } private async interactiveSwarmInit( projectName: string, ): Promise<CommandResult> { console.log(`🚀 Initializing Swarm for ${projectName}`); // Interactive topology selection const topology = await this.promptService.select({ message: "Select swarm topology:", choices: [ { name: "Hierarchical (Queen-led coordination)", value: "hierarchical", }, { name: "Mesh (Peer-to-peer collaboration)", value: "mesh" }, { name: "Adaptive (Dynamic topology switching)", value: "adaptive" }, ], }); // Agent configuration const agents = await this.promptAgentConfiguration(); // Initialize with configuration const swarm = await this.swarmCoordinator.initialize({ name: projectName, topology, agents, hooks: { onAgentSpawn: this.handleAgentSpawn.bind(this), onTaskComplete: this.handleTaskComplete.bind(this), onSwarmComplete: this.handleSwarmComplete.bind(this), }, }); return CommandResult.success({ message: `✅ Swarm ${projectName} initialized with ${agents.length} agents`, data: { swarmId: swarm.id, topology, agentCount: agents.length }, }); } @SubCommand("status") async status(): Promise<CommandResult> { const swarms = await this.swarmCoordinator.listActiveSwarms(); if (swarms.length === 0) { return CommandResult.info("No active swarms found"); } // Interactive swarm selection if multiple const selectedSwarm = swarms.length === 1 ? swarms[0] : await this.promptService.select({ message: "Select swarm to inspect:", choices: swarms.map((s) => ({ name: `${s.name} (${s.agents.length} agents, ${s.topology})`, value: s, })), }); return this.displaySwarmStatus(selectedSwarm); } } ``` ### Learning Commands Module ```typescript // src/cli/commands/learning/learning.command.ts @Command({ name: "learning", description: "Learning system management and optimization", category: "intelligence", }) export class LearningCommand { constructor( private learningService: IntegratedLearningService, private promptService: InteractivePromptService, ) {} @SubCommand("start") @Option("--algorithm", "RL algorithm to use", "auto") @Option("--tier", "Learning tier (basic|standard|advanced)", "standard") async start(options: LearningStartOptions): Promise<CommandResult> { // Auto-detect optimal algorithm if not specified if (options.algorithm === "auto") { const taskContext = await this.analyzeCurrentContext(); options.algorithm = this.learningService.selectOptimalAlgorithm(taskContext); console.log( `🧠 Auto-selected ${options.algorithm} algorithm based on context`, ); } const session = await this.learningService.startSession({ algorithm: options.algorithm, tier: options.tier, userId: await this.getCurrentUser(), }); return CommandResult.success({ message: `🚀 Learning session started with ${options.algorithm}`, data: { sessionId: session.id, algorithm: options.algorithm, tier: options.tier, }, }); } @SubCommand("feedback") @Arg("reward", "Reward value (0-1)", "number") async feedback( @Arg("reward") reward: number, @Option("--context", "Additional context for learning") context?: string, ): Promise<CommandResult> { const activeSession = await this.learningService.getActiveSession(); if (!activeSession) { return CommandResult.error( "No active learning session found. Start one with `learning start`", ); } await this.learningService.submitFeedback({ sessionId: activeSession.id, reward, context, timestamp: new Date(), }); return CommandResult.success({ message: `📊 Feedback recorded (reward: ${reward})`, data: { reward, sessionId: activeSession.id }, }); } @SubCommand("metrics") async metrics(): Promise<CommandResult> { const metrics = await this.learningService.getMetrics(); // Interactive metrics display await this.displayInteractiveMetrics(metrics); return CommandResult.success("Metrics displayed"); } } ``` ## Interactive Prompt System ### Advanced Prompt Service ```typescript // src/cli/services/interactive-prompt.service.ts interface PromptOptions { message: string; type: "select" | "multiselect" | "input" | "confirm" | "progress"; choices?: PromptChoice[]; default?: any; validate?: (input: any) => boolean | string; transform?: (input: any) => any; } export class InteractivePromptService { private inquirer: any; // Dynamic import for tree-shaking async select<T>(options: SelectPromptOptions<T>): Promise<T> { const { default: inquirer } = await import("inquirer"); const result = await inquirer.prompt([ { type: "list", name: "selection", message: options.message, choices: options.choices, default: options.default, }, ]); return result.selection; } async multiSelect<T>(options: MultiSelectPromptOptions<T>): Promise<T[]> { const { default: inquirer } = await import("inquirer"); const result = await inquirer.prompt([ { type: "checkbox", name: "selections", message: options.message, choices: options.choices, validate: (input: T[]) => { if (options.minSelections && input.length < options.minSelections) { return `Please select at least ${options.minSelections} options`; } if (options.maxSelections && input.length > options.maxSelections) { return `Please select at most ${options.maxSelections} options`; } return true; }, }, ]); return result.selections; } async input(options: InputPromptOptions): Promise<string> { const { default: inquirer } = await import("inquirer"); const result = await inquirer.prompt([ { type: "input", name: "input", message: options.message, default: options.default, validate: options.validate, transformer: options.transform, }, ]); return result.input; } async progressTask<T>( task: ProgressTask<T>, options: ProgressOptions, ): Promise<T> { const { default: cliProgress } = await import("cli-progress"); const progressBar = new cliProgress.SingleBar({ format: `${options.title} |{bar}| {percentage}% | {status}`, barCompleteChar: "█", barIncompleteChar: "░", hideCursor: true, }); progressBar.start(100, 0, { status: "Starting..." }); try { const result = await task({ updateProgress: (percent: number, status?: string) => { progressBar.update(percent, { status: status || "Processing..." }); }, }); progressBar.update(100, { status: "Complete!" }); progressBar.stop(); return result; } catch (error) { progressBar.stop(); throw error; } } async confirmWithDetails( message: string, details: ConfirmationDetails, ): Promise<boolean> { console.log("\n" + chalk.bold(message)); console.log(chalk.gray("Details:")); for (const [key, value] of Object.entries(details)) { console.log(chalk.gray(` ${key}: ${value}`)); } return this.confirm("\nProceed?"); } } ``` ## Enhanced Hooks Integration ### Deep CLI Hooks Integration ```typescript // src/cli/hooks/cli-hooks-manager.ts interface CLIHookEvent { type: | "command_start" | "command_end" | "command_error" | "agent_spawn" | "task_complete"; command: string; args: string[]; context: ExecutionContext; timestamp: Date; } export class CLIHooksManager { private hooks: Map<string, HookHandler[]> = new Map(); private learningIntegration: LearningHooksIntegration; constructor() { this.learningIntegration = new LearningHooksIntegration(); this.setupDefaultHooks(); } private setupDefaultHooks(): void { // Learning integration hooks this.registerHook("command_start", async (event: CLIHookEvent) => { await this.learningIntegration.recordCommandStart(event); }); this.registerHook("command_end", async (event: CLIHookEvent) => { await this.learningIntegration.recordCommandSuccess(event); });
View on GitHub
This SKILL.md is very large, so SkillsMP previews the first section here. View on GitHub