continuous-improvement 3.8.0 → 3.9.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/.claude-plugin/marketplace.json +2 -14
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -21
- package/QUICKSTART.md +148 -101
- package/README.md +50 -18
- package/action.yml +33 -33
- package/bin/analyze.sh +161 -161
- package/bin/backfill.mjs +19 -19
- package/bin/check-doc-runtime-claims.mjs +120 -0
- package/bin/generate-plugin-manifests.mjs +2 -0
- package/bin/hook-stats.mjs +21 -21
- package/bin/install.mjs +51 -44
- package/bin/mcp-server.mjs +43 -40
- package/bin/refresh-third-party.mjs +416 -416
- package/commands/continuous-improvement.md +115 -115
- package/commands/dashboard.md +56 -56
- package/commands/discipline.md +51 -51
- package/commands/proceed-with-the-recommendation.md +62 -62
- package/commands/seven-laws.md +16 -16
- package/commands/superpowers.md +119 -92
- package/commands/workspace-surface-audit.md +77 -77
- package/hooks/gateguard.mjs +172 -0
- package/hooks/observe.sh +172 -172
- package/hooks/session.sh +106 -106
- package/hooks/three-section-close.mjs +181 -181
- package/instinct-packs/go.json +58 -58
- package/instinct-packs/meta.json +16 -16
- package/instinct-packs/python.json +58 -58
- package/instinct-packs/react.json +58 -58
- package/lib/gateguard-state.mjs +85 -0
- package/lib/plugin-metadata.mjs +25 -18
- package/llms.txt +68 -68
- package/package.json +3 -2
- package/plugins/beginner.json +1 -1
- package/plugins/continuous-improvement/.claude-plugin/marketplace.json +1 -1
- package/plugins/continuous-improvement/.claude-plugin/plugin.json +1 -1
- package/plugins/continuous-improvement/LICENSE +21 -21
- package/plugins/continuous-improvement/README.md +1 -0
- package/plugins/continuous-improvement/agents/README.md +120 -0
- package/plugins/continuous-improvement/agents/code-reviewer.md +97 -0
- package/plugins/continuous-improvement/agents/security-auditor.md +101 -0
- package/plugins/continuous-improvement/agents/test-engineer.md +95 -0
- package/plugins/continuous-improvement/bin/backfill.mjs +19 -19
- package/plugins/continuous-improvement/bin/mcp-server.mjs +43 -40
- package/plugins/continuous-improvement/commands/continuous-improvement.md +115 -115
- package/plugins/continuous-improvement/commands/dashboard.md +56 -56
- package/plugins/continuous-improvement/commands/discipline.md +51 -51
- package/plugins/continuous-improvement/commands/proceed-with-the-recommendation.md +62 -62
- package/plugins/continuous-improvement/commands/seven-laws.md +16 -16
- package/plugins/continuous-improvement/commands/superpowers.md +119 -92
- package/plugins/continuous-improvement/commands/workspace-surface-audit.md +77 -77
- package/plugins/continuous-improvement/hooks/gateguard.mjs +172 -0
- package/plugins/continuous-improvement/hooks/hooks.json +6 -1
- package/plugins/continuous-improvement/hooks/observe.sh +172 -172
- package/plugins/continuous-improvement/hooks/session.sh +106 -106
- package/plugins/continuous-improvement/hooks/three-section-close.mjs +181 -181
- package/plugins/continuous-improvement/instinct-packs/go.json +58 -58
- package/plugins/continuous-improvement/instinct-packs/meta.json +16 -16
- package/plugins/continuous-improvement/instinct-packs/python.json +58 -58
- package/plugins/continuous-improvement/instinct-packs/react.json +58 -58
- package/plugins/continuous-improvement/lib/plugin-metadata.mjs +25 -18
- package/plugins/continuous-improvement/skills/README.md +4 -1
- package/plugins/continuous-improvement/skills/deploy-receipt/SKILL.md +47 -0
- package/plugins/continuous-improvement/skills/gateguard/SKILL.md +17 -9
- package/plugins/continuous-improvement/skills/para-memory-files/SKILL.md +108 -108
- package/plugins/continuous-improvement/skills/proceed-with-the-recommendation/SKILL.md +1 -8
- package/plugins/continuous-improvement/skills/ralph/SKILL.md +221 -221
- package/plugins/continuous-improvement/skills/recovery-classification/SKILL.md +73 -0
- package/plugins/continuous-improvement/skills/safety-guard/SKILL.md +76 -76
- package/plugins/continuous-improvement/skills/state-reconciliation/SKILL.md +63 -0
- package/plugins/continuous-improvement/skills/strategic-compact/SKILL.md +104 -104
- package/plugins/continuous-improvement/skills/superpowers/SKILL.md +22 -15
- package/plugins/continuous-improvement/skills/tdd-workflow/SKILL.md +411 -411
- package/plugins/continuous-improvement/skills/token-budget-advisor/SKILL.md +136 -136
- package/plugins/continuous-improvement/skills/verification-loop/SKILL.md +32 -0
- package/plugins/continuous-improvement/skills/wild-risa-balance/SKILL.md +191 -191
- package/plugins/continuous-improvement/skills/worktree-safety/SKILL.md +66 -0
- package/plugins/expert.json +1 -1
- package/skills/README.md +79 -79
- package/skills/deploy-receipt.md +47 -0
- package/skills/gateguard.md +17 -9
- package/skills/para-memory-files.md +108 -108
- package/skills/proceed-with-the-recommendation.md +1 -8
- package/skills/ralph.md +221 -221
- package/skills/recovery-classification.md +73 -0
- package/skills/safety-guard.md +76 -76
- package/skills/state-reconciliation.md +63 -0
- package/skills/strategic-compact.md +104 -104
- package/skills/superpowers.md +22 -15
- package/skills/tdd-workflow.md +411 -411
- package/skills/token-budget-advisor.md +136 -136
- package/skills/verification-loop.md +32 -0
- package/skills/wild-risa-balance.md +191 -191
- package/skills/worktree-safety.md +66 -0
- package/templates/insights-claude-md.md +91 -0
- package/templates/verify-ladder.example.json +37 -24
package/skills/ralph.md
CHANGED
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ralph
|
|
3
|
-
tier: companion
|
|
4
|
-
description: "Enforces Law 6 (Iterate Means One Thing) of the 7 Laws of AI Agent Discipline at PRD scale. Ralph is an autonomous AI agent loop that runs repeatedly until all PRD items are complete. Converts PRDs to executable JSON, implements stories iteratively with quality checks, and tracks progress."
|
|
5
|
-
origin: https://github.com/snarktank/ralph
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Ralph — Autonomous Agent Loop
|
|
9
|
-
|
|
10
|
-
Ralph runs iteratively until all PRD stories are complete. Each iteration: picks highest priority story, implements, runs quality checks, commits if passing, updates progress, repeats.
|
|
11
|
-
|
|
12
|
-
## When to Use
|
|
13
|
-
|
|
14
|
-
- Large features that exceed a single context window
|
|
15
|
-
- Multi-story PRDs that need consistent implementation
|
|
16
|
-
- Tasks requiring repeated verification and commit cycles
|
|
17
|
-
- Long-running development that benefits from persistence across interruptions
|
|
18
|
-
|
|
19
|
-
## Do NOT Use When
|
|
20
|
-
|
|
21
|
-
- Task is a one-shot fix completable in a single edit — just edit the file
|
|
22
|
-
- You haven't written a PRD yet — write the PRD first, then run Ralph against it
|
|
23
|
-
- The work spans fewer than 3 stories — single-iteration verification is enough
|
|
24
|
-
- You need to explore or plan before committing to scope — use a planning skill first; Ralph is for execution, not discovery
|
|
25
|
-
- You want manual control over each iteration — run quality checks yourself, no need for Ralph's loop
|
|
26
|
-
|
|
27
|
-
## Prerequisites
|
|
28
|
-
|
|
29
|
-
- Git repository
|
|
30
|
-
- PRD document (markdown format)
|
|
31
|
-
- `jq` installed (`brew install jq` on macOS)
|
|
32
|
-
|
|
33
|
-
## Workflow
|
|
34
|
-
|
|
35
|
-
### 1. Create a PRD
|
|
36
|
-
|
|
37
|
-
Generate a detailed requirements document using the PRD skill:
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
Load the prd skill and create a PRD for [your feature description]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Output saved to `tasks/prd-[feature-name].md`
|
|
44
|
-
|
|
45
|
-
**CRITICAL — refine generic criteria before iteration begins.** Auto-generated PRD scaffolds often produce generic acceptance criteria like `["Implementation is complete", "Code compiles without errors"]`. These are theater — Ralph cannot prove a story passes against criteria that don't actually constrain it. Replace every generic criterion with a concrete, testable statement before moving to step 2.
|
|
46
|
-
|
|
47
|
-
- Bad: `"Function is implemented correctly"`
|
|
48
|
-
- Good: `"Function parseUserInput(s) returns {ok: true, value} for valid s and {ok: false, error} for invalid s, asserted by tests/parse-user-input.test.ts"`
|
|
49
|
-
- Bad: `"Code compiles"`
|
|
50
|
-
- Good: `"TypeScript compiles with no errors (npm run build) AND lsp diagnostics show 0 errors on src/parse-user-input.ts"`
|
|
51
|
-
|
|
52
|
-
If you cannot write a testable criterion, the story is too big. Break it down before continuing.
|
|
53
|
-
|
|
54
|
-
**Example — refining a scaffold criterion**
|
|
55
|
-
|
|
56
|
-
Auto-generated:
|
|
57
|
-
|
|
58
|
-
```json
|
|
59
|
-
"acceptanceCriteria": [
|
|
60
|
-
"Implementation is complete",
|
|
61
|
-
"Code compiles without errors"
|
|
62
|
-
]
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
After refinement:
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
"acceptanceCriteria": [
|
|
69
|
-
"POST /api/users returns 201 with {id, email} for valid input, asserted by tests/api-users.test.ts",
|
|
70
|
-
"POST /api/users returns 400 with {error} for missing email, asserted by tests/api-users.test.ts",
|
|
71
|
-
"TypeScript compiles with 0 errors (npm run build)",
|
|
72
|
-
"lsp diagnostics show 0 errors on src/api/users.ts"
|
|
73
|
-
]
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 2. Convert PRD to Ralph Format
|
|
77
|
-
|
|
78
|
-
Convert the markdown PRD to executable JSON:
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
Load the ralph skill and convert tasks/prd-[feature-name].md to prd.json
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
This creates `prd.json` with user stories structured for autonomous execution.
|
|
85
|
-
|
|
86
|
-
### 3. Run Ralph
|
|
87
|
-
|
|
88
|
-
Execute the autonomous loop:
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# Using Amp (default)
|
|
92
|
-
./scripts/ralph/ralph.sh [max_iterations]
|
|
93
|
-
|
|
94
|
-
# Using Claude Code
|
|
95
|
-
./scripts/ralph/ralph.sh --tool claude [max_iterations]
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Default: 10 iterations. Use `--tool amp` or `--tool claude` to select your AI tool.
|
|
99
|
-
|
|
100
|
-
## Ralph Loop Steps
|
|
101
|
-
|
|
102
|
-
1. **Create feature branch** — from PRD `branchName`
|
|
103
|
-
2. **Pick highest priority story** — where `passes: false`
|
|
104
|
-
3. **Implement that single story** — fresh context per iteration
|
|
105
|
-
4. **Run quality checks** — verify the current story's specific acceptance criteria with fresh evidence:
|
|
106
|
-
- For EACH acceptance criterion, run the test/build/lint that proves it
|
|
107
|
-
- Read the output, do not assume
|
|
108
|
-
- If ANY criterion is not met, continue working — do NOT mark the story as `passes: true`
|
|
109
|
-
- **Suite-level "all tests pass" is NOT a substitute for criterion-level proof.**
|
|
110
|
-
|
|
111
|
-
**Example — story-by-story verification**
|
|
112
|
-
|
|
113
|
-
Bad:
|
|
114
|
-
|
|
115
|
-
```
|
|
116
|
-
Story US-002: "Add /api/users endpoint"
|
|
117
|
-
- Ran npm test → all green → marked passes: true
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Why bad: suite-level pass doesn't prove THIS story's criteria. Other tests could be passing while the new endpoint is broken.
|
|
121
|
-
|
|
122
|
-
Good:
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
Story US-002: "Add /api/users endpoint"
|
|
126
|
-
- Criterion 1: POST /api/users → 201 → ran `npx vitest tests/api-users.test.ts -t "valid input"` → PASS
|
|
127
|
-
- Criterion 2: POST /api/users → 400 → ran `npx vitest tests/api-users.test.ts -t "missing email"` → PASS
|
|
128
|
-
- Criterion 3: typecheck → ran `npm run build` → 0 errors
|
|
129
|
-
- All criteria met with fresh evidence → marked passes: true
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Why good: each criterion proven with a targeted run; the output was read before the mark.
|
|
133
|
-
|
|
134
|
-
5. **Commit if checks pass** — atomic commits per story
|
|
135
|
-
6. **Update prd.json** — mark story as `passes: true`
|
|
136
|
-
7. **Append learnings** — to `progress.txt`
|
|
137
|
-
8. **Repeat** — until all stories pass or max iterations reached
|
|
138
|
-
|
|
139
|
-
## Key Concepts
|
|
140
|
-
|
|
141
|
-
### Each Iteration = Fresh Context
|
|
142
|
-
|
|
143
|
-
Every story gets a clean slate. Previous work is visible only via git history and `prd.json`, preventing context pollution.
|
|
144
|
-
|
|
145
|
-
### Small Tasks
|
|
146
|
-
|
|
147
|
-
Stories should be completable in 10-30 minutes. If a story stalls, break it down.
|
|
148
|
-
|
|
149
|
-
### AGENTS.md Updates Are Critical
|
|
150
|
-
|
|
151
|
-
Ralph updates `AGENTS.md` after each story so subsequent iterations know what's already done.
|
|
152
|
-
|
|
153
|
-
### Feedback Loops
|
|
154
|
-
|
|
155
|
-
- Build/test failures: immediate fix or rollback
|
|
156
|
-
- Test failures: investigate before declaring pass
|
|
157
|
-
- Confusion: log to `progress.txt` for human review
|
|
158
|
-
|
|
159
|
-
### Browser Verification for UI Stories
|
|
160
|
-
|
|
161
|
-
Ralph starts a dev server and uses Playwright to verify UI stories actually render.
|
|
162
|
-
|
|
163
|
-
### Stop Condition
|
|
164
|
-
|
|
165
|
-
Ralph stops when:
|
|
166
|
-
- All stories have `passes: true`
|
|
167
|
-
- Max iterations reached
|
|
168
|
-
- Critical failure encountered (user intervention required)
|
|
169
|
-
|
|
170
|
-
## Anti-patterns
|
|
171
|
-
|
|
172
|
-
These thoughts mean STOP — Ralph is about to slip:
|
|
173
|
-
|
|
174
|
-
| Thought | Why it's wrong |
|
|
175
|
-
|---|---|
|
|
176
|
-
| "All stories pass, time to summarise and wait for the user" mid-loop | Polite-stop. Ralph continues through commit + progress update + next pick in the same turn. |
|
|
177
|
-
| "Tests pass at the suite level, the story must be done" | Suite-level pass is not criterion-level proof. Verify each criterion with fresh evidence. |
|
|
178
|
-
| "Story is bigger than expected, I'll mark it passes: true and add a TODO" | Scope reduction. Either complete the story or break it down — never declare partial completion. |
|
|
179
|
-
| "The criterion is generic but obviously the test covers it" | PRD theater. Refine the criterion to something specific before proceeding. |
|
|
180
|
-
| "I'll skip the failing test by deleting/skipping it" | Tests are evidence. Fix the implementation, not the test. |
|
|
181
|
-
| "Reviewer said it looks good" — without running fresh checks | "Looks good" is not verification. Run the build, run the tests, read the output. |
|
|
182
|
-
|
|
183
|
-
## Final Checklist (Hard Gate)
|
|
184
|
-
|
|
185
|
-
Ralph cannot exit cleanly until ALL of these are true:
|
|
186
|
-
|
|
187
|
-
- [ ] Every story in `prd.json` has `passes: true` (no incomplete stories)
|
|
188
|
-
- [ ] Acceptance criteria are task-specific (no `"Implementation is complete"` generics)
|
|
189
|
-
- [ ] All requirements from the original task are met (no scope reduction)
|
|
190
|
-
- [ ] Fresh test run output shows all tests pass (read it, don't assume)
|
|
191
|
-
- [ ] Fresh build output shows success (read it, don't assume)
|
|
192
|
-
- [ ] No tests were deleted, skipped, or weakened to make checks green
|
|
193
|
-
- [ ] `progress.txt` records implementation details and learnings per iteration
|
|
194
|
-
- [ ] Working tree is clean (every story committed atomically)
|
|
195
|
-
|
|
196
|
-
A failing checkbox is a hard halt — do not declare done.
|
|
197
|
-
|
|
198
|
-
## Files
|
|
199
|
-
|
|
200
|
-
- `prd.json` — executable PRD with user stories
|
|
201
|
-
- `progress.txt` — accumulated learnings and status
|
|
202
|
-
- `ralph.sh` — the loop script
|
|
203
|
-
- `AGENTS.md` — iteration memory
|
|
204
|
-
|
|
205
|
-
## Debugging
|
|
206
|
-
|
|
207
|
-
If Ralph gets stuck:
|
|
208
|
-
|
|
209
|
-
1. Check `prd.json` for malformed stories
|
|
210
|
-
2. Review `progress.txt` for accumulated errors
|
|
211
|
-
3. Verify tests pass independently: `npm test` or equivalent
|
|
212
|
-
4. Check git status for uncommitted changes
|
|
213
|
-
5. Run single iteration manually to isolate issues
|
|
214
|
-
|
|
215
|
-
## Customizing the Prompt
|
|
216
|
-
|
|
217
|
-
Edit the prompt template in `scripts/ralph/prompt.md` (Amp) or `scripts/ralph/CLAUDE.md` (Claude Code) to adjust behavior.
|
|
218
|
-
|
|
219
|
-
## Archiving
|
|
220
|
-
|
|
221
|
-
After completion, archive `prd.json` and `progress.txt` to `tasks/archive/[date]/` for future reference.
|
|
1
|
+
---
|
|
2
|
+
name: ralph
|
|
3
|
+
tier: companion
|
|
4
|
+
description: "Enforces Law 6 (Iterate Means One Thing) of the 7 Laws of AI Agent Discipline at PRD scale. Ralph is an autonomous AI agent loop that runs repeatedly until all PRD items are complete. Converts PRDs to executable JSON, implements stories iteratively with quality checks, and tracks progress."
|
|
5
|
+
origin: https://github.com/snarktank/ralph
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Ralph — Autonomous Agent Loop
|
|
9
|
+
|
|
10
|
+
Ralph runs iteratively until all PRD stories are complete. Each iteration: picks highest priority story, implements, runs quality checks, commits if passing, updates progress, repeats.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Large features that exceed a single context window
|
|
15
|
+
- Multi-story PRDs that need consistent implementation
|
|
16
|
+
- Tasks requiring repeated verification and commit cycles
|
|
17
|
+
- Long-running development that benefits from persistence across interruptions
|
|
18
|
+
|
|
19
|
+
## Do NOT Use When
|
|
20
|
+
|
|
21
|
+
- Task is a one-shot fix completable in a single edit — just edit the file
|
|
22
|
+
- You haven't written a PRD yet — write the PRD first, then run Ralph against it
|
|
23
|
+
- The work spans fewer than 3 stories — single-iteration verification is enough
|
|
24
|
+
- You need to explore or plan before committing to scope — use a planning skill first; Ralph is for execution, not discovery
|
|
25
|
+
- You want manual control over each iteration — run quality checks yourself, no need for Ralph's loop
|
|
26
|
+
|
|
27
|
+
## Prerequisites
|
|
28
|
+
|
|
29
|
+
- Git repository
|
|
30
|
+
- PRD document (markdown format)
|
|
31
|
+
- `jq` installed (`brew install jq` on macOS)
|
|
32
|
+
|
|
33
|
+
## Workflow
|
|
34
|
+
|
|
35
|
+
### 1. Create a PRD
|
|
36
|
+
|
|
37
|
+
Generate a detailed requirements document using the PRD skill:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Load the prd skill and create a PRD for [your feature description]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Output saved to `tasks/prd-[feature-name].md`
|
|
44
|
+
|
|
45
|
+
**CRITICAL — refine generic criteria before iteration begins.** Auto-generated PRD scaffolds often produce generic acceptance criteria like `["Implementation is complete", "Code compiles without errors"]`. These are theater — Ralph cannot prove a story passes against criteria that don't actually constrain it. Replace every generic criterion with a concrete, testable statement before moving to step 2.
|
|
46
|
+
|
|
47
|
+
- Bad: `"Function is implemented correctly"`
|
|
48
|
+
- Good: `"Function parseUserInput(s) returns {ok: true, value} for valid s and {ok: false, error} for invalid s, asserted by tests/parse-user-input.test.ts"`
|
|
49
|
+
- Bad: `"Code compiles"`
|
|
50
|
+
- Good: `"TypeScript compiles with no errors (npm run build) AND lsp diagnostics show 0 errors on src/parse-user-input.ts"`
|
|
51
|
+
|
|
52
|
+
If you cannot write a testable criterion, the story is too big. Break it down before continuing.
|
|
53
|
+
|
|
54
|
+
**Example — refining a scaffold criterion**
|
|
55
|
+
|
|
56
|
+
Auto-generated:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
"acceptanceCriteria": [
|
|
60
|
+
"Implementation is complete",
|
|
61
|
+
"Code compiles without errors"
|
|
62
|
+
]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
After refinement:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
"acceptanceCriteria": [
|
|
69
|
+
"POST /api/users returns 201 with {id, email} for valid input, asserted by tests/api-users.test.ts",
|
|
70
|
+
"POST /api/users returns 400 with {error} for missing email, asserted by tests/api-users.test.ts",
|
|
71
|
+
"TypeScript compiles with 0 errors (npm run build)",
|
|
72
|
+
"lsp diagnostics show 0 errors on src/api/users.ts"
|
|
73
|
+
]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 2. Convert PRD to Ralph Format
|
|
77
|
+
|
|
78
|
+
Convert the markdown PRD to executable JSON:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
Load the ralph skill and convert tasks/prd-[feature-name].md to prd.json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This creates `prd.json` with user stories structured for autonomous execution.
|
|
85
|
+
|
|
86
|
+
### 3. Run Ralph
|
|
87
|
+
|
|
88
|
+
Execute the autonomous loop:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Using Amp (default)
|
|
92
|
+
./scripts/ralph/ralph.sh [max_iterations]
|
|
93
|
+
|
|
94
|
+
# Using Claude Code
|
|
95
|
+
./scripts/ralph/ralph.sh --tool claude [max_iterations]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Default: 10 iterations. Use `--tool amp` or `--tool claude` to select your AI tool.
|
|
99
|
+
|
|
100
|
+
## Ralph Loop Steps
|
|
101
|
+
|
|
102
|
+
1. **Create feature branch** — from PRD `branchName`
|
|
103
|
+
2. **Pick highest priority story** — where `passes: false`
|
|
104
|
+
3. **Implement that single story** — fresh context per iteration
|
|
105
|
+
4. **Run quality checks** — verify the current story's specific acceptance criteria with fresh evidence:
|
|
106
|
+
- For EACH acceptance criterion, run the test/build/lint that proves it
|
|
107
|
+
- Read the output, do not assume
|
|
108
|
+
- If ANY criterion is not met, continue working — do NOT mark the story as `passes: true`
|
|
109
|
+
- **Suite-level "all tests pass" is NOT a substitute for criterion-level proof.**
|
|
110
|
+
|
|
111
|
+
**Example — story-by-story verification**
|
|
112
|
+
|
|
113
|
+
Bad:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
Story US-002: "Add /api/users endpoint"
|
|
117
|
+
- Ran npm test → all green → marked passes: true
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Why bad: suite-level pass doesn't prove THIS story's criteria. Other tests could be passing while the new endpoint is broken.
|
|
121
|
+
|
|
122
|
+
Good:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Story US-002: "Add /api/users endpoint"
|
|
126
|
+
- Criterion 1: POST /api/users → 201 → ran `npx vitest tests/api-users.test.ts -t "valid input"` → PASS
|
|
127
|
+
- Criterion 2: POST /api/users → 400 → ran `npx vitest tests/api-users.test.ts -t "missing email"` → PASS
|
|
128
|
+
- Criterion 3: typecheck → ran `npm run build` → 0 errors
|
|
129
|
+
- All criteria met with fresh evidence → marked passes: true
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Why good: each criterion proven with a targeted run; the output was read before the mark.
|
|
133
|
+
|
|
134
|
+
5. **Commit if checks pass** — atomic commits per story
|
|
135
|
+
6. **Update prd.json** — mark story as `passes: true`
|
|
136
|
+
7. **Append learnings** — to `progress.txt`
|
|
137
|
+
8. **Repeat** — until all stories pass or max iterations reached
|
|
138
|
+
|
|
139
|
+
## Key Concepts
|
|
140
|
+
|
|
141
|
+
### Each Iteration = Fresh Context
|
|
142
|
+
|
|
143
|
+
Every story gets a clean slate. Previous work is visible only via git history and `prd.json`, preventing context pollution.
|
|
144
|
+
|
|
145
|
+
### Small Tasks
|
|
146
|
+
|
|
147
|
+
Stories should be completable in 10-30 minutes. If a story stalls, break it down.
|
|
148
|
+
|
|
149
|
+
### AGENTS.md Updates Are Critical
|
|
150
|
+
|
|
151
|
+
Ralph updates `AGENTS.md` after each story so subsequent iterations know what's already done.
|
|
152
|
+
|
|
153
|
+
### Feedback Loops
|
|
154
|
+
|
|
155
|
+
- Build/test failures: immediate fix or rollback
|
|
156
|
+
- Test failures: investigate before declaring pass
|
|
157
|
+
- Confusion: log to `progress.txt` for human review
|
|
158
|
+
|
|
159
|
+
### Browser Verification for UI Stories
|
|
160
|
+
|
|
161
|
+
Ralph starts a dev server and uses Playwright to verify UI stories actually render.
|
|
162
|
+
|
|
163
|
+
### Stop Condition
|
|
164
|
+
|
|
165
|
+
Ralph stops when:
|
|
166
|
+
- All stories have `passes: true`
|
|
167
|
+
- Max iterations reached
|
|
168
|
+
- Critical failure encountered (user intervention required)
|
|
169
|
+
|
|
170
|
+
## Anti-patterns
|
|
171
|
+
|
|
172
|
+
These thoughts mean STOP — Ralph is about to slip:
|
|
173
|
+
|
|
174
|
+
| Thought | Why it's wrong |
|
|
175
|
+
|---|---|
|
|
176
|
+
| "All stories pass, time to summarise and wait for the user" mid-loop | Polite-stop. Ralph continues through commit + progress update + next pick in the same turn. |
|
|
177
|
+
| "Tests pass at the suite level, the story must be done" | Suite-level pass is not criterion-level proof. Verify each criterion with fresh evidence. |
|
|
178
|
+
| "Story is bigger than expected, I'll mark it passes: true and add a TODO" | Scope reduction. Either complete the story or break it down — never declare partial completion. |
|
|
179
|
+
| "The criterion is generic but obviously the test covers it" | PRD theater. Refine the criterion to something specific before proceeding. |
|
|
180
|
+
| "I'll skip the failing test by deleting/skipping it" | Tests are evidence. Fix the implementation, not the test. |
|
|
181
|
+
| "Reviewer said it looks good" — without running fresh checks | "Looks good" is not verification. Run the build, run the tests, read the output. |
|
|
182
|
+
|
|
183
|
+
## Final Checklist (Hard Gate)
|
|
184
|
+
|
|
185
|
+
Ralph cannot exit cleanly until ALL of these are true:
|
|
186
|
+
|
|
187
|
+
- [ ] Every story in `prd.json` has `passes: true` (no incomplete stories)
|
|
188
|
+
- [ ] Acceptance criteria are task-specific (no `"Implementation is complete"` generics)
|
|
189
|
+
- [ ] All requirements from the original task are met (no scope reduction)
|
|
190
|
+
- [ ] Fresh test run output shows all tests pass (read it, don't assume)
|
|
191
|
+
- [ ] Fresh build output shows success (read it, don't assume)
|
|
192
|
+
- [ ] No tests were deleted, skipped, or weakened to make checks green
|
|
193
|
+
- [ ] `progress.txt` records implementation details and learnings per iteration
|
|
194
|
+
- [ ] Working tree is clean (every story committed atomically)
|
|
195
|
+
|
|
196
|
+
A failing checkbox is a hard halt — do not declare done.
|
|
197
|
+
|
|
198
|
+
## Files
|
|
199
|
+
|
|
200
|
+
- `prd.json` — executable PRD with user stories
|
|
201
|
+
- `progress.txt` — accumulated learnings and status
|
|
202
|
+
- `ralph.sh` — the loop script
|
|
203
|
+
- `AGENTS.md` — iteration memory
|
|
204
|
+
|
|
205
|
+
## Debugging
|
|
206
|
+
|
|
207
|
+
If Ralph gets stuck:
|
|
208
|
+
|
|
209
|
+
1. Check `prd.json` for malformed stories
|
|
210
|
+
2. Review `progress.txt` for accumulated errors
|
|
211
|
+
3. Verify tests pass independently: `npm test` or equivalent
|
|
212
|
+
4. Check git status for uncommitted changes
|
|
213
|
+
5. Run single iteration manually to isolate issues
|
|
214
|
+
|
|
215
|
+
## Customizing the Prompt
|
|
216
|
+
|
|
217
|
+
Edit the prompt template in `scripts/ralph/prompt.md` (Amp) or `scripts/ralph/CLAUDE.md` (Claude Code) to adjust behavior.
|
|
218
|
+
|
|
219
|
+
## Archiving
|
|
220
|
+
|
|
221
|
+
After completion, archive `prd.json` and `progress.txt` to `tasks/archive/[date]/` for future reference.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: recovery-classification
|
|
3
|
+
tier: "2"
|
|
4
|
+
description: "Enforces Law 4 (Verify Before Reporting) of the 7 Laws of AI Agent Discipline. After any failure in the verification ladder or auto-loop, classify the failure class before retrying — provider, tool-schema, deterministic-policy, git, worktree, runtime — so retry-vs-pause-vs-self-heal-vs-stop is an intentional decision, not a generic 'try again'."
|
|
5
|
+
origin: continuous-improvement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Recovery Classification Skill
|
|
9
|
+
|
|
10
|
+
When a phase or unit fails, name the failure class first. Generic "retry on failure" hides repeatable failure modes and turns them into flaky tests.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- After any Phase 1–6 failure in `verification-loop`.
|
|
15
|
+
- After any auto-loop unit that exits non-zero.
|
|
16
|
+
- After any tool call the harness rejects (schema validation, policy gate, deterministic block).
|
|
17
|
+
- Before re-running anything that just failed — classification fires once, before the first retry.
|
|
18
|
+
|
|
19
|
+
## Why This Skill Exists
|
|
20
|
+
|
|
21
|
+
GSD-2's [CONTEXT.md](https://github.com/gsd-build/gsd-2/blob/main/CONTEXT.md) names "Recovery Classification" as one of four runtime invariant modules. Common failure modes it catches:
|
|
22
|
+
|
|
23
|
+
- **Deterministic-policy blocks misclassified as generic provider failures** — gateguard denials retried in a loop until budget is exhausted.
|
|
24
|
+
- **Schema-validation failures retried verbatim** — wasting tokens on a call the validator will keep rejecting.
|
|
25
|
+
- **Stale-worker / stale-lock states** — no retry can resolve a worker that died holding a lock; the loop just spins.
|
|
26
|
+
- **Worktree-invalidity errors** — recovery can't fix without operator intervention; retrying writes to a broken root.
|
|
27
|
+
|
|
28
|
+
A retry without a class is a guess; a guess at scale is a budget leak.
|
|
29
|
+
|
|
30
|
+
## The Classification Taxonomy
|
|
31
|
+
|
|
32
|
+
Six classes. Each maps to one intentional action:
|
|
33
|
+
|
|
34
|
+
| Class | Signal | Action |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| **provider** | API timeout, 5xx, rate limit, network, transient cloud error | retry with exponential backoff |
|
|
37
|
+
| **tool-schema** | tool input rejected by validator, missing required field, type mismatch | repair input, do **not** retry verbatim |
|
|
38
|
+
| **deterministic-policy** | gateguard / write-gate / permission denied / explicit policy block | pause, ask operator (do **not** retry) |
|
|
39
|
+
| **git** | merge conflict, detached HEAD, unmerged paths, lockfile, pre-commit hook | self-heal if known recipe, else pause |
|
|
40
|
+
| **worktree** | missing `.git`, invalid root, lease lost, prunable worktree, foreign session | stop — never spawn workers into unresolved paths |
|
|
41
|
+
| **runtime** | OOM, segfault, host kill, parent process gone, context exhaustion | stop, surface to operator |
|
|
42
|
+
|
|
43
|
+
A failure that fits no class is `unclassified` — that itself is a signal: the taxonomy is incomplete and needs a new entry, not a retry.
|
|
44
|
+
|
|
45
|
+
## The Output Contract
|
|
46
|
+
|
|
47
|
+
Before any retry, emit one fenced block:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
recovery-classification:
|
|
51
|
+
failure: <one-line summary>
|
|
52
|
+
class: tool-schema
|
|
53
|
+
evidence: stderr line 14: "missing required field: workspace_id"
|
|
54
|
+
action: repair input (add workspace_id from session context), do NOT retry verbatim
|
|
55
|
+
retry budget: 2/3 remaining (this class)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Retry budgets are **per-class**, not global. A failed class that resolves on retry resets its budget; a class that exhausts its budget escalates to `pause` regardless of remaining global retries. This keeps a flaky network from masking a persistent schema bug.
|
|
59
|
+
|
|
60
|
+
## Anti-Patterns
|
|
61
|
+
|
|
62
|
+
- **One retry budget for all classes.** A network blip and a schema mismatch consume the same counter, so persistent schema bugs masquerade as "flaky network."
|
|
63
|
+
- **Auto-retry on `deterministic-policy`.** The gate exists exactly because retry is wrong. Pause instead and surface the policy that fired.
|
|
64
|
+
- **Classifying after retry.** The class informs the action; classifying afterward turns it into a post-mortem label and the loop has already misspent its budget.
|
|
65
|
+
- **Coalescing `worktree` into `git`.** Worktree errors are stop-class; git errors are usually self-heal-class. Conflating them lets workers spawn into broken roots.
|
|
66
|
+
- **Treating `unclassified` as `provider`.** Unknown is not transient. Force a taxonomy update; do not paper over the gap with a backoff.
|
|
67
|
+
|
|
68
|
+
## Pairs With
|
|
69
|
+
|
|
70
|
+
- [verification-loop](verification-loop.md) — every Phase 1–6 failure routes through here before any retry.
|
|
71
|
+
- [state-reconciliation](state-reconciliation.md) — runs before the next loop iteration when class is `git` or `runtime`, since those classes often leave drift behind.
|
|
72
|
+
- [worktree-safety](worktree-safety.md) — class `worktree` is exactly worktree-safety's failure surface; the two are co-defined.
|
|
73
|
+
- [gateguard](gateguard.md) — class `deterministic-policy` is gateguard's surface; recovery-classification names what gateguard already blocked.
|