Execute implementation tasks autonomously for: **$ARGUMENTS**
Executes implementation tasks autonomously through iterative loops until completion or max iterations reached.
/plugin marketplace add niekcandaele/claude-helpers/plugin install cata-helpers@cata-helpers-marketplacecata-proj/Execute implementation tasks autonomously for: $ARGUMENTS
This command uses the Ralph Wiggum pattern: a Stop hook intercepts exit attempts and blocks the stop if work isn't complete, creating an autonomous feedback loop until all tasks are done or max iterations reached.
/cata-proj:ralph-execute feature-nameAUTONOMOUS ITERATION - The loop continues automatically:
On first run or continuation:
Parse Arguments
$ARGUMENTS can be:
- feature-name (finds docs/design/*/tasks.md)
- path/to/tasks.md (direct path)
- feature-name --max-iterations N (override default)
Locate Configuration
.claude/ralph-loop.local.md existsCreate/Update Config (.claude/ralph-loop.local.md)
---
active: true
iteration: 1
max_iterations: 10
feature: [feature-name]
tasks_file: [path/to/tasks.md]
started_at: [ISO timestamp]
status: in_progress
---
# Ralph Execute Loop State
## Current Status
**Iteration**: 1/10
**Tasks Complete**: 0/X
**Last Updated**: [timestamp]
**Status**: in_progress
## Iteration History
(Will be populated each iteration)
## Completion Markers
<!-- Hook reads these markers -->
Extract max_iterations
--max-iterations Nmax_iterations: NBefore doing work, check if we should stop:
Check Max Iterations
current_iteration=$(grep "^iteration:" .claude/ralph-loop.local.md | awk '{print $2}')
max_iterations=$(grep "^max_iterations:" .claude/ralph-loop.local.md | awk '{print $2}')
if [ "$current_iteration" -ge "$max_iterations" ]; then
# Write max iterations marker
# Report partial completion
# Exit (hook will allow stop)
fi
Check Task Completion
tasks_file=$(grep "^tasks_file:" .claude/ralph-loop.local.md | cut -d' ' -f2-)
incomplete=$(grep -c '^\s*- \[ \]' "$tasks_file" || echo "0")
complete=$(grep -c '^\s*- \[x\]' "$tasks_file" || echo "0")
if [ "$incomplete" -eq 0 ] && [ "$complete" -gt 0 ]; then
# Write completion marker
# Report success
# Exit (hook will allow stop)
fi
If Termination Condition Met
<!-- RALPH_COMPLETE --> if all tasks done<!-- RALPH_MAX_ITERATIONS --> if max iterations hitactive: false in config frontmatterFind tasks.md
docs/design/*/tasks.md matching featureFind design.md
Validate tasks.md Format
- [ ] or - [x]Use TodoWrite to show current iteration status:
TodoWrite with:
- Iteration N/M: [current iteration / max iterations]
- Tasks complete: X/Y
- Current phase: [phase name]
- Tasks in this iteration: [list of tasks attempting]
This gives visibility into what the loop is doing each iteration.
NO PLANNING PHASE - Ralph loops don't stop for approval, they iterate.
Identify Next Incomplete Phase
- Read tasks.md
- Find first phase with incomplete tasks (- [ ])
- That's the target phase for this iteration
Launch Research Agents (if needed)
For complex phases, launch research agents:
a. Explore Agent - Understand codebase context
Task tool with:
- subagent_type: "Explore"
- description: "Research [phase] implementation"
- prompt: "Understand existing patterns for [phase].
Find similar implementations.
Identify integration points.
Map files that need modification."
b. Researcher Agent (if unfamiliar tech)
Task tool with:
- subagent_type: "cata-researcher"
- description: "Research [technology]"
- prompt: "Research [technology] best practices.
Find current documentation (2026).
Identify potential pitfalls."
Implement Tasks
For each incomplete task in the phase:
a. Read Task Details
b. Implement
c. Update tasks.md Checkmarks
- Change `- [ ] Task description` to `- [x] Task description`
- Do this AS tasks complete, not in batch
- tasks.md is source of truth for completion
d. Handle Blockers
After implementing tasks, run verification:
Invoke /verify
Skill tool with:
- skill: "verify"
- No arguments needed
Capture Results
Log to Config
### Iteration N - [timestamp]
**Tasks Attempted**: [list]
**Verify Result**: PASS | FAIL
**Tasks Completed**: X
**Notes**: [what happened this iteration]
**Failures**: [if verify failed, what failed]
Handle Verify Failures
Update Config Frontmatter
---
active: true
iteration: [incremented]
max_iterations: [unchanged]
feature: [unchanged]
tasks_file: [unchanged]
started_at: [unchanged]
status: in_progress | complete | max_iterations_reached
---
Sync Task Count
- Count tasks.md checkboxes again
- Update "Tasks Complete: X/Y" in config
- Track progress percentage
Report Progress
Iteration N/M complete
Progress:
- Tasks complete: X/Y (P%)
- Verify result: PASS | FAIL
- Next iteration will: [continue | stop]
[If failures: list failures]
[If blockers: list blockers]
Exit Naturally
Stuck Task Detection
If task fails 3+ consecutive iterations:
- Log in config: "Task X.Y stuck - attempted in iterations [1,2,3]"
- Skip this task
- Move to next incomplete task
- Report stuck task in iteration summary
No Progress Detection
If no tasks completed in last 3 iterations:
- Log warning in config
- Continue trying (don't give up)
- Report pattern to user in iteration summary
Config File Issues
If config corrupted or unreadable:
- Backup to .claude/ralph-loop.local.md.backup
- Reinitialize from tasks.md state
- Start fresh iteration count
- Log warning
Missing Files
If tasks.md not found: Error and exit
If design.md not found: Log warning, continue
If verify command fails: Log error, this is critical, continue but report
The Stop hook reads these markers to decide continuation:
All Tasks Complete
<!-- RALPH_COMPLETE -->
Added when: incomplete_count == 0 && complete_count > 0
Max Iterations Reached
<!-- RALPH_MAX_ITERATIONS -->
Added when: current_iteration >= max_iterations
Active Flag
active: false
Set when loop should stop (completion or max iterations)
When loop ends (completion or max iterations), generate report:
Ralph Execute Complete
Feature: [feature-name]
Total Iterations: N/M
Duration: [start time to end time]
Final Status: [COMPLETE | PARTIAL | BLOCKED]
Tasks Summary:
- Total tasks: Y
- Completed: X
- Incomplete: Z
- Stuck: W
Iteration History:
[Summary of each iteration: what was attempted, results]
Recommendations:
[If incomplete: suggest increase --max-iterations or manual intervention]
[If stuck tasks: list them with details]
[If all complete: celebrate! 🎉]
/cata-proj:ralph-execute user-auth
Finds tasks.md for user-auth feature, runs with default 10 iterations.
/cata-proj:ralph-execute user-auth --max-iterations 20
Allows up to 20 iterations before stopping.
/cata-proj:ralph-execute docs/design/2024-01-15-user-auth/tasks.md
Uses specific tasks.md file.
/cata-proj:ralph-execute user-auth
If .claude/ralph-loop.local.md exists with active:true, continues from where it left off.
| Feature | execute | ralph-execute |
|---|---|---|
| Approval gates | Yes (after planning, after verify) | No (autonomous) |
| Loop behavior | Single run | Multi-iteration loop |
| Verify failures | Stop for human review | Log and continue |
| Use case | Critical features, tight control | Routine features, autonomous iteration |
| Stop control | Human decides | Hook decides based on completion |
✓ Routine features with clear requirements ✓ When you want autonomous iteration ✓ When you trust the process to converge ✓ When tasks.md is well-defined ✓ For exploratory implementation
✗ Critical production features ✗ When tight control needed ✗ When requirements are ambiguous ✗ When manual review is essential
Remember: The Ralph loop is powerful but autonomous. Trust the eventual consistency, let it iterate, and check the final results when it completes.