Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Automation Commands

rUv edited this page Aug 5, 2025 · 1 revision

๐Ÿค– Intelligent Automation Commands

Claude-Flow v2 introduces powerful automation capabilities that intelligently orchestrate AI agents for complex workflows. The automation system combines smart agent spawning, dependency management, and advanced coordination patterns.

๐ŸŽฏ Overview

The automation commands provide:

  • ๐Ÿง  Intelligent Agent Selection: Automatically spawns optimal agents based on task complexity
  • โšก MLE-STAR Workflow Engine: Machine Learning Engineering via Search and Targeted Refinement
  • ๐Ÿ”— Stream-JSON Chaining: Real-time agent-to-agent output piping
  • ๐ŸŽ›๏ธ Interactive & Non-Interactive Modes: Flexible execution patterns
  • ๐Ÿ“Š Real-time Progress Tracking: Visual task boards and status monitoring

๐Ÿ“‹ Command Reference

Core Automation Commands

# Auto-spawn agents based on task complexity
claude-flow automation auto-agent --task-complexity <level> [options]

# Smart agent spawning with specific requirements  
claude-flow automation smart-spawn --requirement <description> [options]

# Select optimal workflow for project type
claude-flow automation workflow-select --project-type <type> [options]

# Execute workflow from JSON/YAML files
claude-flow automation run-workflow <file> [options]

# MLE-STAR Machine Learning Engineering workflow (flagship)
claude-flow automation mle-star [options]

๐Ÿง  Auto-Agent Command

Automatically spawns optimal agents based on task complexity analysis.

Usage

claude-flow automation auto-agent --task-complexity <level> [options]

Complexity Levels

Level Agents Description
low/simple 2 agents 1 coordinator + 1 developer
medium/moderate 4 agents 1 coordinator + 2 developers + 1 researcher
high/complex 8 agents 2 coordinators + 3 developers + 2 researchers + 1 analyzer
enterprise/massive 15 agents 3 coordinators + 5 developers + 3 researchers + 2 analyzers + 2 testers

Example

# Enterprise-level task with optimal agent configuration
claude-flow automation auto-agent --task-complexity enterprise --swarm-id enterprise-api

Output

๐ŸŽฏ OPTIMAL AGENT CONFIGURATION:
  ๐Ÿค– coordinator: 3 agents
  ๐Ÿค– developer: 5 agents  
  ๐Ÿค– researcher: 3 agents
  ๐Ÿค– analyzer: 2 agents
  ๐Ÿค– tester: 2 agents
  ๐Ÿ“Š Total agents: 15

โœ… Auto-agent spawning completed
๐Ÿš€ 15 agents spawned and configured for enterprise complexity tasks

๐ŸŽฏ Smart-Spawn Command

Intelligently spawns agents based on specific requirements and provides recommendations.

Usage

claude-flow automation smart-spawn --requirement <description> [options]

Examples

# Web development project
claude-flow automation smart-spawn --requirement "web-development" --max-agents 8

# Data analysis workflow
claude-flow automation smart-spawn --requirement "data-analysis" --max-agents 6

# Enterprise API development
claude-flow automation smart-spawn --requirement "enterprise-api-development" --max-agents 12

Smart Recommendations

The system analyzes requirements and suggests optimal agent configurations:

๐Ÿง  Smart spawning agents based on requirements...
๐Ÿ“‹ Requirement: web-development
๐Ÿ”ข Max agents: 8

๐ŸŽฏ RECOMMENDED AGENT CONFIGURATION:
  ๐Ÿค– coordinator: 1 agents - Task orchestration
  ๐Ÿค– coder: 3 agents - Core development work
  ๐Ÿค– tester: 1 agents - Quality assurance
  ๐Ÿค– researcher: 2 agents - Information gathering
  ๐Ÿค– analyst: 1 agents - Data analysis

๐Ÿ“Š SUMMARY:
  ๐Ÿ“ Total recommended: 8 agents
  ๐Ÿ”ข Max allowed: 8 agents
  โœ… Configuration: Within limits

