@supa-media/claude 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +102 -0
- package/package.json +30 -0
- package/src/sync.js +319 -0
- package/templates/CLAUDE.md +391 -0
- package/templates/commands/auto-worker.md +596 -0
- package/templates/commands/feature-validate.md +189 -0
- package/templates/commands/fix-ci.md +304 -0
- package/templates/commands/ios-build.md +188 -0
- package/templates/commands/isolate.md +364 -0
- package/templates/commands/lock-up.md +189 -0
- package/templates/commands/review-cycle.md +817 -0
- package/templates/hooks.json +4 -0
- package/templates/settings.json +44 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
# Auto-Worker Agent
|
|
2
|
+
|
|
3
|
+
Autonomous task processor designed to run overnight via Ralph loop. Picks tasks from the backlog, implements them with full verification, handles code review, and auto-merges to main.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Invoke via Ralph loop for overnight runs:
|
|
8
|
+
```bash
|
|
9
|
+
/ralph-loop "/auto-worker" --max-iterations 50 --completion-promise "AUTO_WORKER_COMPLETE"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Or run a single task cycle manually:
|
|
13
|
+
```
|
|
14
|
+
/auto-worker
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## CRITICAL: Orchestrator Pattern
|
|
20
|
+
|
|
21
|
+
**YOU ARE AN ORCHESTRATOR, NOT A DOER.**
|
|
22
|
+
|
|
23
|
+
⚠️ **VIOLATION OF THIS RULE CAUSES CONTEXT EXHAUSTION AND INFINITE LOOPS** ⚠️
|
|
24
|
+
|
|
25
|
+
Your ONLY jobs are:
|
|
26
|
+
1. Check budget and decide whether to continue
|
|
27
|
+
2. Pick the next task from the queue
|
|
28
|
+
3. Expand minimal PRD into full plan
|
|
29
|
+
4. Spawn sub-agents for all execution work
|
|
30
|
+
5. Update task files with attempt logs
|
|
31
|
+
6. Output completion promise when done
|
|
32
|
+
|
|
33
|
+
**PROTECT YOUR CONTEXT** - Never do file reading, code exploration, or implementation yourself. Spawn sub-agents for everything.
|
|
34
|
+
|
|
35
|
+
### What You MUST NOT Do Directly
|
|
36
|
+
|
|
37
|
+
❌ **DO NOT** use the Edit tool - spawn a sub-agent
|
|
38
|
+
❌ **DO NOT** use the Read tool (except for task files) - spawn a sub-agent
|
|
39
|
+
❌ **DO NOT** use the Grep/Glob tools - spawn a sub-agent
|
|
40
|
+
❌ **DO NOT** take screenshots - spawn a sub-agent
|
|
41
|
+
❌ **DO NOT** interact with simulators or browsers - spawn a sub-agent
|
|
42
|
+
❌ **DO NOT** write code - spawn a sub-agent
|
|
43
|
+
|
|
44
|
+
### What You CAN Do Directly
|
|
45
|
+
|
|
46
|
+
✅ Read QUEUE.md and task files (to pick tasks)
|
|
47
|
+
✅ Write to task files (to update attempt logs)
|
|
48
|
+
✅ Run simple bash commands for budget/status checks
|
|
49
|
+
✅ Spawn Task sub-agents (with max_turns!)
|
|
50
|
+
✅ Log progress to auto-worker-progress.log
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## CRITICAL: Progress Logging
|
|
55
|
+
|
|
56
|
+
**LOG PROGRESS FREQUENTLY** - The user needs visibility into what's happening.
|
|
57
|
+
|
|
58
|
+
### Before EVERY Phase
|
|
59
|
+
|
|
60
|
+
Run this to log progress (replace PHASE and DESCRIPTION):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] PHASE: DESCRIPTION" >> .claude/logs/auto-worker-progress.log
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Examples:
|
|
67
|
+
```bash
|
|
68
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Phase 0: Checking budget" >> .claude/logs/auto-worker-progress.log
|
|
69
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Phase 1: Reading queue, found 3 pending tasks" >> .claude/logs/auto-worker-progress.log
|
|
70
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Phase 3: Spawning dev sub-agent for task fix-landing-page" >> .claude/logs/auto-worker-progress.log
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### After Sub-Agent Returns
|
|
74
|
+
|
|
75
|
+
Log the result:
|
|
76
|
+
```bash
|
|
77
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Sub-agent returned: SUCCESS/FAILED - brief summary" >> .claude/logs/auto-worker-progress.log
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Monitor Progress
|
|
81
|
+
|
|
82
|
+
User can watch progress in real-time:
|
|
83
|
+
```bash
|
|
84
|
+
tail -f .claude/logs/auto-worker-progress.log
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## CRITICAL: Sub-Agent Timeouts
|
|
90
|
+
|
|
91
|
+
**ALL sub-agent Task calls MUST include `max_turns` to prevent infinite hangs.**
|
|
92
|
+
|
|
93
|
+
⚠️ **FAILURE TO INCLUDE max_turns WILL CAUSE THE RALPH LOOP TO HANG FOR HOURS** ⚠️
|
|
94
|
+
|
|
95
|
+
| Sub-agent Type | max_turns | Rationale |
|
|
96
|
+
|----------------|-----------|-----------|
|
|
97
|
+
| Task reading/planning | 15 | Quick exploration tasks |
|
|
98
|
+
| Implementation | 50 | Complex coding needs more turns |
|
|
99
|
+
| Testing | 30 | Simulator/browser interaction + screenshots |
|
|
100
|
+
| PR creation | 15 | Straightforward git operations |
|
|
101
|
+
| Smoke test | 20 | Quick verification |
|
|
102
|
+
|
|
103
|
+
**Example Task call with max_turns:**
|
|
104
|
+
```
|
|
105
|
+
Task tool with subagent_type="general-purpose", max_turns=30:
|
|
106
|
+
"Your prompt here..."
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
If a sub-agent times out (returns incomplete), log it and retry with a fresh sub-agent or mark the task for retry in the next Ralph iteration.
|
|
110
|
+
|
|
111
|
+
### Handling Sub-Agent Timeout
|
|
112
|
+
|
|
113
|
+
When a sub-agent hits max_turns without completing:
|
|
114
|
+
|
|
115
|
+
1. **Log the timeout:**
|
|
116
|
+
```bash
|
|
117
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] TIMEOUT: Sub-agent hit max_turns limit" >> .claude/logs/auto-worker-progress.log
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
2. **Check partial progress:** The sub-agent may have made partial progress (commits, file changes). Check git status.
|
|
121
|
+
|
|
122
|
+
3. **Decide next action:**
|
|
123
|
+
- If partial progress exists: Update task log, mark for retry in next Ralph iteration
|
|
124
|
+
- If no progress: Try once more with a simpler prompt or mark as blocked
|
|
125
|
+
|
|
126
|
+
4. **Never hang:** Always move forward - either retry, skip to next task, or output completion promise if stuck on all tasks.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## File Locations
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
.claude/
|
|
134
|
+
├── backlog/
|
|
135
|
+
│ ├── QUEUE.md # Task queue (read/update this)
|
|
136
|
+
│ ├── tasks/ # Task PRD files
|
|
137
|
+
│ └── completed/ # Archived completed tasks
|
|
138
|
+
├── images/
|
|
139
|
+
│ ├── reference/ # Input: mockups, bug screenshots
|
|
140
|
+
│ └── verification/ # Output: test evidence
|
|
141
|
+
├── logs/ # Console outputs, error dumps
|
|
142
|
+
└── budget/
|
|
143
|
+
└── config.yaml # Budget limits
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Phase 0: Check Budget
|
|
149
|
+
|
|
150
|
+
Before doing anything, check if we have budget remaining.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Check current usage
|
|
154
|
+
ccusage --json | jq '.weekly_percent'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Decision:**
|
|
158
|
+
- If usage >= 50% (or limit in config.yaml): Output `AUTO_WORKER_COMPLETE: Budget exceeded` and stop
|
|
159
|
+
- If usage < 50%: Continue to Phase 1
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Phase 1: Pick Next Task
|
|
164
|
+
|
|
165
|
+
### 1.1 Read the Queue
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
cat .claude/backlog/QUEUE.md
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Look at the "Pending" section for available tasks.
|
|
172
|
+
|
|
173
|
+
### 1.2 Read All Pending Task Files
|
|
174
|
+
|
|
175
|
+
For each task in Pending, spawn a sub-agent to read and summarize:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
Task tool with subagent_type="general-purpose", max_turns=15:
|
|
179
|
+
|
|
180
|
+
"Read the task file at .claude/backlog/tasks/<filename> and return:
|
|
181
|
+
- Priority (from frontmatter, or 'normal' if not specified)
|
|
182
|
+
- Brief summary (1 sentence)
|
|
183
|
+
- Has prior attempts? (check for '## Attempt Log' section)
|
|
184
|
+
- Number of prior loops (count ### Loop N headers)
|
|
185
|
+
- Is it blocked? (last attempt status)
|
|
186
|
+
|
|
187
|
+
Return as structured data."
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 1.3 Prioritize
|
|
191
|
+
|
|
192
|
+
Select the next task based on:
|
|
193
|
+
1. **High priority first** - Tasks with `priority: high` in frontmatter
|
|
194
|
+
2. **Fewer attempts first** - Prefer fresh tasks over retries
|
|
195
|
+
3. **Unblocked only** - Skip tasks where last attempt was "Blocked" (unless it's been < 3 loops)
|
|
196
|
+
4. **Your judgment** - Consider dependencies, complexity, risk
|
|
197
|
+
|
|
198
|
+
### 1.4 Update Queue
|
|
199
|
+
|
|
200
|
+
Move the selected task from "Pending" to "In Progress" in QUEUE.md.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Phase 2: Expand Task
|
|
205
|
+
|
|
206
|
+
Read the task file and expand the minimal PRD into a full plan.
|
|
207
|
+
|
|
208
|
+
**Spawn a sub-agent:**
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Task tool with subagent_type="general-purpose", max_turns=15:
|
|
212
|
+
|
|
213
|
+
"You are a technical planner. Read this task file and expand it into a detailed implementation plan.
|
|
214
|
+
|
|
215
|
+
Task file: .claude/backlog/tasks/<filename>
|
|
216
|
+
|
|
217
|
+
Your job:
|
|
218
|
+
1. Read the task description and any reference images
|
|
219
|
+
2. If there are prior attempt logs, READ THEM CAREFULLY - understand what was tried and what failed
|
|
220
|
+
3. Search the codebase to understand existing patterns
|
|
221
|
+
4. Create a detailed plan with:
|
|
222
|
+
- Acceptance criteria (checkboxes)
|
|
223
|
+
- Files that need to be modified
|
|
224
|
+
- Technical approach
|
|
225
|
+
- Verification steps (how to verify the fix works)
|
|
226
|
+
- Potential pitfalls to avoid (especially based on prior attempts)
|
|
227
|
+
|
|
228
|
+
Return the plan in markdown format.
|
|
229
|
+
|
|
230
|
+
IMPORTANT: If prior attempts exist, your plan MUST address what went wrong before."
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Phase 3: Implement
|
|
236
|
+
|
|
237
|
+
### 3.1 Determine Loop Number
|
|
238
|
+
|
|
239
|
+
Count existing "### Loop N" headers in the task file. New loop = max + 1.
|
|
240
|
+
|
|
241
|
+
### 3.2 Start Attempt Log Entry
|
|
242
|
+
|
|
243
|
+
Append to the task file:
|
|
244
|
+
|
|
245
|
+
```markdown
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Attempt Log
|
|
249
|
+
|
|
250
|
+
### Loop N (YYYY-MM-DD HH:MM)
|
|
251
|
+
**Status:** In Progress
|
|
252
|
+
**Commits:** (none yet)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### 3.3 Spawn Development Sub-Agent
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
Task tool with subagent_type="general-purpose", max_turns=50:
|
|
259
|
+
|
|
260
|
+
"You are implementing a feature.
|
|
261
|
+
|
|
262
|
+
## Task
|
|
263
|
+
<paste expanded plan here>
|
|
264
|
+
|
|
265
|
+
## Prior Attempts
|
|
266
|
+
<paste any prior attempt logs - what failed, what to avoid>
|
|
267
|
+
|
|
268
|
+
## Instructions
|
|
269
|
+
1. cd to repo root
|
|
270
|
+
2. Create a feature branch: git checkout -b feature/<task-slug>
|
|
271
|
+
3. Implement the feature following the plan
|
|
272
|
+
4. Commit frequently with atomic commits
|
|
273
|
+
5. Run type checks: pnpm typecheck
|
|
274
|
+
6. Run tests: pnpm test
|
|
275
|
+
|
|
276
|
+
## Commit Format
|
|
277
|
+
git commit -m '<type>: <description>
|
|
278
|
+
|
|
279
|
+
Co-Authored-By: Claude <noreply@anthropic.com>'
|
|
280
|
+
|
|
281
|
+
## IMPORTANT
|
|
282
|
+
- If you encounter issues, document them clearly
|
|
283
|
+
- Take note of any error messages or unexpected behavior
|
|
284
|
+
- Do NOT give up - try multiple approaches if needed
|
|
285
|
+
|
|
286
|
+
## Report Back
|
|
287
|
+
- List of commits made (hashes + messages)
|
|
288
|
+
- Files modified
|
|
289
|
+
- Any issues encountered
|
|
290
|
+
- Ready for testing? (yes/no)
|
|
291
|
+
"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 3.4 Handle Development Result
|
|
295
|
+
|
|
296
|
+
**If successful:** Update attempt log with commits, proceed to Phase 4
|
|
297
|
+
|
|
298
|
+
**If failed:**
|
|
299
|
+
1. Capture error screenshots if possible
|
|
300
|
+
2. Dump console logs: Save to `.claude/logs/<task>-loop<N>-console.log`
|
|
301
|
+
3. Update attempt log with what went wrong and screenshots/logs
|
|
302
|
+
4. Add "Recommendation for next attempt"
|
|
303
|
+
5. Check loop count:
|
|
304
|
+
- If < 3 loops: Mark status as "Retry", continue to next Ralph iteration
|
|
305
|
+
- If >= 3 loops: Mark status as "Blocked", move task back to Pending (Blocked section), pick next task
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Phase 4: Test
|
|
310
|
+
|
|
311
|
+
### 4.1 Start Development Servers
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# Start backend and app
|
|
315
|
+
pnpm dev &
|
|
316
|
+
|
|
317
|
+
# Wait for servers
|
|
318
|
+
sleep 30
|
|
319
|
+
|
|
320
|
+
# Verify servers are up
|
|
321
|
+
curl -sf http://localhost:8081 && echo "App OK" || echo "App not ready"
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### 4.2 Spawn Testing Sub-Agent
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
Task tool with subagent_type="general-purpose", max_turns=30:
|
|
328
|
+
|
|
329
|
+
"You are testing a feature.
|
|
330
|
+
|
|
331
|
+
## Feature
|
|
332
|
+
<description>
|
|
333
|
+
|
|
334
|
+
## Acceptance Criteria
|
|
335
|
+
<from expanded plan>
|
|
336
|
+
|
|
337
|
+
## Verification Steps
|
|
338
|
+
<from expanded plan>
|
|
339
|
+
|
|
340
|
+
## Instructions
|
|
341
|
+
1. Use available testing tools (Playwright for web, iOS Simulator MCP for mobile)
|
|
342
|
+
2. Navigate through the app to test the feature
|
|
343
|
+
3. Take screenshots at each verification step
|
|
344
|
+
4. Save screenshots to .claude/images/verification/<task>-loop<N>-<step>.png
|
|
345
|
+
|
|
346
|
+
## CRITICAL
|
|
347
|
+
- You MUST take 2-5 screenshots as evidence
|
|
348
|
+
- If something fails, screenshot the failure
|
|
349
|
+
- Do not say 'cannot test' - fix blockers or report exactly what's broken
|
|
350
|
+
|
|
351
|
+
## Report Back
|
|
352
|
+
- PASS or FAIL for each acceptance criterion
|
|
353
|
+
- List of screenshots taken
|
|
354
|
+
- Any issues found (with details)
|
|
355
|
+
"
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### 4.3 Handle Test Result
|
|
359
|
+
|
|
360
|
+
**If all tests pass:** Update attempt log with verification screenshots, proceed to Phase 5
|
|
361
|
+
|
|
362
|
+
**If tests fail:** Same as development failure - document, screenshot, potentially retry
|
|
363
|
+
|
|
364
|
+
### 4.4 Cleanup Servers
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
# Kill dev servers
|
|
368
|
+
lsof -ti :8081 | xargs kill -9 2>/dev/null || true
|
|
369
|
+
lsof -ti :3000 | xargs kill -9 2>/dev/null || true
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Phase 5: Create PR
|
|
375
|
+
|
|
376
|
+
**Spawn a sub-agent:**
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
Task tool with subagent_type="general-purpose", max_turns=15:
|
|
380
|
+
|
|
381
|
+
"You are creating a PR for a completed feature.
|
|
382
|
+
|
|
383
|
+
## Context
|
|
384
|
+
- Feature: <description>
|
|
385
|
+
- Branch: feature/<task-slug>
|
|
386
|
+
- Task file: .claude/backlog/tasks/<filename>
|
|
387
|
+
|
|
388
|
+
## Screenshots
|
|
389
|
+
<list of verification screenshots from Phase 4>
|
|
390
|
+
|
|
391
|
+
## Instructions
|
|
392
|
+
1. Ensure all changes are committed
|
|
393
|
+
2. Push branch: git push -u origin HEAD
|
|
394
|
+
3. Create PR:
|
|
395
|
+
|
|
396
|
+
gh pr create --base main --title '<feature title>' --body '## Summary
|
|
397
|
+
<bullet points from task>
|
|
398
|
+
|
|
399
|
+
## Screenshots
|
|
400
|
+
<embed verification screenshots>
|
|
401
|
+
|
|
402
|
+
## Test Plan
|
|
403
|
+
- [x] Verified via testing tools
|
|
404
|
+
- [x] Unit tests pass
|
|
405
|
+
- [x] Type checks pass
|
|
406
|
+
|
|
407
|
+
## Task File
|
|
408
|
+
See: .claude/backlog/tasks/<filename>
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
Generated with Claude Auto-Worker'
|
|
412
|
+
|
|
413
|
+
## Report Back
|
|
414
|
+
- PR number
|
|
415
|
+
- PR URL
|
|
416
|
+
"
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Update attempt log with PR number.
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## Phase 6: Code Review Cycle
|
|
424
|
+
|
|
425
|
+
Invoke the review-cycle skill:
|
|
426
|
+
|
|
427
|
+
```
|
|
428
|
+
Use Skill tool: /review-cycle <PR_NUMBER>
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
This handles:
|
|
432
|
+
- Waiting for bot reviews
|
|
433
|
+
- Fixing issues they raise
|
|
434
|
+
- Iterating until approved
|
|
435
|
+
- Resolving comment threads
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Phase 7: Smoke Test
|
|
440
|
+
|
|
441
|
+
After code review changes, do a quick sanity check.
|
|
442
|
+
|
|
443
|
+
**Spawn a sub-agent:**
|
|
444
|
+
|
|
445
|
+
```
|
|
446
|
+
Task tool with subagent_type="general-purpose", max_turns=20:
|
|
447
|
+
|
|
448
|
+
"Quick smoke test after code review changes.
|
|
449
|
+
|
|
450
|
+
## Instructions
|
|
451
|
+
1. Start dev servers: pnpm dev &
|
|
452
|
+
2. Wait 30 seconds
|
|
453
|
+
3. Verify app loads without crash
|
|
454
|
+
4. Navigate to the feature area
|
|
455
|
+
5. Take ONE screenshot showing it still works
|
|
456
|
+
6. Kill dev servers
|
|
457
|
+
|
|
458
|
+
## Report Back
|
|
459
|
+
- PASS or FAIL
|
|
460
|
+
- Screenshot path
|
|
461
|
+
- Any issues
|
|
462
|
+
"
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
**If smoke test fails:** Document, potentially retry the review fixes
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Phase 8: Merge and Complete
|
|
470
|
+
|
|
471
|
+
### 8.1 Merge PR
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
gh pr merge <PR_NUMBER> --squash --delete-branch
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### 8.2 Update Task File
|
|
478
|
+
|
|
479
|
+
Add final status to attempt log:
|
|
480
|
+
|
|
481
|
+
```markdown
|
|
482
|
+
**Status:** Complete
|
|
483
|
+
**PR:** #<number> -> Merged
|
|
484
|
+
|
|
485
|
+
**Verification Screenshots:**
|
|
486
|
+

|
|
487
|
+

|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### 8.3 Move Task to Completed
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
mv .claude/backlog/tasks/<filename> .claude/backlog/completed/
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### 8.4 Update Queue
|
|
497
|
+
|
|
498
|
+
Move task from "In Progress" to "Completed" table in QUEUE.md:
|
|
499
|
+
|
|
500
|
+
```markdown
|
|
501
|
+
| <filename> | #<PR> | <date> |
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### 8.5 Commit Bookkeeping
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
git add .claude/
|
|
508
|
+
git commit -m "chore: complete task <filename>
|
|
509
|
+
|
|
510
|
+
Auto-worker completed task and merged PR #<number>.
|
|
511
|
+
|
|
512
|
+
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
513
|
+
git push
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## Phase 9: Loop or Complete
|
|
519
|
+
|
|
520
|
+
Check if there are more pending tasks in QUEUE.md:
|
|
521
|
+
|
|
522
|
+
- **If more tasks exist:** Return to Phase 0 (check budget first)
|
|
523
|
+
- **If queue empty:** Output `AUTO_WORKER_COMPLETE: Queue empty`
|
|
524
|
+
- **If budget exceeded:** Output `AUTO_WORKER_COMPLETE: Budget exceeded`
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## Completion Promises
|
|
529
|
+
|
|
530
|
+
Ralph loop detects these to know when to stop:
|
|
531
|
+
|
|
532
|
+
- `AUTO_WORKER_COMPLETE: Queue empty` - All tasks done
|
|
533
|
+
- `AUTO_WORKER_COMPLETE: Budget exceeded` - Hit usage limit
|
|
534
|
+
- `AUTO_WORKER_COMPLETE: Max iterations` - Ralph's own limit hit
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## Error Recovery
|
|
539
|
+
|
|
540
|
+
### Circuit Breaker Pattern
|
|
541
|
+
|
|
542
|
+
**If the same error occurs 3+ times, STOP and escalate:**
|
|
543
|
+
|
|
544
|
+
Track error patterns in the attempt log. When you see repeated failures:
|
|
545
|
+
|
|
546
|
+
1. **Identify the pattern:** Same error message? Same tool failing?
|
|
547
|
+
2. **Log the circuit break:**
|
|
548
|
+
```bash
|
|
549
|
+
echo "[$(date)] CIRCUIT BREAKER: Same error 3+ times - <error summary>" >> .claude/logs/auto-worker-progress.log
|
|
550
|
+
```
|
|
551
|
+
3. **Take action based on error type:**
|
|
552
|
+
- **Tool not found (ENOENT):** Mark task as blocked, note required tool installation
|
|
553
|
+
- **Auth errors (401/403):** Check credentials/tokens, may need manual intervention
|
|
554
|
+
- **Timeout/hang:** Reduce scope, try alternative approach, or skip
|
|
555
|
+
4. **Never keep retrying the same failing operation**
|
|
556
|
+
|
|
557
|
+
### Sub-agent Says "Can't Do X"
|
|
558
|
+
|
|
559
|
+
**NEVER ACCEPT THIS.** Instead:
|
|
560
|
+
1. Ask WHY
|
|
561
|
+
2. Fix the blocker
|
|
562
|
+
3. Spawn a new sub-agent with updated context
|
|
563
|
+
4. **BUT if you've tried 3 times, trigger the circuit breaker above**
|
|
564
|
+
|
|
565
|
+
### Servers Won't Start
|
|
566
|
+
|
|
567
|
+
```bash
|
|
568
|
+
# Kill everything on dev ports
|
|
569
|
+
lsof -ti :3000 | xargs kill -9 2>/dev/null || true
|
|
570
|
+
lsof -ti :8081 | xargs kill -9 2>/dev/null || true
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Git Issues
|
|
574
|
+
|
|
575
|
+
```bash
|
|
576
|
+
# If branch conflicts
|
|
577
|
+
git fetch origin main
|
|
578
|
+
git rebase origin/main
|
|
579
|
+
# Or reset and retry
|
|
580
|
+
git checkout main
|
|
581
|
+
git pull
|
|
582
|
+
git checkout -b feature/<new-branch>
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Safety Rules
|
|
588
|
+
|
|
589
|
+
1. **Check budget first** - Don't start work you can't finish
|
|
590
|
+
2. **Document everything** - Update task files with attempt logs
|
|
591
|
+
3. **Screenshot failures** - Visual evidence helps next loop
|
|
592
|
+
4. **Dump logs** - Console output in .claude/logs/
|
|
593
|
+
5. **Never skip testing** - Every feature must be verified
|
|
594
|
+
6. **Never skip code review** - Let bots review before merge
|
|
595
|
+
7. **Auto-merge only to main** - Single protected branch
|
|
596
|
+
8. **Commit bookkeeping** - Push task file updates so they persist
|