# Quick Start Guide - Infinite Variant 6

Get started with the Stateful Infinite Loop in 5 minutes.

## Installation

```bash
cd infinite_variants/infinite_variant_6
```

That's it! No dependencies required (Python 3.6+ already on your system).

## Your First Run

### 1. Run a Simple Generation

```bash
/infinite-stateful specs/example_spec.md my_output 3
```

This will:
- Generate 3 interactive visualizations
- Save them to `my_output/`
- Create state file in `.claude/state/`

### 2. Check Status

```bash
/status
```

You'll see:
- Your run ID (e.g., `run_20250310_143022`)
- Progress (3 of 3)
- Consistency score (1.00 = perfect)

### 3. Try Interrupting and Resuming

```bash
# Start a longer run
/infinite-stateful specs/example_spec.md outputs 10

# Stop it after a few iterations (Ctrl+C or context limit)

# Check what completed
/status run_20250310_143022

# Resume exactly where you left off
/resume run_20250310_143022
```

## Common Commands

### Generate with URL Strategy

```bash
# Create URL strategy
cat > specs/my_urls.json << 'URLS'
{
  "foundation": [
    "https://observablehq.com/@d3/learn-d3"
  ],
  "intermediate": [
    "https://observablehq.com/@d3/force-directed-graph"
  ]
}
URLS

# Run with strategy
/infinite-stateful specs/example_spec.md outputs 5 specs/my_urls.json
```

### Check State Consistency

```bash
# Using command
/status run_20250310_143022

# Using validator script
./validators/check_state_consistency.sh run_20250310_143022

# Using Python utility
python state_manager.py validate run_20250310_143022
```

### Recover from Issues

```bash
# If files were deleted or state is corrupted
/reset-state run_20250310_143022 --rebuild

# Verify the rebuild worked
/status run_20250310_143022
```

## Understanding Output

### Generated Files

```
my_output/
├── visualization_1.html  # Self-contained HTML
├── visualization_2.html
└── visualization_3.html

.claude/state/
└── run_20250310_143022.json  # State file
```

### What's in the State File?

```json
{
  "run_id": "run_20250310_143022",
  "completed_iterations": 3,
  "used_urls": ["https://..."],
  "validation": {
    "consistency_score": 1.0
  }
}
```

## Key Features Demo

### 1. Resume After Interruption

```bash
# This run will be interrupted
/infinite-stateful specs/example_spec.md outputs 100

# ... context limit reached at iteration 47 ...

# Later, resume
/resume run_20250310_143022
# Continues from iteration 48!
```

### 2. No URL Duplicates

```bash
# First run uses some URLs
/infinite-stateful specs/example_spec.md outputs 10 specs/urls.json

# Resume uses only NEW URLs
/resume run_20250310_143022
# Never repeats a URL!
```

### 3. Self-Consistency Validation

```bash
# Check state health
/status run_20250310_143022

# You'll see 6 validation checks:
# ✓ Schema Validation: PASS
# ✓ File Count: PASS
# ✓ Iteration Records: PASS
# ✓ URL Uniqueness: PASS
# ✓ File Existence: PASS
# ✓ Timestamp Validity: PASS
# Consistency Score: 1.00 (100%)
```

## Troubleshooting

### "State file not found"

```bash
# List available runs
/status

# Use the correct run_id
/resume run_20250310_143022
```

### "Low consistency score"

```bash
# Rebuild state from files
/reset-state run_20250310_143022 --rebuild
```

### "Output directory already exists"

That's fine! The system will:
- Scan existing files
- Continue from next iteration number
- Not overwrite anything

## Next Steps

1. **Read Full Docs**: See `README.md` for complete features
2. **Understand State**: See `.claude/state/README.md`
3. **Deep Dive**: See `docs/state_management_guide.md` (21KB guide)
4. **Custom Specs**: Create your own in `specs/`
5. **Extend System**: Add custom commands in `.claude/commands/`

## Quick Reference

| Task | Command |
|------|---------|
| Start run | `/infinite-stateful <spec> <output> <count>` |
| List runs | `/status` |
| Check run | `/status <run_id>` |
| Resume | `/resume <run_id>` |
| Validate | `./validators/check_state_consistency.sh <run_id>` |
| Rebuild | `/reset-state <run_id> --rebuild` |

## Help

- **README.md** - Full feature documentation
- **CLAUDE.md** - System architecture and principles
- **docs/state_management_guide.md** - Complete usage guide
- **MANIFEST.md** - All files explained

## What Makes This Special?

1. **Never lose progress** - Resume from any interruption
2. **Never duplicate URLs** - State tracks everything
3. **Self-healing** - Rebuild state from files if corrupted
4. **Self-validating** - 6 independent checks ensure reliability
5. **Production-ready** - Used in real infinite generation scenarios

Start generating! 🚀