๐Ÿ”„ Workflow-Select Command

Selects and configures optimal workflows based on project type and priorities.

Usage

claude-flow automation workflow-select --project-type <type> --priority <priority>

Project Types

Type Phases Duration Agents
web-app planning โ†’ design โ†’ frontend โ†’ backend โ†’ testing โ†’ deployment 2-4 weeks coordinator(1) + developer(3) + tester(1) + researcher(1)
api specification โ†’ design โ†’ implementation โ†’ testing โ†’ documentation 1-2 weeks coordinator(1) + developer(2) + tester(1) + researcher(1)
data-analysis collection โ†’ cleaning โ†’ analysis โ†’ visualization โ†’ reporting 1-3 weeks coordinator(1) + researcher(2) + analyzer(2) + developer(1)
enterprise requirements โ†’ architecture โ†’ development โ†’ integration โ†’ testing โ†’ deployment โ†’ monitoring 2-6 months coordinator(2) + developer(5) + researcher(2) + analyzer(1) + tester(2)

Priority Optimizations

  • speed: +50% agents, parallel execution
  • quality: +100% testing, code review stages
  • cost: Minimal agents, sequential execution
  • balanced: Optimal speed/quality/cost ratio

Example

# API project optimized for speed
claude-flow automation workflow-select --project-type api --priority speed

๐Ÿ“‹ Run-Workflow Command

Executes workflows from JSON/YAML files with Claude CLI integration.

Usage

claude-flow automation run-workflow <workflow-file> [options]

Key Options

--claude                  # Enable Claude CLI integration for actual execution
--non-interactive         # Run in non-interactive mode (no prompts)
--output-format <format>  # Output format (text, json, stream-json)
--variables <json>        # Override workflow variables (JSON format)
--max-concurrency <n>     # Maximum concurrent tasks (default: 3)
--timeout <ms>            # Execution timeout in milliseconds
--verbose                 # Enable detailed logging

Example Workflow File

{
  "name": "API Development Workflow",
  "agents": [
    {"id": "architect", "type": "architect", "name": "System Designer"},
    {"id": "coder", "type": "coder", "name": "API Developer"},
    {"id": "tester", "type": "tester", "name": "Quality Engineer"}
  ],
  "tasks": [
    {
      "id": "design",
      "name": "Design API Architecture", 
      "assignTo": "architect",
      "description": "Create comprehensive API design"
    },
    {
      "id": "implement",
      "name": "Implement Endpoints",
      "assignTo": "coder", 
      "depends": ["design"],
      "description": "Build REST API endpoints"
    },
    {
      "id": "test",
      "name": "Write Tests",
      "assignTo": "tester",
      "depends": ["implement"], 
      "description": "Create comprehensive test suite"
    }
  ]
}

Execution Example

# Execute custom workflow with Claude integration
claude-flow automation run-workflow my-api-workflow.json --claude --non-interactive

๐Ÿง  MLE-STAR Workflow (Flagship)

The MLE-STAR (Machine Learning Engineering via Search and Targeted Refinement) workflow is Claude-Flow's flagship automation feature for ML engineering tasks.

Usage

claude-flow automation mle-star [options]

Key Features

  • ๐Ÿ” Web Search Phase: Finds state-of-the-art ML approaches and solutions
  • ๐Ÿ—๏ธ Foundation Building: Creates baseline models and training infrastructure
  • ๐ŸŽฏ Targeted Refinement: Focuses deep optimization on high-impact components
  • ๐Ÿ›๏ธ Ensemble Methods: Intelligent model combination beyond simple averaging
  • โœ… Comprehensive Validation: Rigorous testing with data leakage prevention

MLE-STAR Options

--claude                  # Enable Claude CLI integration (recommended)
--dataset <path>          # Path to dataset file (default: ./data/dataset.csv)
--target <column>         # Target column name (default: target)
--output <dir>            # Model output directory (default: ./models/)
--name <experiment>       # Experiment name for tracking
--search-iterations <n>   # Web search iterations (default: 3)
--refinement-iterations <n> # Refinement cycles (default: 5)
--max-agents <n>          # Maximum agents to spawn (default: 6)
--interactive             # Use interactive mode with master coordinator
--non-interactive         # Force non-interactive mode (default for MLE-STAR)
--output-format <format>  # Output format (stream-json enables chaining)
--chaining                # Enable stream-json chaining between agents
--no-chaining             # Disable stream-json chaining

