| 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
Task("CLI architecture", "Analyze current CLI structure and identify optimization opportunities", "cli-hooks-developer")
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
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);
if (!this.categories.has(command.category)) {
this..(command., []);
}
..(command.)!.(command);
}
(: , : []): <> {
command = .(name);
(!command) {
(name, .(name));
}
context = .(command, args);
result = command..(context);
result;
}
(: ): | {
(..(name)) {
..(name);
}
aliasTarget = ..(name);
(aliasTarget) {
..(aliasTarget);
}
.(name);
}
}
Command Decomposition Strategy
Swarm Commands Module
@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.(projectName, options);
}
(
: ,
): <> {
.();
topology = ..({
: ,
: [
{
: ,
: ,
},
{ : , : },
{ : , : },
],
});
agents = .();
swarm = ..({
: projectName,
topology,
agents,
: {
: ..(),
: ..(),
: ..(),
},
});
.({
: ,
: { : swarm., topology, : agents. },
});
}
()
(): <> {
swarms = ..();
(swarms. === ) {
.();
}
selectedSwarm =
swarms. ===
? swarms[]
: ..({
: ,
: swarms.( ({
: ,
: s,
})),
});
.(selectedSwarm);
}
}
Learning Commands Module
@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> {
if (options.algorithm === "auto") {
const taskContext = await this.analyzeCurrentContext();
options.algorithm =
this.learningService.selectOptimalAlgorithm(taskContext);
console.(
,
);
}
session = ..({
: options.,
: options.,
: .(),
});
.({
: ,
: {
: session.,
: options.,
: options.,
},
});
}
()
(, , )
(
() : ,
(, )
?: ,
): <> {
activeSession = ..();
(!activeSession) {
.(
,
);
}
..({
: activeSession.,
reward,
context,
: (),
});
.({
: ,
: { reward, : activeSession. },
});
}
()
(): <> {
metrics = ..();
.(metrics);
.();
}
}
Interactive Prompt System
Advanced Prompt Service
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;
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,
: options.,
: options.,
},
]);
result.;
}
multiSelect<T>(: <T>): <T[]> {
{ : inquirer } = ();
result = inquirer.([
{
: ,
: ,
: options.,
: options.,
: {
(options. && input. < options.) {
;
}
(options. && input. > options.) {
;
}
;
},
},
]);
result.;
}
(: ): <> {
{ : inquirer } = ();
result = inquirer.([
{
: ,
: ,
: options.,
: options.,
: options.,
: options.,
},
]);
result.;
}
progressTask<T>(
: <T>,
: ,
): <T> {
{ : cliProgress } = ();
progressBar = cliProgress.({
: ,
: ,
: ,
: ,
});
progressBar.(, , { : });
{
result = ({
: {
progressBar.(percent, { : status || });
},
});
progressBar.(, { : });
progressBar.();
result;
} (error) {
progressBar.();
error;
}
}
(
: ,
: ,
): <> {
.( + chalk.(message));
.(chalk.());
( [key, value] .(details)) {
.(chalk.());
}
.();
}
}
Enhanced Hooks Integration
Deep CLI Hooks Integration
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 {
this.registerHook("command_start", async (event: CLIHookEvent) => {
await this..(event);
});
.(, (: ) => {
..(event);
});
.(, (: ) => {
..(event);
});
.(, (: ) => {
suggestions = .(event);
(suggestions. > ) {
.(suggestions);
}
});
.(, (: ) => {
.(event);
});
}
(: , : ): <> {
handlers = ..() || [];
.(
handlers.( .(handler, event)),
);
}
(
: ,
): <[]> {
context = ..(event);
patterns =
..(context);
patterns.( ({
: ,
: ,
: pattern.,
}));
}
}
Learning Integration
export class LearningHooksIntegration {
constructor(
private agenticFlowHooks: AgenticFlowHooksClient,
private agentDBLearning: AgentDBLearningClient,
) {}
async recordCommandStart(event: CLIHookEvent): Promise<void> {
await this.agenticFlowHooks.trajectoryStart({
sessionId: event.context.sessionId,
command: event.command,
args: event.args,
context: event.context,
});
await this.agentDBLearning.recordExperience({
type: "command_execution",
state: this.encodeCommandState(event),
action: event.command,
timestamp: event.timestamp,
});
}
async recordCommandSuccess(event: ): <> {
executionTime = .() - event..();
reward = .(event, executionTime, );
..({
: event..,
: ,
reward,
: ,
});
..({
: event..,
reward,
: ,
: executionTime,
});
(reward > ) {
..({
: event.,
: event..,
: reward,
});
}
}
(: ): <> {
executionTime = .() - event..();
reward = .(event, executionTime, );
..({
: event..,
: ,
reward,
: ,
: event..,
});
..({
: event..,
reward,
: ,
: executionTime,
: event..,
});
}
(
: ,
: ,
: ,
): {
(!success) ;
reward = ;
expectedTime = .(event.);
(executionTime < expectedTime) {
reward += * ( - executionTime / expectedTime);
}
complexity = .(event);
reward += complexity * ;
.(reward, );
}
}
Intelligent Workflow Automation
Workflow Orchestrator
interface WorkflowStep {
id: string;
command: string;
args: string[];
dependsOn: string[];
condition?: WorkflowCondition;
retryPolicy?: RetryPolicy;
}
export class WorkflowOrchestrator {
constructor(
private commandRegistry: ModularCommandRegistry,
private promptService: InteractivePromptService,
) {}
async executeWorkflow(workflow: Workflow): Promise<WorkflowResult> {
const context = new WorkflowExecutionContext(workflow);
await this.displayWorkflowOverview(workflow);
const confirmed = await this.promptService.confirm(
"Execute this workflow?",
);
if (!confirmed) {
return WorkflowResult.cancelled();
}
..(
({ updateProgress }) => {
steps = .(workflow.);
( i = ; i < steps.; i++) {
step = steps[i];
((i / steps.) * , );
.(step, context);
}
.(context.());
},
{ : },
);
}
(: ): <> {
patterns = .(intent);
(patterns. === ) {
();
}
selectedPattern =
patterns. ===
? patterns[]
: ..({
: ,
: patterns.( ({
: ,
: p,
})),
});
.(selectedPattern, intent);
}
(
: ,
: ,
): <> {
(step. && !.(step., context)) {
context.(step., );
;
}
missingDeps = step..(
!context.(dep),
);
(missingDeps. > ) {
(
,
);
}
retryPolicy = step. || { : };
: | = ;
( attempt = ; attempt <= retryPolicy.; attempt++) {
{
result = ..(
step.,
step.,
);
context.(step., result);
;
} (error) {
lastError = error ;
(attempt < retryPolicy.) {
.(retryPolicy. || );
}
}
}
(
,
);
}
}
Performance Optimization
Command Performance Monitoring
export class CommandPerformanceMonitor {
private metrics = new Map<string, CommandMetrics>();
async measureCommand<T>(
commandName: string,
executor: () => Promise<T>,
): Promise<T> {
const start = performance.now();
const memBefore = process.memoryUsage();
try {
const result = await executor();
const end = performance.now();
const memAfter = process.memoryUsage();
this.recordMetrics(commandName, {
executionTime: end - start,
memoryDelta: memAfter.heapUsed - memBefore.heapUsed,
success: true,
});
return result;
} catch (error) {
const end = performance.now();
this.recordMetrics(commandName, {
executionTime: end - start,
memoryDelta: 0,
success: false,
: error ,
});
error;
}
}
(
: ,
: ,
): {
(!..(command)) {
..(command, (command));
}
metrics = ..(command)!;
metrics.(measurement);
(metrics.() > ) {
.(
,
);
}
}
(: ): {
metrics = ..(command);
(!metrics) {
();
}
{
command,
: metrics.(),
: metrics.(),
: metrics.(),
: metrics.(),
: metrics.(),
: .(metrics),
};
}
}
Smart Auto-completion
Intelligent Command Completion
export class IntelligentCompletion {
constructor(
private learningService: LearningService,
private commandRegistry: ModularCommandRegistry,
) {}
async generateCompletions(
partial: string,
context: CompletionContext,
): Promise<Completion[]> {
const completions: Completion[] = [];
const exactMatches = this.commandRegistry.findCommandsByPrefix(partial);
completions.push(
...exactMatches.map((cmd) => ({
value: cmd.name,
description: cmd.description,
type: "command",
confidence: 1.0,
})),
);
const learnedSuggestions = await this.learningService.suggestCommands(
partial,
context,
);
completions.push(...learnedSuggestions);
contextualSuggestions = .(
partial,
context,
);
completions.(...contextualSuggestions);
completions.( b. - a.).(, );
}
(
: ,
: ,
): <[]> {
: [] = [];
(context.) {
(partial.()) {
suggestions.({
: ,
: ,
: ,
: ,
});
}
}
(context.) {
(partial.() || partial.()) {
suggestions.({
: ,
: ,
: ,
: ,
});
}
}
suggestions;
}
}
Success Metrics
CLI Performance Targets
User Experience Improvements
const cliImprovements = {
before: {
commandResponse: "~500ms",
interactivity: "Basic command parsing",
workflows: "Manual command chaining",
suggestions: "Static help text",
},
after: {
commandResponse: "<200ms with caching",
interactivity: "Smart context-aware prompts",
workflows: "Automated multi-step execution",
suggestions: "Learning-based intelligent completion",
},
};
Related V3 Skills
v3-core-implementation - Core domain integration
v3-memory-unification - Memory-backed command caching
v3-swarm-coordination - CLI swarm management integration
v3-performance-optimization - CLI performance monitoring
Usage Examples
Complete CLI Modernization
Task("CLI modernization implementation",
"Implement modular commands, interactive prompts, and intelligent workflows",
"cli-hooks-developer")
Interactive Command Enhancement
claude-flow swarm init --interactive
claude-flow learning start --guided
claude-flow workflow create --from-intent "setup new project"