16 KiB
CLAUDE.md
This file provides guidance to Claude Code when working with the Configuration-Driven Infinite Loop Orchestration variant.
Project Overview
This is Variant 5 of the Infinite Agents project, implementing a configuration-driven orchestration system with chain prompting patterns.
Unlike previous variants with hardcoded parameters, this variant externalizes all orchestration settings to JSON configuration files, enabling flexible, reproducible, and production-ready infinite loop execution.
Core Innovation
Configuration-Driven Architecture
All orchestration parameters are externalized to configuration files:
- Defaults in
.claude/config/defaults.json - Profiles in
.claude/config/profiles/{profile}.json - Custom configurations via file paths or inline JSON
- Hierarchical merging: defaults → profile → custom → runtime overrides
Chain Prompting Implementation
Implements chain prompting pattern from Anthropic documentation:
- Workflow decomposed into 7 focused stages
- State passed between stages via XML tags
- Each stage has single-task goal for maximum attention
- Self-correction loops for quality enforcement
- Complete traceability through workflow audit trail
Key Commands
Primary Command: /project:infinite-config
Main orchestration command implementing full chain prompting workflow.
Syntax:
/project:infinite-config <spec_path> <output_dir> <count> [profile] [config_overrides]
Arguments:
spec_path: Path to specification fileoutput_dir: Output directory (relative to project root)count: Number of iterations or "infinite"profile(optional): Configuration profile (development|production|research)config_overrides(optional): Path to custom config JSON or inline JSON
Examples:
# Use defaults
/project:infinite-config specs/example_spec.md output 5
# Use development profile
/project:infinite-config specs/example_spec.md output_dev 3 development
# Use production profile
/project:infinite-config specs/example_spec.md output_prod 20 production
# Use custom config file
/project:infinite-config specs/example_spec.md output 10 custom examples/custom_config.json
# Use inline overrides
/project:infinite-config specs/example_spec.md output 5 development '{"orchestration":{"max_parallel_agents":8}}'
# Infinite mode
/project:infinite-config specs/example_spec.md infinite_output infinite production
Utility Commands
Configuration Validation:
/project:validate-config [config_path] [profile]
Validates configuration files with:
- Schema validation (types, required fields, constraints)
- Semantic validation (logical consistency, value reasonableness)
- Cross-field validation (relationship checks, compatibility)
Interactive Configuration:
/project:configure [action] [profile] [output_path]
Actions:
create- Create new custom configuration interactivelyedit- Edit existing configurationcompare- Compare two configurationsoptimize- Optimize for use case (speed, quality, scale, development, research)merge- Merge multiple configurations
Configuration Profiles
Development Profile
File: .claude/config/profiles/development.json
Optimized for:
- Quick iteration and testing
- Debugging and learning
- Quality over speed
Settings:
- Small batches (3 iterations)
- 2 parallel agents
- Verbose logging (debug level)
- Review stage enabled
- Lower uniqueness threshold (0.7)
- Max 10 iterations
- Web enhancement enabled with caching
Use when:
- Testing new specifications
- Debugging issues
- Learning the system
- Developing new features
Production Profile
File: .claude/config/profiles/production.json
Optimized for:
- Scale and throughput
- Efficiency and performance
- Minimal overhead
Settings:
- Large batches (10 iterations)
- 5 parallel agents
- Minimal logging (warn level)
- Review stage disabled
- High uniqueness threshold (0.9)
- Max 1000 iterations
- Web enhancement enabled, no caching
- Progressive sophistication enabled
Use when:
- Running large batches
- Production deployments
- Performance is critical
- Quality thresholds are well-tested
Research Profile
File: .claude/config/profiles/research.json
Optimized for:
- Maximum quality
- Exploration and experimentation
- Comprehensive analysis
Settings:
- Medium batches (5 iterations)
- 3 parallel agents
- Extensive logging (debug level, verbose)
- Review stage enabled
- Very high uniqueness threshold (0.95)
- Max 50 iterations
- Extensive web priming (8 URLs)
- Cross-iteration learning enabled
- Additional chain prompting stages (11 total)
Use when:
- Exploring new domains
- Maximum quality needed
- Understanding system behavior
- Experimenting with techniques
Chain Prompting Workflow
The system implements a 7-stage chain prompting workflow (configurable):
Stage 1: Load Configuration
Single-Task Goal: Load and parse all configuration sources
Loads configurations in hierarchical order:
- defaults.json
- profile.json (if specified)
- custom config file (if provided)
- inline JSON overrides (if provided)
Stage 2: Validate Configuration
Single-Task Goal: Validate all configurations against schema
Validates:
- Schema compliance (types, required fields, constraints)
- Value ranges and enum values
- String patterns
Stage 3: Merge Configuration
Single-Task Goal: Merge validated configurations hierarchically
Deep merges all configurations, later values override earlier ones.
Stage 4: Analyze Specification
Single-Task Goal: Deeply analyze the specification file
Extracts:
- Content requirements
- Quality standards
- Naming conventions
- Technical requirements
Stage 5: Plan Execution
Single-Task Goal: Create detailed execution plan
Plans:
- Execution mode (batch vs infinite)
- Wave structure and agent assignments
- Web enhancement strategy
- Resource allocation
Stage 6: Execute Generation
Single-Task Goal: Execute parallel agent generation
Executes:
- Initial web priming (if enabled)
- Parallel agent waves
- Error handling and retries
- Limit checking
Stage 7: Validate Output (Optional)
Single-Task Goal: Validate generated outputs
Validates:
- Spec compliance
- Uniqueness thresholds
- File size limits
- Code quality
Enables self-correction loops if validation fails.
Configuration System
Configuration Sections
orchestration - Parallel execution settings
max_parallel_agents(1-10): Simultaneous sub-agentsbatch_size(1-50): Iterations per batchinfinite_mode_wave_size(1-20): Iterations per wavecontext_budget_per_agent(10000-200000): Token budgetagent_timeout_ms(30000-600000): Execution timeoutenable_progressive_sophistication(boolean): Increase complexity over time
generation - Output file settings
output_directory: Save locationnaming_pattern: File naming with placeholdersfile_format: html|markdown|json|textinclude_metadata(boolean): Embed metadatametadata_format: html_comment|yaml_frontmatter|json_header
quality - Quality control
min_uniqueness_threshold(0.0-1.0): Required uniquenessenable_validation(boolean): Validate outputsenable_review_stage(boolean): Add review stepmax_retry_attempts(0-5): Retry failuresrequire_spec_compliance_check(boolean): Validate spec compliance
web_enhancement - Web learning
enabled(boolean): Enable web-enhanced generationinitial_priming_urls(0-10): Initial knowledge primingurls_per_iteration(0-5): URLs per iterationprogressive_difficulty(boolean): Progressive URL difficultyenable_web_search_fallback(boolean): Search when exhaustedcache_web_content(boolean): Cache fetched contentweb_fetch_timeout_ms(5000-60000): Fetch timeout
logging - Logging configuration
level: debug|info|warn|errorlog_agent_outputs(boolean): Log sub-agent outputslog_web_fetches(boolean): Log web operationslog_config_loading(boolean): Log config loadingverbose(boolean): Maximum detail
chain_prompting - Chain prompting settings
enabled(boolean): Enable chain promptingstages(array): Workflow stages to executeenable_self_correction(boolean): Enable self-correctionpass_state_via_xml(boolean): Use XML for state
features - Feature flags
enable_url_strategy(boolean): URL strategy filesenable_theme_evolution(boolean): Evolve themesenable_cross_iteration_learning(boolean): Learn from previousenable_automatic_indexing(boolean): Auto-generate indexes
limits - Safety limits
max_iterations: Maximum iterationsmax_file_size_kb: Maximum file sizemax_total_output_mb: Maximum total outputwarn_at_iteration: Warning threshold
Configuration Hierarchy
Configurations merge in order (later overrides earlier):
.claude/config/defaults.json(base).claude/config/profiles/{profile}.json(if specified)- Custom config file (if path provided)
- Inline JSON overrides (if provided)
Example:
# This uses: defaults ← production ← custom_config.json ← inline override
/project:infinite-config specs/example_spec.md output 20 production examples/custom_config.json '{"logging":{"verbose":true}}'
Typical Workflows
Workflow 1: Quick Test (Development)
# Validate development profile
/project:validate-config development
# Run 3 iterations for testing
/project:infinite-config specs/example_spec.md test_output 3 development
Workflow 2: Production Batch
# Validate production profile
/project:validate-config production
# Run 50 iterations
/project:infinite-config specs/example_spec.md prod_output 50 production
Workflow 3: Custom Configuration
# Create custom configuration interactively
/project:configure create production my_custom.json
# Validate it
/project:validate-config my_custom.json
# Run with custom config
/project:infinite-config specs/example_spec.md output 20 custom my_custom.json
Workflow 4: Optimization
# Create speed-optimized configuration
/project:configure optimize speed
# Or quality-optimized
/project:configure optimize quality
# Compare configurations
/project:configure compare development production
Workflow 5: Research Exploration
# Use research profile for maximum quality
/project:infinite-config specs/example_spec.md research_output 20 research
# Check results, then continue
/project:infinite-config specs/example_spec.md research_output 30 research
Best Practices
For Claude Code Agent
-
Always validate configurations before running
- Use
/project:validate-configto check - Fix errors before executing
- Use
-
Choose appropriate profile for task
- Development: testing, debugging, learning
- Production: scale, efficiency
- Research: quality, exploration
-
Use inline overrides for one-off changes
- Don't create new config file for single parameter change
- Use inline JSON for temporary overrides
-
Monitor resource usage
- Check context budget consumption
- Monitor output directory size
- Watch for limit warnings
-
Start small, scale up
- Test with small batches first
- Validate quality before large runs
- Use development profile for initial tests
-
Leverage chain prompting stages
- Each stage focuses on single task
- State passes via XML tags
- Self-correction enabled for quality
For Specifications
-
Reference configuration in spec
- Specs should note configurable parameters
- Guide users to appropriate settings
-
Set reasonable defaults
- Specs work with default configuration
- Optimize for common use cases
-
Document quality thresholds
- What uniqueness threshold is appropriate?
- Which validation checks are needed?
File Structure
infinite_variant_5/
├── .claude/
│ ├── commands/ # Slash commands
│ │ ├── infinite-config.md
│ │ ├── validate-config.md
│ │ └── configure.md
│ ├── config/ # Configuration system
│ │ ├── defaults.json
│ │ ├── schema.json
│ │ └── profiles/
│ │ ├── development.json
│ │ ├── production.json
│ │ └── research.json
│ └── settings.json
├── specs/ # Specifications
│ └── example_spec.md
├── examples/ # Example configs
│ └── custom_config.json
├── docs/ # Documentation
│ └── configuration_guide.md
├── README.md
└── CLAUDE.md # This file
Troubleshooting
Configuration Errors
Issue: Configuration validation fails
Solution:
- Run
/project:validate-configto see specific errors - Check schema.json for valid values
- Compare to working profile configurations
- Use
/project:configure editto fix interactively
Execution Failures
Issue: Generation fails during execution
Solution:
- Check configured timeouts (agent_timeout_ms)
- Verify output directory is writable
- Check resource limits (max_iterations, max_total_output_mb)
- Enable verbose logging to diagnose
- Try smaller batch_size
Uniqueness Issues
Issue: Iterations too similar
Solution:
- Increase
min_uniqueness_threshold - Enable
enable_theme_evolution - Check specification diversity requirements
- Review existing iterations for patterns
Performance Issues
Issue: Execution too slow
Solution:
- Increase
max_parallel_agents(up to 10) - Disable
enable_review_stage - Reduce logging level to
warnorerror - Disable web enhancement if not needed
- Use production profile as baseline
Web Enhancement Issues
Issue: Web fetches failing or slow
Solution:
- Check
web_fetch_timeout_msis sufficient - Enable
enable_web_search_fallback - Reduce
urls_per_iteration - Enable
cache_web_contentto reuse fetches
Advanced Usage
Custom Chain Prompting Stages
Modify chain_prompting.stages array to customize workflow:
{
"chain_prompting": {
"stages": [
"load_config",
"validate_config",
"merge_config",
"analyze_spec",
"research_existing", // Custom stage
"plan_execution",
"execute_generation",
"review_output", // Optional stage
"refine_output", // Custom stage
"validate_output",
"analyze_results" // Custom stage
]
}
}
Progressive Sophistication
When enable_progressive_sophistication is true, infinite mode increases complexity:
- Wave 1: Basic implementations
- Wave 2: Intermediate complexity
- Wave 3: Advanced techniques
- Wave 4+: Expert level
Configure wave size with infinite_mode_wave_size.
Cross-Iteration Learning
Enable with features.enable_cross_iteration_learning:
- Later iterations learn from earlier ones
- Requires additional context budget
- Improves quality but increases execution time
Automatic Indexing
Enable with features.enable_automatic_indexing:
- Generates index.html after each wave
- Lists all generated iterations
- Provides navigation and preview
Integration with Other Variants
This configuration system can be adapted to other variants:
- Variant 1 (Original): Add configuration layer
- Variant 2 (Web-Enhanced): Already supports web enhancement config
- Variant 3 (State-Based): Add state management config section
- Variant 4 (Specialized Agents): Add agent role configurations
Further Reading
README.md- Overview and quick startdocs/configuration_guide.md- Complete configuration reference.claude/commands/infinite-config.md- Full command documentation.claude/commands/validate-config.md- Validation documentation.claude/commands/configure.md- Interactive utility documentation.claude/config/schema.json- Complete schema referencespecs/example_spec.md- Example specification
Notes
- Configuration files use JSON format with JSON Schema validation
- All file paths should be relative to project root
- Inline JSON overrides must be valid JSON strings
- Chain prompting stages execute sequentially
- Self-correction loops respect
max_retry_attempts - Context budget managed across all stages and agents