MLE-STAR Phases

graph TB
    A[Web Search & Foundation Discovery] --> B[Foundation Model Building]
    B --> C[Ablation Analysis]  
    C --> D[Targeted Refinement]
    D --> E[Ensemble Creation]
    E --> F[Comprehensive Validation]
    F --> G[Production Deployment]
    
    subgraph "Phase 1: Parallel"
        A
        B
    end
    
    subgraph "Phase 2: Sequential"
        C
        D
    end
    
    subgraph "Phase 3: Parallel"
        E
        F
    end
Loading

Example Usage

# Basic MLE-STAR execution (non-interactive by default)
claude-flow automation mle-star --dataset sales-data.csv --target revenue --claude

# MLE-STAR with stream chaining
claude-flow automation mle-star --dataset data.csv --target price --claude --output-format stream-json

# Custom configuration with more iterations
claude-flow automation mle-star \
  --dataset customer-data.csv \
  --target churn \
  --output models/churn/ \
  --name "customer-churn-prediction" \
  --search-iterations 5 \
  --refinement-iterations 8 \
  --max-agents 8

MLE-STAR Output

๐Ÿง  MLE-STAR: Machine Learning Engineering via Search and Targeted Refinement
๐ŸŽฏ This is the flagship automation workflow for ML engineering tasks

๐Ÿ“‹ Workflow: MLE-STAR Machine Learning Engineering Workflow
๐Ÿ“„ Description: Complete Machine Learning Engineering workflow using MLE-STAR methodology
๐ŸŽ“ Methodology: Search โ†’ Foundation โ†’ Refinement โ†’ Ensemble โ†’ Validation
โฑ๏ธ  Expected Runtime: 2-4 hours

๐Ÿ“Š Configuration:
  Dataset: customer-data.csv
  Target: churn
  Output: models/churn/
  Claude Integration: Enabled
  Execution Mode: Non-interactive (default)
  Stream Chaining: Enabled

๐Ÿ’ก Running in non-interactive mode: Each agent will execute independently
๐Ÿ”— Stream chaining enabled: Agent outputs will be piped to dependent agents

๐Ÿ“‹ Executing 6 tasks in 3 phases...

๐Ÿ”„ Phase 1: 2 concurrent tasks
๐Ÿ”„ Phase 2: 2 concurrent tasks  
๐Ÿ”„ Phase 3: 2 concurrent tasks

๐ŸŽ‰ MLE-STAR workflow completed successfully!
๐Ÿ“Š Results: 6/6 tasks completed
โฑ๏ธ  Duration: 2h 15m 30s
๐Ÿ†” Execution ID: workflow-exec-1704067200000

๐Ÿ”— Stream-JSON Chaining

When --output-format stream-json is enabled, agents automatically pipe their outputs to dependent agents:

# Agent A generates stream-json output
claude --print --output-format stream-json "Task 1"
     โ†“ (stdout piped automatically)
# Agent B receives Agent A's output and continues  
claude --print --input-format stream-json --output-format stream-json "Task 2"
     โ†“ (stdout piped automatically)
# Agent C completes the chain
claude --print --input-format stream-json "Task 3"

Chaining Indicators

Look for these console messages:

  • ๐Ÿ”— Enabling stream chaining from task1 to task2
  • ๐Ÿ”— Chaining: Piping output from previous agent to Agent Name

๐ŸŽ›๏ธ Execution Modes

Non-Interactive Mode (Default for MLE-STAR)

  • Each agent spawns independently
  • Outputs are processed automatically
  • No user prompts or intervention required
  • Ideal for CI/CD and automation pipelines

Interactive Mode

  • Single master coordinator manages all agents
  • User can interact during execution
  • Real-time decision making possible
  • Better for exploratory workflows

