-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathralph.sh
More file actions
80 lines (62 loc) · 2.62 KB
/
Copy pathralph.sh
File metadata and controls
80 lines (62 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Ralph - Autonomous AI Coding Loop
# Iteratively works through features in prd.json until complete
#
# Usage: ./ralph.sh <max-iterations>
# Example: ./ralph.sh 20
set -e
if [ -z "$1" ]; then
echo "Error: Please specify maximum iterations"
echo "Usage: $0 <max-iterations>"
echo "Example: $0 20"
exit 1
fi
MAX_ITERATIONS=$1
PROGRESS_FILE="agent-progress.txt"
PRD_FILE="prd.json"
echo "🤖 Ralph - Autonomous Coding Agent"
echo "📋 Task List: $PRD_FILE"
echo "📝 Progress Log: $PROGRESS_FILE"
echo "🔄 Max Iterations: $MAX_ITERATIONS"
echo ""
for ((iteration=1; iteration<=MAX_ITERATIONS; iteration++)); do
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Iteration $iteration / $MAX_ITERATIONS"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
result=$(claude --dangerously-skip-permissions -p "@$PRD_FILE @$PROGRESS_FILE @SPEC.MD @CLAUDE.md
Pick ONE task from $PRD_FILE where passes=false.
You don't have to go in order - choose the best next task based on dependencies and what's already done.
Foundation work (db, auth) before UI. Risky integrations before routine work.
Implement it following @CLAUDE.md guidelines.
Verify UI changes with Playwright MCP.
Run checks (bun run build, bun run lint, bun run test, bun run test:e2e).
After each completed task:
Mark passes=true in the prd.json file (for the completed task), update $PROGRESS_FILE, commit via Git.
When ALL tasks have passes=true, output: <complete>ALL_TASKS_DONE</complete>
" 2>&1) || {
echo "Error: claude failed with exit code $?"
echo "Output: $result"
exit 1
}
echo "$result"
echo ""
# Check if all work is complete
if [[ "$result" == *"<complete>ALL_TASKS_DONE</complete>"* ]]; then
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ All tasks complete!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
exit 0
fi
if [ $iteration -lt $MAX_ITERATIONS ]; then
echo "⏸ 2 second pause..."
sleep 2
echo ""
fi
done
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🏁 Reached $MAX_ITERATIONS iterations"
echo "📊 Review: git log"
echo "📝 Progress: cat $PROGRESS_FILE"
echo "⏭️ Run again if more work remains"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"