ralphie 1.0.0 → 1.1.0
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/README.md +79 -22
- package/dist/cli.js +2982 -2701
- package/package.json +12 -4
- package/skills/SKILLS.md +69 -0
- package/skills/ralphie-iterate/SKILL.md +264 -751
- package/skills/ralphie-spec/SKILL.md +359 -0
- package/skills/review-spec/SKILL.md +367 -218
- package/templates/.claude/ralphie.md +2 -2
- package/templates/RALPHIE.md +87 -59
- package/templates/specs/active/.gitkeep +0 -0
- package/templates/specs/completed/.gitkeep +0 -0
- package/templates/specs/lessons.md +18 -0
- package/templates/specs/templates/bugfix.md +66 -0
- package/templates/specs/templates/feature.md +56 -0
- package/templates/specs/templates/refactor.md +80 -0
- package/skills/create-spec/SKILL.md +0 -222
- package/templates/.claude/skills/create-spec/SKILL.md +0 -222
- package/templates/.claude/skills/ralphie-iterate/SKILL.md +0 -959
|
@@ -1,959 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ralphie-iterate
|
|
3
|
-
description: Execute one Ralphie iteration - load context, explore codebase, plan implementation, write code with tests, review changes, and commit. Use this skill to run a single autonomous coding iteration following the Ralphie protocol.
|
|
4
|
-
context: fork
|
|
5
|
-
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Task, TodoWrite, LSP
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Ralphie Iteration Protocol
|
|
9
|
-
|
|
10
|
-
Execute ONE complete Ralphie iteration: read SPEC, plan, implement, test, review, commit.
|
|
11
|
-
|
|
12
|
-
**For coding standards** (language, style, testing, git, security), see `ralphie.md`.
|
|
13
|
-
|
|
14
|
-
## Claude Code Native Features
|
|
15
|
-
|
|
16
|
-
This skill leverages Claude Code's native capabilities:
|
|
17
|
-
|
|
18
|
-
| Feature | Tool | When Used |
|
|
19
|
-
|---------|------|-----------|
|
|
20
|
-
| **Codebase Exploration** | `Task(Explore)` | Step 2 - understand code before planning |
|
|
21
|
-
| **Progress Tracking** | `TodoWrite` | Steps 1-6 - track sub-task completion |
|
|
22
|
-
| **Code Review** | `Task(general-purpose)` | Step 5 - pre-commit review |
|
|
23
|
-
| **Iteration Validation** | Stop Hook | After Step 6 - verify iteration complete |
|
|
24
|
-
|
|
25
|
-
## Creating SPECs
|
|
26
|
-
|
|
27
|
-
**Use the `/create-spec` skill** for creating new SPECs. It provides:
|
|
28
|
-
- Structured interview process
|
|
29
|
-
- Proper task batching
|
|
30
|
-
- LLM-based review before finalizing
|
|
31
|
-
|
|
32
|
-
This skill (`ralphie-iterate`) is for **executing** iterations, not creating specs.
|
|
33
|
-
|
|
34
|
-
## Writing SPECs
|
|
35
|
-
|
|
36
|
-
Optimize for **iteration efficiency**. Each checkbox = one Ralphie iteration.
|
|
37
|
-
|
|
38
|
-
### Batch Related Tasks
|
|
39
|
-
|
|
40
|
-
```markdown
|
|
41
|
-
# BAD - 4 iterations
|
|
42
|
-
- [ ] Create UserModel.ts
|
|
43
|
-
- [ ] Create UserService.ts
|
|
44
|
-
- [ ] Create UserController.ts
|
|
45
|
-
- [ ] Create user.test.ts
|
|
46
|
-
|
|
47
|
-
# GOOD - 1 iteration
|
|
48
|
-
- [ ] Create User module (Model, Service, Controller) with tests
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**Batch when:**
|
|
52
|
-
- Same directory or tightly coupled files
|
|
53
|
-
- Similar structure (4 similar components = 1 task)
|
|
54
|
-
- Tests go with implementation
|
|
55
|
-
|
|
56
|
-
**Don't batch when:**
|
|
57
|
-
- Different areas of codebase
|
|
58
|
-
- Complex logic needing focus
|
|
59
|
-
- Independent failure modes
|
|
60
|
-
|
|
61
|
-
### What SPECs Should NOT Include
|
|
62
|
-
|
|
63
|
-
SPECs describe **requirements**, not solutions. Implementation details belong in `.ai/ralphie/plan.md`.
|
|
64
|
-
|
|
65
|
-
**Never include in SPEC.md:**
|
|
66
|
-
- Code snippets or fix approaches
|
|
67
|
-
- Specific file:line references (e.g., `setup.ts:150`)
|
|
68
|
-
- Root cause analysis ("The bug is in X because...")
|
|
69
|
-
- Technical implementation notes or "Technical Notes" sections
|
|
70
|
-
- Shell commands or CLI invocations
|
|
71
|
-
- "How to fix" instructions
|
|
72
|
-
|
|
73
|
-
**Sub-bullets are deliverables, not instructions:**
|
|
74
|
-
|
|
75
|
-
```markdown
|
|
76
|
-
# BAD - prescribes implementation
|
|
77
|
-
- [ ] Fix PR creation
|
|
78
|
-
- Use `git rev-list` to check unpushed commits
|
|
79
|
-
- Remove the early return at line 152
|
|
80
|
-
- Add `--token` flag to gh command
|
|
81
|
-
|
|
82
|
-
# GOOD - describes deliverables
|
|
83
|
-
- [ ] Fix PR creation flow
|
|
84
|
-
- Detect unpushed commits (not uncommitted changes)
|
|
85
|
-
- Push and create PR when commits exist
|
|
86
|
-
- Pass auth token correctly to gh CLI
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**Why this matters:**
|
|
90
|
-
- The implementer figures out HOW during Step 2 (Explore) and Step 3 (Plan)
|
|
91
|
-
- Over-specified SPECs constrain solutions and hide better approaches
|
|
92
|
-
- Requirements should be testable outcomes, not implementation checklists
|
|
93
|
-
|
|
94
|
-
**Run `ralphie validate` to check your SPEC for violations.**
|
|
95
|
-
|
|
96
|
-
## Step 1: Load Context
|
|
97
|
-
|
|
98
|
-
### 1.1 Read SPEC.md
|
|
99
|
-
|
|
100
|
-
Find the next incomplete task:
|
|
101
|
-
- Look for the first unchecked checkbox: `- [ ]`
|
|
102
|
-
- Skip checked items: `- [x]`
|
|
103
|
-
- A batched checkbox counts as ONE task (e.g., "Create components A, B, C" = 1 task)
|
|
104
|
-
|
|
105
|
-
```
|
|
106
|
-
Read SPEC.md → Find first `- [ ]` → This is your task for this iteration
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### 1.2 Check STATE.txt (if needed)
|
|
110
|
-
|
|
111
|
-
Read `STATE.txt` when:
|
|
112
|
-
- Unsure if a task was partially completed
|
|
113
|
-
- Need to understand blockers from previous iterations
|
|
114
|
-
- Want to verify what was done vs what SPEC shows
|
|
115
|
-
|
|
116
|
-
Look for:
|
|
117
|
-
- ✅ entries (completed work)
|
|
118
|
-
- ⚠️ entries (blockers or issues)
|
|
119
|
-
- Last completion timestamp
|
|
120
|
-
|
|
121
|
-
### 1.3 Read Recent Context
|
|
122
|
-
|
|
123
|
-
Read **last 3-5 entries** from `.ai/ralphie/index.md`:
|
|
124
|
-
- Extract file patterns (what files were recently changed)
|
|
125
|
-
- Note "next:" hints (what the previous iteration recommended)
|
|
126
|
-
- Understand recent architectural decisions
|
|
127
|
-
|
|
128
|
-
**Don't read the entire index** — only recent entries to stay context-efficient.
|
|
129
|
-
|
|
130
|
-
### 1.4 Break Down with TodoWrite
|
|
131
|
-
|
|
132
|
-
If the task has **3+ steps**, use TodoWrite to track sub-tasks:
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
TodoWrite({
|
|
136
|
-
todos: [
|
|
137
|
-
{
|
|
138
|
-
content: "Read existing auth code",
|
|
139
|
-
activeForm: "Reading existing auth code",
|
|
140
|
-
status: "pending"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
content: "Create login endpoint",
|
|
144
|
-
activeForm: "Creating login endpoint",
|
|
145
|
-
status: "pending"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
content: "Add input validation",
|
|
149
|
-
activeForm: "Adding input validation",
|
|
150
|
-
status: "pending"
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
content: "Write unit tests",
|
|
154
|
-
activeForm: "Writing unit tests",
|
|
155
|
-
status: "pending"
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
})
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**Required fields:**
|
|
162
|
-
- `content`: Imperative form (what to do)
|
|
163
|
-
- `activeForm`: Present continuous (what's happening)
|
|
164
|
-
- `status`: "pending" | "in_progress" | "completed"
|
|
165
|
-
|
|
166
|
-
**Skip TodoWrite when:**
|
|
167
|
-
- Task is atomic (single file, single change)
|
|
168
|
-
- Task is documentation-only
|
|
169
|
-
- Task can be completed in under 3 steps
|
|
170
|
-
|
|
171
|
-
## Step 2: Explore (if needed)
|
|
172
|
-
|
|
173
|
-
Before writing your plan, spawn parallel exploration agents to understand unfamiliar parts of the codebase. This is faster than reading files sequentially and helps you make better architectural decisions.
|
|
174
|
-
|
|
175
|
-
### 2.1 When to Explore
|
|
176
|
-
|
|
177
|
-
**Explore when:**
|
|
178
|
-
- Working in a new area of the codebase
|
|
179
|
-
- Task involves multiple interconnected modules
|
|
180
|
-
- Unsure about existing patterns or conventions
|
|
181
|
-
- Need to understand how similar features were implemented
|
|
182
|
-
|
|
183
|
-
**Skip when:**
|
|
184
|
-
- Working on files you've modified recently
|
|
185
|
-
- Simple changes to isolated functions
|
|
186
|
-
- Task specifies exact file paths in SPEC
|
|
187
|
-
- Documentation-only changes
|
|
188
|
-
|
|
189
|
-
### 2.2 Spawn Parallel Agents
|
|
190
|
-
|
|
191
|
-
Use the Task tool with `subagent_type='Explore'` to spawn agents that search the codebase in parallel. **Send all Task calls in a single message** to run them concurrently:
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
// Example: Exploring for an authentication feature
|
|
195
|
-
// Spawn all agents in ONE message (parallel execution)
|
|
196
|
-
|
|
197
|
-
Task({
|
|
198
|
-
subagent_type: 'Explore',
|
|
199
|
-
description: 'Find auth patterns',
|
|
200
|
-
prompt: 'Find how authentication is implemented. Look for middleware, JWT handling, session management. Report file paths and key patterns.'
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
Task({
|
|
204
|
-
subagent_type: 'Explore',
|
|
205
|
-
description: 'Find test patterns',
|
|
206
|
-
prompt: 'Find testing patterns for API endpoints. Look for test setup, mocking strategies, assertion patterns. Report examples I can follow.'
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
Task({
|
|
210
|
-
subagent_type: 'Explore',
|
|
211
|
-
description: 'Find error handling',
|
|
212
|
-
prompt: 'Find error handling patterns. Look for custom error classes, error middleware, response formatting. Report the conventions used.'
|
|
213
|
-
})
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### 2.3 What to Explore
|
|
217
|
-
|
|
218
|
-
Tailor your exploration prompts to your task:
|
|
219
|
-
|
|
220
|
-
| Need | Prompt Focus |
|
|
221
|
-
|------|--------------|
|
|
222
|
-
| **Architecture** | "How is [feature] structured? What files/modules are involved?" |
|
|
223
|
-
| **Patterns** | "What patterns are used for [X]? Show me examples." |
|
|
224
|
-
| **Dependencies** | "What does [module] depend on? What depends on it?" |
|
|
225
|
-
| **Conventions** | "What naming/file structure conventions are used?" |
|
|
226
|
-
| **Similar features** | "How is [existing similar feature] implemented?" |
|
|
227
|
-
|
|
228
|
-
### 2.4 Using Exploration Results
|
|
229
|
-
|
|
230
|
-
Once all agents complete:
|
|
231
|
-
|
|
232
|
-
1. **Wait for completion** — don't proceed until all agents return
|
|
233
|
-
2. **Extract file paths** — incorporate discovered paths into your plan's Files section
|
|
234
|
-
3. **Follow patterns** — use patterns the agents identify (don't invent new ones)
|
|
235
|
-
4. **Note concerns** — document any blockers or risks in your plan
|
|
236
|
-
5. **Update sub-tasks** — add/remove TodoWrite items based on findings
|
|
237
|
-
|
|
238
|
-
```
|
|
239
|
-
Exploration Results → Informs Plan → Guides Implementation
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## Step 3: Plan
|
|
243
|
-
|
|
244
|
-
Write your plan to `.ai/ralphie/plan.md` **before writing any code**. The plan is your contract for this iteration — it defines scope, prevents creep, and provides a clear completion target.
|
|
245
|
-
|
|
246
|
-
### 3.1 Write the Goal
|
|
247
|
-
|
|
248
|
-
The Goal is a **single sentence** that describes what this iteration accomplishes. It should be:
|
|
249
|
-
- **Specific**: Name the feature, component, or fix
|
|
250
|
-
- **Completable**: Something achievable in one iteration
|
|
251
|
-
- **Verifiable**: You can objectively confirm it's done
|
|
252
|
-
|
|
253
|
-
**Good goals:**
|
|
254
|
-
```markdown
|
|
255
|
-
## Goal
|
|
256
|
-
Add JWT token refresh endpoint that returns a new access token when given a valid refresh token.
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
```markdown
|
|
260
|
-
## Goal
|
|
261
|
-
Fix race condition in WebSocket reconnection that causes duplicate message handlers.
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
**Bad goals (too vague):**
|
|
265
|
-
```markdown
|
|
266
|
-
## Goal
|
|
267
|
-
Improve authentication. ← What specifically? Add? Fix? Refactor?
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
```markdown
|
|
271
|
-
## Goal
|
|
272
|
-
Work on the API. ← Which endpoint? What change?
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### 3.2 List the Files
|
|
276
|
-
|
|
277
|
-
List every file you plan to create or modify with a brief note about what changes:
|
|
278
|
-
|
|
279
|
-
```markdown
|
|
280
|
-
## Files
|
|
281
|
-
- src/auth/refresh.ts - create token refresh endpoint
|
|
282
|
-
- src/auth/middleware.ts - add refresh token validation
|
|
283
|
-
- src/auth/types.ts - add RefreshTokenPayload type
|
|
284
|
-
- tests/auth/refresh.test.ts - unit tests for refresh flow
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
**Guidelines:**
|
|
288
|
-
- **Be explicit** — list actual file paths, not "auth files"
|
|
289
|
-
- **Include tests** — every implementation file should have a corresponding test file
|
|
290
|
-
- **Note the action** — "create", "modify", "add", "fix", "remove"
|
|
291
|
-
- **Use exploration results** — if Step 2 found patterns in specific files, reference them
|
|
292
|
-
|
|
293
|
-
If you're unsure which files need changes, your exploration in Step 2 was incomplete. Go back and explore more before planning.
|
|
294
|
-
|
|
295
|
-
### 3.3 Define the Tests
|
|
296
|
-
|
|
297
|
-
List specific test scenarios that prove your implementation works. These become your acceptance criteria:
|
|
298
|
-
|
|
299
|
-
```markdown
|
|
300
|
-
## Tests
|
|
301
|
-
- Returns new access token when refresh token is valid
|
|
302
|
-
- Returns 401 when refresh token is expired
|
|
303
|
-
- Returns 401 when refresh token is revoked
|
|
304
|
-
- Returns 400 when refresh token is malformed
|
|
305
|
-
- Rotates refresh token on successful refresh (one-time use)
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
**Guidelines:**
|
|
309
|
-
- **Cover happy path** — at least one test for the success case
|
|
310
|
-
- **Cover error cases** — invalid input, edge cases, failures
|
|
311
|
-
- **Be specific** — "handles errors" is not a test; "returns 404 when user not found" is
|
|
312
|
-
- **Match existing patterns** — look at how similar features are tested in the codebase
|
|
313
|
-
|
|
314
|
-
**Skip when:**
|
|
315
|
-
- Task is documentation-only
|
|
316
|
-
- Task is configuration/setup (no logic to test)
|
|
317
|
-
- Existing tests already cover the change
|
|
318
|
-
|
|
319
|
-
### 3.4 Set Exit Criteria
|
|
320
|
-
|
|
321
|
-
Exit criteria are the **checkboxes you must check** before committing. They combine your goal, tests, and any additional requirements:
|
|
322
|
-
|
|
323
|
-
```markdown
|
|
324
|
-
## Exit Criteria
|
|
325
|
-
- Refresh endpoint returns new tokens for valid requests
|
|
326
|
-
- All 5 test scenarios pass
|
|
327
|
-
- Type checking passes (`npm run type-check`)
|
|
328
|
-
- No new linting errors
|
|
329
|
-
- Changes committed with conventional message
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
**Standard exit criteria (include most of these):**
|
|
333
|
-
- Feature/fix works as described in Goal
|
|
334
|
-
- Tests pass with good coverage (80%+ for new code)
|
|
335
|
-
- Type checking passes (if TypeScript)
|
|
336
|
-
- No linting errors
|
|
337
|
-
- Changes committed
|
|
338
|
-
|
|
339
|
-
**Additional criteria (when applicable):**
|
|
340
|
-
- Documentation updated (for public APIs)
|
|
341
|
-
- Migration added (for database changes)
|
|
342
|
-
- Environment variables documented (for new config)
|
|
343
|
-
|
|
344
|
-
### Complete Plan Example
|
|
345
|
-
|
|
346
|
-
```markdown
|
|
347
|
-
## Goal
|
|
348
|
-
Add JWT token refresh endpoint that returns a new access token when given a valid refresh token.
|
|
349
|
-
|
|
350
|
-
## Files
|
|
351
|
-
- src/auth/refresh.ts - create token refresh endpoint
|
|
352
|
-
- src/auth/middleware.ts - add refresh token validation helper
|
|
353
|
-
- src/auth/types.ts - add RefreshTokenPayload interface
|
|
354
|
-
- tests/auth/refresh.test.ts - unit tests
|
|
355
|
-
|
|
356
|
-
## Tests
|
|
357
|
-
- Returns new access token when refresh token is valid
|
|
358
|
-
- Returns 401 when refresh token is expired
|
|
359
|
-
- Returns 401 when refresh token is revoked
|
|
360
|
-
- Returns 400 when refresh token is malformed
|
|
361
|
-
- Rotates refresh token on successful refresh
|
|
362
|
-
|
|
363
|
-
## Exit Criteria
|
|
364
|
-
- Refresh endpoint works for valid requests
|
|
365
|
-
- All 5 test scenarios pass
|
|
366
|
-
- Type checking passes
|
|
367
|
-
- Changes committed
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
### After Writing the Plan
|
|
371
|
-
|
|
372
|
-
1. **Review scope** — Is this achievable in one iteration? If not, split the task.
|
|
373
|
-
2. **Update TodoWrite** — Add sub-tasks based on your Files list if not done in Step 1.
|
|
374
|
-
3. **Proceed to implementation** — Only start coding after the plan is written.
|
|
375
|
-
|
|
376
|
-
## Step 4: Implement
|
|
377
|
-
|
|
378
|
-
Now execute your plan. Write the code, write the tests, and verify everything works before proceeding to review.
|
|
379
|
-
|
|
380
|
-
### 4.1 Write the Code
|
|
381
|
-
|
|
382
|
-
Follow your plan's Files section. For each file:
|
|
383
|
-
|
|
384
|
-
1. **Read first** — Understand existing code before modifying
|
|
385
|
-
2. **Follow patterns** — Match the codebase's style, conventions, and architecture
|
|
386
|
-
3. **Keep it simple** — Don't over-engineer or add features beyond the plan
|
|
387
|
-
4. **Update TodoWrite** — Mark sub-task as `in_progress` when you start
|
|
388
|
-
|
|
389
|
-
```typescript
|
|
390
|
-
// Before starting a sub-task:
|
|
391
|
-
TodoWrite({
|
|
392
|
-
todos: [
|
|
393
|
-
{ content: "Create login endpoint", activeForm: "Creating login endpoint", status: "in_progress" },
|
|
394
|
-
{ content: "Add input validation", activeForm: "Adding input validation", status: "pending" },
|
|
395
|
-
// ...
|
|
396
|
-
]
|
|
397
|
-
})
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
**Implementation order:**
|
|
401
|
-
1. Types/interfaces first (if TypeScript)
|
|
402
|
-
2. Core logic
|
|
403
|
-
3. Integration points (exports, routes, etc.)
|
|
404
|
-
4. Tests (or write alongside — see 4.2)
|
|
405
|
-
|
|
406
|
-
**Avoid:**
|
|
407
|
-
- Adding comments unless truly necessary (code should be self-documenting)
|
|
408
|
-
- Creating new patterns when existing patterns work
|
|
409
|
-
- Scope creep — if you discover something outside the plan, note it for the next iteration
|
|
410
|
-
|
|
411
|
-
### 4.2 Write the Tests
|
|
412
|
-
|
|
413
|
-
Write tests that match your plan's Tests section. Each test scenario becomes a test case.
|
|
414
|
-
|
|
415
|
-
**Test structure:**
|
|
416
|
-
```typescript
|
|
417
|
-
describe('RefreshToken', () => {
|
|
418
|
-
describe('refresh', () => {
|
|
419
|
-
it('returns new access token when refresh token is valid', async () => {
|
|
420
|
-
// Arrange - set up test data
|
|
421
|
-
const refreshToken = createValidRefreshToken();
|
|
422
|
-
|
|
423
|
-
// Act - call the function
|
|
424
|
-
const result = await refresh(refreshToken);
|
|
425
|
-
|
|
426
|
-
// Assert - verify the outcome
|
|
427
|
-
expect(result.accessToken).toBeDefined();
|
|
428
|
-
expect(result.expiresIn).toBe(3600);
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
it('returns 401 when refresh token is expired', async () => {
|
|
432
|
-
const expiredToken = createExpiredRefreshToken();
|
|
433
|
-
|
|
434
|
-
await expect(refresh(expiredToken))
|
|
435
|
-
.rejects.toThrow(UnauthorizedError);
|
|
436
|
-
});
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
**Guidelines:**
|
|
442
|
-
- **One assertion per test** (when practical) — easier to debug failures
|
|
443
|
-
- **Descriptive names** — test name should describe the scenario
|
|
444
|
-
- **Cover the plan** — every test in your Tests section should become a real test
|
|
445
|
-
- **Match existing patterns** — look at how similar features are tested
|
|
446
|
-
|
|
447
|
-
**Update TodoWrite after writing tests:**
|
|
448
|
-
```typescript
|
|
449
|
-
TodoWrite({
|
|
450
|
-
todos: [
|
|
451
|
-
{ content: "Create login endpoint", activeForm: "Creating login endpoint", status: "completed" },
|
|
452
|
-
{ content: "Add input validation", activeForm: "Adding input validation", status: "completed" },
|
|
453
|
-
{ content: "Write unit tests", activeForm: "Writing unit tests", status: "in_progress" },
|
|
454
|
-
// ...
|
|
455
|
-
]
|
|
456
|
-
})
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
### 4.3 Run Tests
|
|
460
|
-
|
|
461
|
-
Run the full test suite to verify your implementation:
|
|
462
|
-
|
|
463
|
-
```bash
|
|
464
|
-
# Standard commands (use project-specific if different)
|
|
465
|
-
npm test # Run all tests
|
|
466
|
-
npm test -- --coverage # Run with coverage report
|
|
467
|
-
npm test -- path/to/file # Run specific test file
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
**What to check:**
|
|
471
|
-
- All tests pass (especially your new ones)
|
|
472
|
-
- No regressions in existing tests
|
|
473
|
-
- Coverage meets requirements (80%+ for new code)
|
|
474
|
-
|
|
475
|
-
**If tests fail:**
|
|
476
|
-
1. Read the error message carefully
|
|
477
|
-
2. Fix the failing test or implementation
|
|
478
|
-
3. Re-run tests
|
|
479
|
-
4. Don't proceed until all tests pass
|
|
480
|
-
|
|
481
|
-
### 4.4 Run Type Check
|
|
482
|
-
|
|
483
|
-
For TypeScript projects, verify types before proceeding:
|
|
484
|
-
|
|
485
|
-
```bash
|
|
486
|
-
npm run type-check # or: npx tsc --noEmit
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
**Common type errors and fixes:**
|
|
490
|
-
|
|
491
|
-
| Error | Fix |
|
|
492
|
-
|-------|-----|
|
|
493
|
-
| `Property does not exist` | Add the property to the interface or check for typos |
|
|
494
|
-
| `Type X is not assignable to Y` | Fix the type mismatch or add proper type casting |
|
|
495
|
-
| `Cannot find module` | Check import path or add missing dependency |
|
|
496
|
-
| `Argument of type X is not assignable` | Update function signature or caller |
|
|
497
|
-
|
|
498
|
-
**Don't proceed with type errors.** They often indicate real bugs.
|
|
499
|
-
|
|
500
|
-
### 4.5 Handle Failures
|
|
501
|
-
|
|
502
|
-
If tests or type checking fail repeatedly:
|
|
503
|
-
|
|
504
|
-
1. **Don't force it** — Repeated failures signal a deeper issue
|
|
505
|
-
2. **Check your plan** — Did you miss something in the Files section?
|
|
506
|
-
3. **Revisit exploration** — Maybe you need more context
|
|
507
|
-
4. **Scope down** — Can you complete a smaller portion of the task?
|
|
508
|
-
|
|
509
|
-
**If blocked:**
|
|
510
|
-
```typescript
|
|
511
|
-
// Update TodoWrite to reflect the blocker
|
|
512
|
-
TodoWrite({
|
|
513
|
-
todos: [
|
|
514
|
-
{ content: "Create login endpoint", activeForm: "Creating login endpoint", status: "completed" },
|
|
515
|
-
{ content: "Fix type error in auth middleware", activeForm: "Fixing type error", status: "in_progress" },
|
|
516
|
-
// Don't mark as completed if you can't finish it
|
|
517
|
-
]
|
|
518
|
-
})
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
If you can't complete the task:
|
|
522
|
-
- Don't commit partial/broken code
|
|
523
|
-
- Document the blocker in STATE.txt
|
|
524
|
-
- Stop the iteration — the next iteration will pick it up
|
|
525
|
-
|
|
526
|
-
### Implementation Checklist
|
|
527
|
-
|
|
528
|
-
Before proceeding to Review:
|
|
529
|
-
|
|
530
|
-
- [ ] All planned files created/modified
|
|
531
|
-
- [ ] Code follows existing patterns
|
|
532
|
-
- [ ] Tests written for all planned scenarios
|
|
533
|
-
- [ ] `npm test` passes
|
|
534
|
-
- [ ] `npm run type-check` passes (TypeScript)
|
|
535
|
-
- [ ] TodoWrite sub-tasks marked as completed
|
|
536
|
-
|
|
537
|
-
## Step 5: Review
|
|
538
|
-
|
|
539
|
-
Before committing, spawn a review agent to catch bugs, verify patterns, and ensure quality. This step prevents shipping broken code and helps maintain codebase consistency.
|
|
540
|
-
|
|
541
|
-
### 5.1 When to Review
|
|
542
|
-
|
|
543
|
-
**Review when:**
|
|
544
|
-
- You wrote more than 20 lines of new code
|
|
545
|
-
- You modified existing business logic
|
|
546
|
-
- You added or changed API endpoints
|
|
547
|
-
- You made security-relevant changes (auth, validation, encryption)
|
|
548
|
-
- You're uncertain about your implementation approach
|
|
549
|
-
|
|
550
|
-
**Skip when:**
|
|
551
|
-
- Task is documentation-only
|
|
552
|
-
- Changes are config/setup files only
|
|
553
|
-
- Changes are purely stylistic (formatting, renaming)
|
|
554
|
-
- You only deleted code without adding anything new
|
|
555
|
-
|
|
556
|
-
### 5.2 Spawn Review Agent
|
|
557
|
-
|
|
558
|
-
Use the Task tool with `subagent_type='general-purpose'` to spawn a review agent. Provide context about the task and list the files you changed:
|
|
559
|
-
|
|
560
|
-
```typescript
|
|
561
|
-
Task({
|
|
562
|
-
subagent_type: 'general-purpose',
|
|
563
|
-
description: 'Review code changes',
|
|
564
|
-
prompt: `Review the following code changes for: [TASK DESCRIPTION]
|
|
565
|
-
|
|
566
|
-
## Files Changed
|
|
567
|
-
- [file1.ts] - [what was changed]
|
|
568
|
-
- [file2.ts] - [what was changed]
|
|
569
|
-
- [file.test.ts] - [tests added]
|
|
570
|
-
|
|
571
|
-
## Review Checklist
|
|
572
|
-
Please check for:
|
|
573
|
-
1. **Bugs** - Logic errors, off-by-one, null handling, race conditions
|
|
574
|
-
2. **Test coverage** - Are edge cases tested? Any missing scenarios?
|
|
575
|
-
3. **Patterns** - Does the code follow existing codebase patterns?
|
|
576
|
-
4. **Security** - Input validation, injection risks, auth bypasses
|
|
577
|
-
5. **Performance** - N+1 queries, unnecessary loops, memory leaks
|
|
578
|
-
|
|
579
|
-
## Response Format
|
|
580
|
-
Respond with ONE of:
|
|
581
|
-
- **CRITICAL**: Must-fix issues that would cause bugs or security problems
|
|
582
|
-
- **SUGGESTIONS**: Optional improvements (style, naming, minor optimizations)
|
|
583
|
-
- **APPROVED**: Code is ready to commit
|
|
584
|
-
|
|
585
|
-
If CRITICAL, list each issue with file:line and a brief fix description.`
|
|
586
|
-
})
|
|
587
|
-
```
|
|
588
|
-
|
|
589
|
-
**Customize the prompt for your task:**
|
|
590
|
-
- For API changes, emphasize validation and error handling
|
|
591
|
-
- For database changes, emphasize migrations and query performance
|
|
592
|
-
- For auth changes, emphasize security review
|
|
593
|
-
- For UI changes, emphasize user experience and accessibility
|
|
594
|
-
|
|
595
|
-
### 5.3 Handle Review Feedback
|
|
596
|
-
|
|
597
|
-
The review agent will respond with one of three outcomes:
|
|
598
|
-
|
|
599
|
-
| Response | Action |
|
|
600
|
-
|----------|--------|
|
|
601
|
-
| **CRITICAL** | **Must fix** - Address every critical issue before committing |
|
|
602
|
-
| **SUGGESTIONS** | **Optional** - Address if quick (<5 min), otherwise note for future |
|
|
603
|
-
| **APPROVED** | **Proceed** - Move to Step 6 (Commit) |
|
|
604
|
-
|
|
605
|
-
**Handling CRITICAL feedback:**
|
|
606
|
-
|
|
607
|
-
1. **Read the issues** - Each critical issue should include file:line and description
|
|
608
|
-
2. **Fix in priority order** - Security > Bugs > Breaking changes
|
|
609
|
-
3. **Re-run tests** - Ensure fixes didn't break anything
|
|
610
|
-
4. **Re-run type check** - Ensure fixes don't introduce type errors
|
|
611
|
-
5. **Request re-review** - Spawn another review agent to verify fixes
|
|
612
|
-
|
|
613
|
-
```typescript
|
|
614
|
-
// After fixing critical issues, re-review:
|
|
615
|
-
Task({
|
|
616
|
-
subagent_type: 'general-purpose',
|
|
617
|
-
description: 'Re-review fixes',
|
|
618
|
-
prompt: `Re-review after fixing critical issues.
|
|
619
|
-
|
|
620
|
-
## Original Issues (now fixed)
|
|
621
|
-
- [Issue 1]: Fixed by [change]
|
|
622
|
-
- [Issue 2]: Fixed by [change]
|
|
623
|
-
|
|
624
|
-
## Files Changed
|
|
625
|
-
- [file1.ts] - [original change + fix]
|
|
626
|
-
|
|
627
|
-
Verify fixes are correct. Respond: CRITICAL, SUGGESTIONS, or APPROVED.`
|
|
628
|
-
})
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
**Handling SUGGESTIONS:**
|
|
632
|
-
|
|
633
|
-
Suggestions are optional but valuable:
|
|
634
|
-
- Address if the fix is quick (< 5 minutes)
|
|
635
|
-
- Skip if the suggestion is stylistic preference
|
|
636
|
-
- Note valuable suggestions in your commit message or index.md for future iterations
|
|
637
|
-
|
|
638
|
-
### 5.4 Review Flow Example
|
|
639
|
-
|
|
640
|
-
```
|
|
641
|
-
Implementation Complete
|
|
642
|
-
│
|
|
643
|
-
▼
|
|
644
|
-
┌─────────────────────┐
|
|
645
|
-
│ Spawn Review Agent │
|
|
646
|
-
└─────────────────────┘
|
|
647
|
-
│
|
|
648
|
-
▼
|
|
649
|
-
┌─────────┐
|
|
650
|
-
│ RESULT? │
|
|
651
|
-
└─────────┘
|
|
652
|
-
│
|
|
653
|
-
┌────┼────┬────────────┐
|
|
654
|
-
│ │ │ │
|
|
655
|
-
▼ │ ▼ ▼
|
|
656
|
-
CRITICAL │ SUGGESTIONS APPROVED
|
|
657
|
-
│ │ │ │
|
|
658
|
-
▼ │ ▼ ▼
|
|
659
|
-
Fix │ Optional Proceed
|
|
660
|
-
Issues │ Fixes to Commit
|
|
661
|
-
│ │ │ │
|
|
662
|
-
▼ │ ▼ │
|
|
663
|
-
Re-review│ Proceed │
|
|
664
|
-
│ │ │ │
|
|
665
|
-
└────┴────┴────────────┘
|
|
666
|
-
│
|
|
667
|
-
▼
|
|
668
|
-
Step 6: Commit
|
|
669
|
-
```
|
|
670
|
-
|
|
671
|
-
### 5.5 Update TodoWrite
|
|
672
|
-
|
|
673
|
-
After review completes, update your sub-tasks:
|
|
674
|
-
|
|
675
|
-
```typescript
|
|
676
|
-
TodoWrite({
|
|
677
|
-
todos: [
|
|
678
|
-
{ content: "Write implementation code", activeForm: "Writing code", status: "completed" },
|
|
679
|
-
{ content: "Write unit tests", activeForm: "Writing tests", status: "completed" },
|
|
680
|
-
{ content: "Run tests and type check", activeForm: "Running verification", status: "completed" },
|
|
681
|
-
{ content: "Code review", activeForm: "Reviewing code", status: "completed" },
|
|
682
|
-
{ content: "Commit changes", activeForm: "Committing", status: "pending" }
|
|
683
|
-
]
|
|
684
|
-
})
|
|
685
|
-
```
|
|
686
|
-
|
|
687
|
-
### Review Checklist
|
|
688
|
-
|
|
689
|
-
Before proceeding to Commit:
|
|
690
|
-
|
|
691
|
-
- [ ] Review agent spawned with appropriate context
|
|
692
|
-
- [ ] All CRITICAL issues addressed
|
|
693
|
-
- [ ] Tests still pass after any fixes
|
|
694
|
-
- [ ] Type check still passes after any fixes
|
|
695
|
-
- [ ] Response is APPROVED or SUGGESTIONS-only
|
|
696
|
-
|
|
697
|
-
## Step 6: Commit
|
|
698
|
-
|
|
699
|
-
After your implementation passes review, commit your changes and update the tracking files. This step completes the iteration and leaves a clean trail for the next one.
|
|
700
|
-
|
|
701
|
-
### 6.1 Stage Your Changes
|
|
702
|
-
|
|
703
|
-
Stage only the files listed in your plan. Don't stage unrelated changes:
|
|
704
|
-
|
|
705
|
-
```bash
|
|
706
|
-
# Stage specific files (preferred)
|
|
707
|
-
git add src/auth/refresh.ts src/auth/types.ts tests/auth/refresh.test.ts
|
|
708
|
-
|
|
709
|
-
# Or stage all tracked changes if you're certain
|
|
710
|
-
git add -A
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
**Pre-stage checklist:**
|
|
714
|
-
- [ ] Only files from your plan's Files section
|
|
715
|
-
- [ ] No temporary files, logs, or build artifacts
|
|
716
|
-
- [ ] No `.env` files or secrets
|
|
717
|
-
- [ ] No unintended formatting changes in other files
|
|
718
|
-
|
|
719
|
-
**Check what you're committing:**
|
|
720
|
-
```bash
|
|
721
|
-
git status # See staged files
|
|
722
|
-
git diff --staged # Review staged changes
|
|
723
|
-
```
|
|
724
|
-
|
|
725
|
-
### 6.2 Write the Commit Message
|
|
726
|
-
|
|
727
|
-
Use [Conventional Commits](https://www.conventionalcommits.org/) format. Always use a HEREDOC for proper multi-line formatting:
|
|
728
|
-
|
|
729
|
-
```bash
|
|
730
|
-
git commit -m "$(cat <<'EOF'
|
|
731
|
-
type(scope): brief description
|
|
732
|
-
|
|
733
|
-
Longer explanation if needed.
|
|
734
|
-
|
|
735
|
-
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
736
|
-
|
|
737
|
-
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
738
|
-
EOF
|
|
739
|
-
)"
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
**Commit types:**
|
|
743
|
-
| Type | Use for |
|
|
744
|
-
|------|---------|
|
|
745
|
-
| `feat` | New feature or functionality |
|
|
746
|
-
| `fix` | Bug fix |
|
|
747
|
-
| `refactor` | Code change that doesn't add feature or fix bug |
|
|
748
|
-
| `test` | Adding or updating tests |
|
|
749
|
-
| `docs` | Documentation only |
|
|
750
|
-
| `chore` | Maintenance tasks, dependency updates |
|
|
751
|
-
|
|
752
|
-
**Examples:**
|
|
753
|
-
```
|
|
754
|
-
feat(auth): add JWT token refresh endpoint
|
|
755
|
-
fix(api): handle null response from user service
|
|
756
|
-
refactor(utils): extract validation into shared module
|
|
757
|
-
test(auth): add edge case tests for token expiry
|
|
758
|
-
docs(readme): add API documentation
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
**Scope guidelines:**
|
|
762
|
-
- Use the feature area or module name: `auth`, `api`, `ui`, `db`
|
|
763
|
-
- Keep it lowercase and short (1-2 words)
|
|
764
|
-
- Be consistent with existing commits in the repo
|
|
765
|
-
|
|
766
|
-
### 6.3 Update index.md
|
|
767
|
-
|
|
768
|
-
After committing, append an entry to `.ai/ralphie/index.md`. This creates a searchable history of what each iteration accomplished.
|
|
769
|
-
|
|
770
|
-
**Get your commit SHA:**
|
|
771
|
-
```bash
|
|
772
|
-
git log -1 --format='%h' # Short SHA (7 chars)
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
**Entry format:**
|
|
776
|
-
```markdown
|
|
777
|
-
## {sha} — {commit message}
|
|
778
|
-
- files: {list of changed files}
|
|
779
|
-
- tests: {test count} passing
|
|
780
|
-
- notes: {key decisions, patterns used, gotchas}
|
|
781
|
-
- next: {logical follow-up task or recommendation}
|
|
782
|
-
```
|
|
783
|
-
|
|
784
|
-
**Example entry:**
|
|
785
|
-
```markdown
|
|
786
|
-
## a1b2c3d — feat(auth): add JWT token refresh endpoint
|
|
787
|
-
- files: src/auth/refresh.ts, src/auth/types.ts, tests/auth/refresh.test.ts
|
|
788
|
-
- tests: 8 passing
|
|
789
|
-
- notes: Used existing JWT library, added refresh token rotation for security
|
|
790
|
-
- next: Add token revocation endpoint for logout
|
|
791
|
-
```
|
|
792
|
-
|
|
793
|
-
**Guidelines:**
|
|
794
|
-
- **Keep it concise** — 5-7 lines max per entry
|
|
795
|
-
- **files**: List actual filenames, not directories
|
|
796
|
-
- **tests**: Include count (get from `npm test` output)
|
|
797
|
-
- **notes**: Capture decisions future iterations need to know
|
|
798
|
-
- **next**: Suggest what should come next (helps the next iteration)
|
|
799
|
-
|
|
800
|
-
### 6.4 Update SPEC.md
|
|
801
|
-
|
|
802
|
-
Check off the completed task in `SPEC.md`:
|
|
803
|
-
|
|
804
|
-
```markdown
|
|
805
|
-
# Before
|
|
806
|
-
- [ ] Add JWT token refresh endpoint with tests
|
|
807
|
-
|
|
808
|
-
# After
|
|
809
|
-
- [x] Add JWT token refresh endpoint with tests
|
|
810
|
-
```
|
|
811
|
-
|
|
812
|
-
**Rules:**
|
|
813
|
-
- Only check off tasks that are **fully complete**
|
|
814
|
-
- One checkbox = one iteration (don't check multiple)
|
|
815
|
-
- If you couldn't complete the task, leave it unchecked
|
|
816
|
-
|
|
817
|
-
### 6.5 Update STATE.txt
|
|
818
|
-
|
|
819
|
-
Append a completion record to `STATE.txt`:
|
|
820
|
-
|
|
821
|
-
```markdown
|
|
822
|
-
✅ YYYY-MM-DD: {Brief description of what was done}
|
|
823
|
-
- {Key detail 1}
|
|
824
|
-
- {Key detail 2}
|
|
825
|
-
- Tests: {count} passing
|
|
826
|
-
- Commit: {sha} {commit message}
|
|
827
|
-
```
|
|
828
|
-
|
|
829
|
-
**Example:**
|
|
830
|
-
```markdown
|
|
831
|
-
✅ 2026-01-12: Added JWT token refresh endpoint
|
|
832
|
-
- Created refresh.ts with token validation and rotation
|
|
833
|
-
- Added RefreshTokenPayload interface to types.ts
|
|
834
|
-
- Tests: 8 passing (refresh.test.ts)
|
|
835
|
-
- Commit: a1b2c3d feat(auth): add JWT token refresh endpoint
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
**If task was blocked:**
|
|
839
|
-
```markdown
|
|
840
|
-
⚠️ 2026-01-12: JWT token refresh - BLOCKED
|
|
841
|
-
- Issue: Existing JWT library doesn't support refresh tokens
|
|
842
|
-
- Attempted: Custom implementation but hit type conflicts
|
|
843
|
-
- Next: Evaluate alternative JWT libraries
|
|
844
|
-
```
|
|
845
|
-
|
|
846
|
-
### 6.6 Update TodoWrite
|
|
847
|
-
|
|
848
|
-
Complete all sub-tasks:
|
|
849
|
-
|
|
850
|
-
```typescript
|
|
851
|
-
TodoWrite({
|
|
852
|
-
todos: [
|
|
853
|
-
{ content: "Write implementation code", activeForm: "Writing code", status: "completed" },
|
|
854
|
-
{ content: "Write unit tests", activeForm: "Writing tests", status: "completed" },
|
|
855
|
-
{ content: "Run tests and type check", activeForm: "Running verification", status: "completed" },
|
|
856
|
-
{ content: "Code review", activeForm: "Reviewing code", status: "completed" },
|
|
857
|
-
{ content: "Commit changes", activeForm: "Committing", status: "completed" }
|
|
858
|
-
]
|
|
859
|
-
})
|
|
860
|
-
```
|
|
861
|
-
|
|
862
|
-
**After updating:**
|
|
863
|
-
- All sub-tasks should be `completed`
|
|
864
|
-
- The TodoWrite list shows the user the iteration is done
|
|
865
|
-
- Clear the list for the next iteration (or let the next iteration reset it)
|
|
866
|
-
|
|
867
|
-
### Commit Checklist
|
|
868
|
-
|
|
869
|
-
Before considering this iteration complete:
|
|
870
|
-
|
|
871
|
-
- [ ] All planned files are staged
|
|
872
|
-
- [ ] No unintended files staged (run `git status`)
|
|
873
|
-
- [ ] Commit message follows conventional format
|
|
874
|
-
- [ ] Commit message uses HEREDOC (no escaping issues)
|
|
875
|
-
- [ ] `.ai/ralphie/index.md` has new entry with correct SHA
|
|
876
|
-
- [ ] `SPEC.md` task is checked off: `- [x]`
|
|
877
|
-
- [ ] `STATE.txt` has completion record
|
|
878
|
-
- [ ] TodoWrite sub-tasks marked completed
|
|
879
|
-
|
|
880
|
-
### Commit Flow Example
|
|
881
|
-
|
|
882
|
-
```
|
|
883
|
-
Tests Pass + Review Approved
|
|
884
|
-
│
|
|
885
|
-
▼
|
|
886
|
-
┌────────────────────────┐
|
|
887
|
-
│ git add [files] │
|
|
888
|
-
│ git status (verify) │
|
|
889
|
-
└────────────────────────┘
|
|
890
|
-
│
|
|
891
|
-
▼
|
|
892
|
-
┌────────────────────────┐
|
|
893
|
-
│ git commit with │
|
|
894
|
-
│ HEREDOC message │
|
|
895
|
-
└────────────────────────┘
|
|
896
|
-
│
|
|
897
|
-
▼
|
|
898
|
-
┌────────────────────────┐
|
|
899
|
-
│ Get SHA: git log -1 │
|
|
900
|
-
│ Append to index.md │
|
|
901
|
-
└────────────────────────┘
|
|
902
|
-
│
|
|
903
|
-
▼
|
|
904
|
-
┌────────────────────────┐
|
|
905
|
-
│ Update SPEC.md │
|
|
906
|
-
│ - [ ] → - [x] │
|
|
907
|
-
└────────────────────────┘
|
|
908
|
-
│
|
|
909
|
-
▼
|
|
910
|
-
┌────────────────────────┐
|
|
911
|
-
│ Update STATE.txt │
|
|
912
|
-
│ ✅ completion record │
|
|
913
|
-
└────────────────────────┘
|
|
914
|
-
│
|
|
915
|
-
▼
|
|
916
|
-
┌────────────────────────┐
|
|
917
|
-
│ TodoWrite: all │
|
|
918
|
-
│ status: "completed" │
|
|
919
|
-
└────────────────────────┘
|
|
920
|
-
│
|
|
921
|
-
▼
|
|
922
|
-
ITERATION DONE
|
|
923
|
-
```
|
|
924
|
-
|
|
925
|
-
## Hard Rules
|
|
926
|
-
|
|
927
|
-
- ONE task per iteration (batched checkbox = one task)
|
|
928
|
-
- Plan BEFORE coding
|
|
929
|
-
- Tests MUST pass before commit
|
|
930
|
-
- No commit = no index entry
|
|
931
|
-
- Mark SPEC task complete only after commit
|
|
932
|
-
|
|
933
|
-
## Hooks Configuration
|
|
934
|
-
|
|
935
|
-
Ralphie uses a **Stop hook** to validate iteration completion. Configure in `.claude/settings.json`:
|
|
936
|
-
|
|
937
|
-
```json
|
|
938
|
-
{
|
|
939
|
-
"hooks": {
|
|
940
|
-
"Stop": [
|
|
941
|
-
{
|
|
942
|
-
"type": "prompt",
|
|
943
|
-
"promptFile": "scripts/validate-iteration.md"
|
|
944
|
-
}
|
|
945
|
-
]
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
**What the hook validates:**
|
|
951
|
-
1. Task implemented (code changes made)
|
|
952
|
-
2. Tests pass (`npm test`)
|
|
953
|
-
3. Type check passes (`npm run type-check`)
|
|
954
|
-
4. Commit made with conventional message
|
|
955
|
-
5. `index.md` updated with new entry
|
|
956
|
-
6. `SPEC.md` task checked off
|
|
957
|
-
7. `STATE.txt` has completion record
|
|
958
|
-
|
|
959
|
-
**If validation fails:** Fix the issue before the next iteration starts.
|