Mode Selection

# Force non-interactive (default for automation commands)
--non-interactive

# Use interactive mode with master coordinator
--interactive

# Auto-detect based on environment
# (no flag = non-interactive for automation commands)

๐Ÿ“Š Progress Tracking

All automation commands provide real-time progress tracking:

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                    ๐Ÿค– CONCURRENT TASK STATUS                   โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ โ ‹ RUNNING (3 agents):                                          โ•‘
โ•‘   ๐Ÿ”ฌ Analyze Dataset              [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘] 2m 15s          โ•‘
โ•‘   ๐Ÿ’ป Build Foundation Model       [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘] 1m 45s          โ•‘
โ•‘   โšก Optimize Performance          [โ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘] 45s             โ•‘
โ•‘ โœ… COMPLETED (2):                                              โ•‘
โ•‘   โœ“ Web Search Research                          3m 20s        โ•‘
โ•‘   โœ“ Data Quality Analysis                        2m 55s        โ•‘
โ•‘ โณ QUEUED: 1 tasks waiting                                     โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ ๐Ÿ“Š Progress: 67% (4/6) โ”‚ โšก Active: 3 โ”‚ โŒ Failed: 0          โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ”ง Advanced Configuration

Custom Workflow Templates

Create reusable workflow templates for common patterns:

# Create template from successful workflow
claude-flow automation export-template --workflow-id exec-123 --name "api-development"

# Apply template to new project
claude-flow automation apply-template api-development --variables '{"project":"my-api"}'

Error Handling & Recovery

  • fail-fast: Stop on first error
  • continue: Continue despite errors
  • retry: Automatic retry with exponential backoff

Resource Management

  • Max Concurrency: Control parallel task execution
  • Timeout Management: Per-task and global timeouts
  • Memory Limits: Prevent resource exhaustion
  • Load Balancing: Distribute tasks across available resources

๐ŸŽฏ Best Practices

1. Start Simple

# Begin with basic complexity assessment
claude-flow automation auto-agent --task-complexity medium

2. Use Appropriate Modes

# CI/CD pipelines: non-interactive
claude-flow automation mle-star --dataset data.csv --target price --claude --non-interactive

# Exploratory work: interactive  
claude-flow automation mle-star --dataset data.csv --target price --claude --interactive

3. Enable Stream Chaining for Complex Workflows

# Complex ML pipelines benefit from chaining
claude-flow automation mle-star --dataset data.csv --target price --claude --output-format stream-json

4. Monitor Resource Usage

# Use appropriate agent counts
claude-flow automation smart-spawn --requirement "simple-script" --max-agents 3
claude-flow automation smart-spawn --requirement "enterprise-system" --max-agents 12

5. Leverage Templates and Reusability

# Create reusable workflows for common patterns
claude-flow automation workflow-select --project-type api --priority speed > api-speed.json
claude-flow automation run-workflow api-speed.json --claude --non-interactive

๐Ÿ“ˆ Performance Benefits

  • 84.8% SWE-Bench Solve Rate: Superior problem-solving through intelligent coordination
  • 2.8-4.4x Speed Improvement: Parallel execution and optimized task distribution
  • 32.3% Token Reduction: Efficient coordination reduces redundant operations
  • Automatic Optimization: Self-tuning based on task complexity and resource availability

๐Ÿ”— Integration

CI/CD Integration

# GitHub Actions example
- name: Run MLE-STAR Pipeline
  run: |
    claude-flow automation mle-star \
      --dataset ${{ inputs.dataset }} \
      --target ${{ inputs.target }} \
      --claude \
      --non-interactive \
      --output-format stream-json

Docker Integration

RUN npm install -g claude-flow@alpha
CMD ["claude-flow", "automation", "mle-star", "--claude", "--non-interactive"]

๐Ÿ”— Related Documentation

๐Ÿš€ Next Steps: Try the MLE-STAR workflow on your dataset: claude-flow automation mle-star --dataset your-data.csv --target your-target --claude

Clone this wiki locally