infinite-agents-public/.claude/commands/infinite.md

10 KiB

INFINITE AGENTIC LOOP COMMAND

Think deeply about this infinite generation task. You are about to embark on a sophisticated iterative creation process.

Variables:

spec_file: $ARGUMENTS output_dir: $ARGUMENTS count: $ARGUMENTS

ARGUMENTS PARSING: Parse the following arguments from "$ARGUMENTS":

  1. spec_file - Path to the markdown specification file
  2. output_dir - Directory where iterations will be saved
  3. count - Number of iterations (1-N or "infinite")

PHASE 1: SPECIFICATION ANALYSIS Read and deeply understand the specification file at spec_file. This file defines:

  • What type of content to generate
  • The format and structure requirements
  • Any specific parameters or constraints
  • The intended evolution pattern between iterations

Think carefully about the spec's intent and how each iteration should build upon previous work.

PHASE 2: OUTPUT DIRECTORY RECONNAISSANCE Thoroughly analyze the output_dir to understand the current state:

  • List all existing files and their naming patterns
  • Identify the highest iteration number currently present
  • Analyze the content evolution across existing iterations
  • Understand the trajectory of previous generations
  • Determine what gaps or opportunities exist for new iterations

PHASE 3: ITERATION STRATEGY Based on the spec analysis and existing iterations:

  • Determine the starting iteration number (highest existing + 1)
  • Plan how each new iteration will be unique and evolutionary
  • Consider how to build upon previous iterations while maintaining novelty
  • If count is "infinite", prepare for continuous generation until context limits

PHASE 4: PARALLEL AGENT COORDINATION Deploy multiple Sub Agents to generate iterations in parallel for maximum efficiency and creative diversity:

Sub-Agent Distribution Strategy:

  • For count 1-5: Launch all agents simultaneously
  • For count 6-20: Launch in batches of 5 agents to manage coordination
  • For "infinite": Launch waves of 3-5 agents, monitoring context and spawning new waves

Agent Assignment Protocol: Each Sub Agent receives:

  1. Spec Context: Complete specification file analysis
  2. Directory Snapshot: Current state of output_dir at launch time
  3. Iteration Assignment: Specific iteration number (starting_number + agent_index)
  4. Uniqueness Directive: Explicit instruction to avoid duplicating concepts from existing iterations
  5. Quality Standards: Detailed requirements from the specification

Agent Task Specification:

TASK: Generate iteration [NUMBER] for [SPEC_FILE] in [OUTPUT_DIR]

You are Sub Agent [X] generating iteration [NUMBER]. 

CONTEXT:
- Specification: [Full spec analysis]
- Existing iterations: [Summary of current output_dir contents]
- Your iteration number: [NUMBER]
- Assigned creative direction: [Specific innovation dimension to explore]

REQUIREMENTS:
1. Read and understand the specification completely
2. Analyze existing iterations to ensure your output is unique
3. Generate content following the spec format exactly
4. Focus on [assigned innovation dimension] while maintaining spec compliance
5. Create file with exact name pattern specified
6. Ensure your iteration adds genuine value and novelty

DELIVERABLE: Single file as specified, with unique innovative content

Parallel Execution Management:

  • Launch all assigned Sub Agents simultaneously using Task tool
  • Monitor agent progress and completion
  • Handle any agent failures by reassigning iteration numbers
  • Ensure no duplicate iteration numbers are generated
  • Collect and validate all completed iterations

PHASE 5: INFINITE MODE ORCHESTRATION For infinite generation mode, orchestrate continuous parallel waves:

Wave-Based Generation:

  1. Wave Planning: Determine next wave size (3-5 agents) based on context capacity
  2. Agent Preparation: Prepare fresh context snapshots for each new wave
  3. Progressive Sophistication: Each wave should explore more advanced innovation dimensions
  4. Context Monitoring: Track total context usage across all agents and main orchestrator
  5. Graceful Conclusion: When approaching context limits, complete current wave and summarize

Infinite Execution Cycle:

WHILE context_capacity > threshold:
    1. Assess current output_dir state
    2. Plan next wave of agents (size based on remaining context)
    3. Assign increasingly sophisticated creative directions
    4. Launch parallel Sub Agent wave
    5. Monitor wave completion
    6. Update directory state snapshot
    7. Evaluate context capacity remaining
    8. If sufficient capacity: Continue to next wave
    9. If approaching limits: Complete final wave and summarize

Progressive Sophistication Strategy:

  • Wave 1: Basic functional replacements with single innovation dimension
  • Wave 2: Multi-dimensional innovations with enhanced interactions
  • Wave 3: Complex paradigm combinations with adaptive behaviors
  • Wave N: Revolutionary concepts pushing the boundaries of the specification

Context Optimization:

  • Each wave uses fresh agent instances to avoid context accumulation
  • Main orchestrator maintains lightweight state tracking
  • Progressive summarization of completed iterations to manage context
  • Strategic pruning of less essential details in later waves

EXECUTION PRINCIPLES:

Quality & Uniqueness:

  • Each iteration must be genuinely unique and valuable
  • Build upon previous work while introducing novel elements
  • Maintain consistency with the original specification
  • Ensure proper file organization and naming

Parallel Coordination:

  • Deploy Sub Agents strategically to maximize creative diversity
  • Assign distinct innovation dimensions to each agent to avoid overlap
  • Coordinate timing to prevent file naming conflicts
  • Monitor all agents for successful completion and quality

Scalability & Efficiency:

  • Think deeply about the evolution trajectory across parallel streams
  • For infinite mode, optimize for maximum valuable output before context exhaustion
  • Use wave-based generation to manage context limits intelligently
  • Balance parallel speed with quality and coordination overhead

Agent Management:

  • Provide each Sub Agent with complete context and clear assignments
  • Handle agent failures gracefully with iteration reassignment
  • Ensure all parallel outputs integrate cohesively with the overall progression

ULTRA-THINKING DIRECTIVE: Before beginning generation, engage in extended thinking about:

Specification & Evolution:

  • The deeper implications of the specification
  • How to create meaningful progression across iterations
  • What makes each iteration valuable and unique
  • How to balance consistency with innovation

Parallel Strategy:

  • Optimal Sub Agent distribution for the requested count
  • How to assign distinct creative directions to maximize diversity
  • Wave sizing and timing for infinite mode
  • Context management across multiple parallel agents

Coordination Challenges:

  • How to prevent duplicate concepts across parallel streams
  • Strategies for ensuring each agent produces genuinely unique output
  • Managing file naming and directory organization with concurrent writes
  • Quality control mechanisms for parallel outputs

Infinite Mode Optimization:

  • Wave-based generation patterns for sustained output
  • Progressive sophistication strategies across multiple waves
  • Context capacity monitoring and graceful conclusion planning
  • Balancing speed of parallel generation with depth of innovation

Risk Mitigation:

  • Handling agent failures and iteration reassignment
  • Ensuring coherent overall progression despite parallel execution
  • Managing context window limits across the entire system
  • Maintaining specification compliance across all parallel outputs

PHASE 6: DASHBOARD & SCREENSHOT GENERATION

After all iterations are complete, automatically update the dashboard and generate screenshots:

Step 1: Update Dashboard Index

python3 generate_index.py

What this does:

  • Scans all demo directories for new files
  • Updates the demos object in index.html
  • Updates category counts and statistics
  • Preserves all styling and functionality

Step 2: Generate Screenshots for New Demos

Determine the category from output_dir:

  • threejs_viznpm run screenshots:threejs
  • sdg_viznpm run screenshots:sdg
  • d3_testnpm run screenshots:d3
  • mapbox_testnpm run screenshots:mapbox
  • claude_code_devtoolsnpm run screenshots:devtools
  • src or src_infinite or src_groupnpm run screenshots:ui

Execution:

# Run appropriate screenshot command based on output_dir
npm run screenshots:[category]

What this does:

  • Launches Playwright headless browser
  • Captures 1920x1080 viewport screenshots
  • Saves to screenshots/ directory with correct naming
  • Each screenshot takes ~2-4 seconds depending on complexity
  • Automatically handles rendering delays for WebGL/D3/animations

Step 3: Report Completion

Provide summary to user:

✅ Generation Complete!

Demos Created: [count] new iterations in [output_dir]
Dashboard Updated: index.html refreshed with new demos
Screenshots Generated: [count] screenshots captured

View your demos:
- Dashboard: http://localhost:8889/
- Latest demo: [path to latest iteration]

Total demos in project: [total count]

Screenshot Generation Details:

Important notes:

  • Requires HTTP server running on port 8889
  • Uses Playwright headless Chromium browser
  • Automatically detects category from output_dir path
  • Only generates screenshots for new demos (existing screenshots preserved)
  • Screenshot naming: path/to/file.html → path_to_file.html.png

Error Handling:

  • If server not running: Inform user to start python3 -m http.server 8889
  • If Playwright not installed: Skip screenshots, inform user to run npm install
  • If npm not available: Skip screenshots, continue with dashboard update only

Performance:

  • Dashboard update: <1 second
  • Screenshot generation: ~2-4 seconds per demo
  • Example: 5 new demos = ~10-20 seconds total

Optional: Skip Screenshots

If you want to skip screenshot generation (for speed), only run:

python3 generate_index.py

This updates the dashboard with emoji placeholders for the new demos.

Begin execution with deep analysis of these parallel coordination challenges and proceed systematically through each phase, leveraging Sub Agents for maximum creative output and efficiency. After all generations complete, automatically update the dashboard and generate screenshots to make the new demos immediately visible.