W Ralph Batch

Batch process multiple Ralph candidates sequentially, or generate an overnight script for unattended execution. Supports Diagnost…

danizeeincali updated 1mo ago
Claude CodeGeneric
View source ↗
# /w-ralph-batch

Batch process multiple Ralph candidates sequentially, or generate an overnight script for unattended execution.
Supports Diagnostic→Fix flow for automated QA verification.

## Usage

/w-ralph-batch # Interactive mode - process one by one /w-ralph-batch --script # Generate overnight batch script /w-ralph-batch --priority P1 # Only process P1 candidates /w-ralph-batch --all # Process all ready candidates sequentially /w-ralph-batch --phased # Execute by priority (P1 → P2 → P3) /w-ralph-batch --diagnostics # Run all diagnostics first, then fixes if needed


---

## ⚠️ MANDATORY FIRST ACTION

Use TodoWrite NOW to create todos for ALL phases:
1. Load candidates from .claude/ralph-candidates.md
2. Filter by status (ready) and priority (if specified)
3. Select execution mode
4. Execute batch or generate script
5. Update candidate statuses
6. Generate summary report

⚠️ VIOLATION: Any action before TodoWrite = restart workflow

---

## Rules

- NEVER skip checkpoints - each requires user confirmation
- NEVER execute without reviewing candidate list first
- NEVER skip status updates after completion
- ALWAYS generate summary report at end
- For diagnostics: ALWAYS run RC-D### before paired RC-F###

---

## Execution Modes

| Mode | Description | Use Case |
|------|-------------|----------|
| Interactive | Process one by one with verification | Supervised execution |
| Script | Generate overnight-work.sh | Unattended overnight runs |
| Phased | Execute by priority order | Structured batch processing |
| All | Process all ready candidates | Quick batch run |
| Diagnostics | Run diagnostics first, fixes only if needed | QA verification |

---

## Candidate Types

| ID Format | Type | Purpose |
|-----------|------|---------|
| RC-### | General | Standard Ralph candidates |
| RC-D### | Diagnostic | Verify patterns/code exists |
| RC-F### | Fix | Restore code if diagnostic fails |

**Diagnostic→Fix Flow:**
1. Run RC-D### diagnostic command
2. If STATUS: PASS → log "VERIFIED" → skip paired RC-F###
3. If STATUS: FAIL → run RC-F### fix → re-run RC-D### to verify
4. Report final status

---

## Execution Protocol

### ⛔ CHECKPOINT 0: Load & Filter Candidates
**REQUIRED OUTPUT:**
- Candidates file: .claude/ralph-candidates.md
- Total candidates: _____
- Ready candidates: _____
- Ready diagnostics (RC-D###): _____
- Ready fixes (RC-F###): _____
- Filtered candidates (if priority specified): _____

**General Candidates:**
| ID | Priority | Name | Completion Tests | Status |
|----|----------|------|------------------|--------|
| RC-___ | P_ | _____ | ___ tests | ready |

**Diagnostics & Fixes (if any):**
| Diagnostic | Verifies | Paired Fix | Status |
|------------|----------|------------|--------|
| RC-D___ | _____ | RC-F___ | ready |

**USER GATE:** Use AskUserQuestion
- Question: "Found [N] ready candidates ([X] diagnostics, [Y] fixes, [Z] general). Select execution mode:"
- Options: ["Interactive (one by one)", "Generate script", "Phased (P1→P2→P3)", "Diagnostics first", "All at once"]

STOP and wait for user response.

---

### ⛔ CHECKPOINT 1: Mode Configuration

**For Interactive Mode:**
- Processing order: by priority (P1 first) or by ID
- Pause between candidates: yes/no
- Auto-archive on success: yes/no

**For Script Mode:**
- Script path: ./overnight-ralph.sh
- Max iterations per candidate: 50 (default)
- Include status updates: yes/no
- Log output to file: yes/no

**For Phased Mode:**
- Phase 1 (P1 Critical): [list IDs]
- Phase 2 (P2 Important): [list IDs]
- Phase 3 (P3 Nice-to-have): [list IDs]
- Completion promises: <promise>P1_COMPLETE</promise>, etc.

**For Diagnostics Mode:**
- Diagnostic pairs to process: [list RC-D### → RC-F### pairs]
- Run fixes only on failure: yes (default)
- Re-verify after fix: yes (default)
- Processing order: by diagnostic ID

**USER GATE:** Use AskUserQuestion
- Question: "Configuration ready. Proceed with [mode]?"
- Options: ["Start execution", "Adjust config", "Change mode"]

STOP and wait for user response.

---

### ⛔ CHECKPOINT 2: Execute/Generate

**Interactive Mode - Per Candidate:**
1. Load candidate spec
2. Verify completion tests
3. Execute Ralph loop (max 50 iterations)
4. Run completion tests
5. Update status (complete/in-progress/blocked)
6. Move to next candidate

**Script Mode - Generate overnight-work.sh:**
```bash
#!/bin/bash
# Ralph Batch - Generated [DATE]
# Candidates: [IDs]
# Total: [N] candidates

set -e  # Exit on error
LOG_FILE="ralph-batch-$(date +%Y%m%d-%H%M%S).log"

echo "Starting Ralph Batch Processing..." | tee -a $LOG_FILE
echo "Start time: $(date)" | tee -a $LOG_FILE

# RC-001: [Name]
echo "Processing RC-001: [Name]..." | tee -a $LOG_FILE
claude -p "/w-ralph-this '[spec]'
Output <promise>RC001_DONE</promise> when all tests pass.
Max iterations: 50" 2>&1 | tee -a $LOG_FILE
echo "RC-001 complete: $(date)" | tee -a $LOG_FILE

# RC-002: [Name]
echo "Processing RC-002: [Name]..." | tee -a $LOG_FILE
claude -p "/w-ralph-this '[spec]'
Output <promise>RC002_DONE</promise> when all tests pass.
Max iterations: 50" 2>&1 | tee -a $LOG_FILE
echo "RC-002 complete: $(date)" | tee -a $LOG_FILE

echo "Ralph Batch Complete: $(date)" | tee -a $LOG_FILE
echo "Results logged to: $LOG_FILE"

Phased Mode - Sequential Priority Execution:

# Phase 1: P1 Critical
Processing RC-001, RC-005...
Output <promise>P1_COMPLETE</promise>

# Phase 2: P2 Important
Processing RC-002, RC-003...
Output <promise>P2_COMPLETE</promise>

# Phase 3: P3 Nice-to-have
Processing RC-004...
Output <promise>P3_COMPLETE</promise>

Output <promise>ALL_PHASES_COMPLETE</promise>

Diagnostics Mode - Verify & Fix Flow: For each RC-D### diagnostic:

┌─────────────────────────────────────────────────┐
│ DIAGNOSTIC: RC-D001 - getOrderBookDepth exists  │
├─────────────────────────────────────────────────┤
│ Running: grep -n "export function getOrder..."  │
│                                   

Maintain W Ralph Batch?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[W Ralph Batch on getagentictools](https://getagentictools.com/loops/danizeeincali-w-ralph-batch?ref=badge)
npx agentictools info loops/danizeeincali-w-ralph-batch

The second line is the CLI lookup for this page — handy in READMEs and docs.