Skip to content

Add config validation and smart naming to generate command #100

@mawburn

Description

@mawburn

Feature Request

Problem Description

When using claude-swarm generate or similar commands, the generated configuration files often contain errors that prevent the swarm from starting properly. Additionally, the command creates files with random names instead of following the expected naming convention.

Current Behavior

  1. Configuration Validation Issues

    • Generated configs frequently contain circular dependencies
    • References to non-existent instances are common
    • No validation occurs during generation
    • Errors are revealed one at a time, requiring multiple runs to discover all issues

    Example errors encountered:

    $ claude-swarm
    Starting Claude Swarm from claude-swarm.yml...
    Circular dependency detected: lead_developer -> rails_optimizer -> lead_developer
    
    # After fixing the circular dependency...
    $ claude-swarm
    Starting Claude Swarm from claude-swarm.yml...
    Instance 'lead_developer' has connection to unknown instance 'distribution_expert'
    
    # After fixing the missing instance...
    $ claude-swarm
    Starting Claude Swarm from claude-swarm.yml...
    Instance 'rails_optimizer' has connection to unknown instance 'performance_analyst'
  2. File Naming Issues

    • Generated files have random names (e.g., random-name.yml) instead of claude-swarm.yml
    • No check for existing claude-swarm.yml files
    • Inconsistent with expected naming conventions

Proposed Solution

Enhance the generate command with:

  1. Comprehensive Configuration Validation

    • Validate all issues at once during generation
    • Check for:
      • Circular dependencies (all cycles, not just the first one found)
      • Missing instance references
      • Duplicate instance names
      • Invalid configuration syntax
    • Display all validation errors in a single report
  2. Smart File Naming

    • Default to claude-swarm.yml for generated files
    • If claude-swarm.yml exists, use incremental naming:
      • claude-swarm-1.yml
      • claude-swarm-2.yml
      • etc.
    • Option to specify custom filename via flag

Expected Behavior

$ claude-swarm generate
Generating swarm configuration...

Validation Report:
❌ 3 issues found:
   1. Circular dependency: lead_developer -> rails_optimizer -> lead_developer
   2. Unknown instance reference: 'distribution_expert' (referenced by lead_developer)
   3. Unknown instance reference: 'performance_analyst' (referenced by rails_optimizer)

Configuration not saved due to validation errors.
Would you like to generate anyway? (y/N)

Or when successful:

$ claude-swarm generate
Generating swarm configuration...
✓ Configuration validated successfully
✓ No circular dependencies detected
✓ All instance references verified
✓ Saved to claude-swarm.yml

Benefits

  • Improved Developer Experience: See all configuration errors at once instead of discovering them one by one
  • Faster Iteration: Fix all issues in a single pass rather than multiple trial-and-error cycles
  • Reduced Debugging Time: No need to repeatedly run claude-swarm to find each error
  • Consistent Workflow: Predictable file naming makes it easier to manage configurations
  • Better Onboarding: New users won't be confused by random file names or cryptic runtime errors

Additional Context

Currently, the iterative nature of error discovery is particularly frustrating when dealing with configurations. I often need to:

  1. Run claude-swarm
  2. See first error
  3. Fix it manually
  4. Run claude-swarm again
  5. See next error
  6. Repeat until all errors are fixed

This would be particularly helpful for users who are new to claude-swarm or those generating complex configurations with multiple interconnected agents. The validation could use the same logic that's already implemented for runtime checks, just applied during the generation phase with comprehensive reporting.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions