anvil-dev-framework 0.1.6
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 +719 -0
- package/VERSION +1 -0
- package/docs/ANVIL-REPO-IMPLEMENTATION-PLAN.md +441 -0
- package/docs/FIRST-SKILL-TUTORIAL.md +408 -0
- package/docs/INSTALLATION-RETRO-NOTES.md +458 -0
- package/docs/INSTALLATION.md +984 -0
- package/docs/anvil-hud.md +469 -0
- package/docs/anvil-init.md +255 -0
- package/docs/anvil-state.md +210 -0
- package/docs/boris-cherny-ralph-wiggum-insights.md +608 -0
- package/docs/command-reference.md +2022 -0
- package/docs/hooks-tts.md +368 -0
- package/docs/implementation-guide.md +810 -0
- package/docs/linear-github-integration.md +247 -0
- package/docs/local-issues.md +677 -0
- package/docs/patterns/README.md +419 -0
- package/docs/planning-responsibilities.md +139 -0
- package/docs/session-workflow.md +573 -0
- package/docs/simplification-plan-template.md +297 -0
- package/docs/simplification-principles.md +129 -0
- package/docs/specifications/CCS-RALPH-INTEGRATION-DESIGN.md +633 -0
- package/docs/specifications/CCS-RESEARCH-REPORT.md +169 -0
- package/docs/specifications/PLAN-ANV-verification-ralph-wiggum.md +403 -0
- package/docs/specifications/PLAN-parallel-tracks-anvil-memory-ccs.md +494 -0
- package/docs/specifications/SPEC-ANV-VRW/component-01-verify.md +208 -0
- package/docs/specifications/SPEC-ANV-VRW/component-02-stop-gate.md +226 -0
- package/docs/specifications/SPEC-ANV-VRW/component-03-posttooluse.md +209 -0
- package/docs/specifications/SPEC-ANV-VRW/component-04-ralph-wiggum.md +604 -0
- package/docs/specifications/SPEC-ANV-VRW/component-05-atomic-actions.md +311 -0
- package/docs/specifications/SPEC-ANV-VRW/component-06-verify-subagent.md +264 -0
- package/docs/specifications/SPEC-ANV-VRW/component-07-claude-md.md +363 -0
- package/docs/specifications/SPEC-ANV-VRW/index.md +182 -0
- package/docs/specifications/SPEC-ANV-anvil-memory.md +573 -0
- package/docs/specifications/SPEC-ANV-context-checkpoints.md +781 -0
- package/docs/specifications/SPEC-ANV-verification-ralph-wiggum.md +789 -0
- package/docs/sync.md +122 -0
- package/global/CLAUDE.md +140 -0
- package/global/agents/verify-app.md +164 -0
- package/global/commands/anvil-settings.md +527 -0
- package/global/commands/anvil-sync.md +121 -0
- package/global/commands/change.md +197 -0
- package/global/commands/clarify.md +252 -0
- package/global/commands/cleanup.md +292 -0
- package/global/commands/commit-push-pr.md +207 -0
- package/global/commands/decay-review.md +127 -0
- package/global/commands/discover.md +158 -0
- package/global/commands/doc-coverage.md +122 -0
- package/global/commands/evidence.md +307 -0
- package/global/commands/explore.md +121 -0
- package/global/commands/force-exit.md +135 -0
- package/global/commands/handoff.md +191 -0
- package/global/commands/healthcheck.md +302 -0
- package/global/commands/hud.md +84 -0
- package/global/commands/insights.md +319 -0
- package/global/commands/linear-setup.md +184 -0
- package/global/commands/lint-fix.md +198 -0
- package/global/commands/orient.md +510 -0
- package/global/commands/plan.md +228 -0
- package/global/commands/ralph.md +346 -0
- package/global/commands/ready.md +182 -0
- package/global/commands/release.md +305 -0
- package/global/commands/retro.md +96 -0
- package/global/commands/shard.md +166 -0
- package/global/commands/spec.md +227 -0
- package/global/commands/sprint.md +184 -0
- package/global/commands/tasks.md +228 -0
- package/global/commands/test-and-commit.md +151 -0
- package/global/commands/validate.md +132 -0
- package/global/commands/verify.md +251 -0
- package/global/commands/weekly-review.md +156 -0
- package/global/hooks/__pycache__/ralph_context_monitor.cpython-314.pyc +0 -0
- package/global/hooks/__pycache__/statusline_agent_sync.cpython-314.pyc +0 -0
- package/global/hooks/anvil_memory_observe.ts +322 -0
- package/global/hooks/anvil_memory_session.ts +166 -0
- package/global/hooks/anvil_memory_stop.ts +187 -0
- package/global/hooks/parse_transcript.py +116 -0
- package/global/hooks/post_merge_cleanup.sh +132 -0
- package/global/hooks/post_tool_format.sh +215 -0
- package/global/hooks/ralph_context_monitor.py +240 -0
- package/global/hooks/ralph_stop.sh +502 -0
- package/global/hooks/statusline.sh +1110 -0
- package/global/hooks/statusline_agent_sync.py +224 -0
- package/global/hooks/stop_gate.sh +250 -0
- package/global/lib/.claude/anvil-state.json +21 -0
- package/global/lib/__pycache__/agent_registry.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/claim_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/coderabbit_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/config_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/coordination_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/doc_coverage_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/gate_logger.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/github_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/hygiene_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/issue_models.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/issue_provider.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/linear_data_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/linear_provider.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/local_provider.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/quality_service.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/ralph_state.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/state_manager.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/transcript_parser.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/verification_runner.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/verify_iteration.cpython-314.pyc +0 -0
- package/global/lib/__pycache__/verify_subagent.cpython-314.pyc +0 -0
- package/global/lib/agent_registry.py +995 -0
- package/global/lib/anvil-state.sh +435 -0
- package/global/lib/claim_service.py +515 -0
- package/global/lib/coderabbit_service.py +314 -0
- package/global/lib/config_service.py +423 -0
- package/global/lib/coordination_service.py +331 -0
- package/global/lib/doc_coverage_service.py +1305 -0
- package/global/lib/gate_logger.py +316 -0
- package/global/lib/github_service.py +310 -0
- package/global/lib/handoff_generator.py +775 -0
- package/global/lib/hygiene_service.py +712 -0
- package/global/lib/issue_models.py +257 -0
- package/global/lib/issue_provider.py +339 -0
- package/global/lib/linear_data_service.py +210 -0
- package/global/lib/linear_provider.py +987 -0
- package/global/lib/linear_provider.py.backup +671 -0
- package/global/lib/local_provider.py +486 -0
- package/global/lib/orient_fast.py +457 -0
- package/global/lib/quality_service.py +470 -0
- package/global/lib/ralph_prompt_generator.py +563 -0
- package/global/lib/ralph_state.py +1202 -0
- package/global/lib/state_manager.py +417 -0
- package/global/lib/transcript_parser.py +597 -0
- package/global/lib/verification_runner.py +557 -0
- package/global/lib/verify_iteration.py +490 -0
- package/global/lib/verify_subagent.py +250 -0
- package/global/skills/README.md +155 -0
- package/global/skills/quality-gates/SKILL.md +252 -0
- package/global/skills/skill-template/SKILL.md +109 -0
- package/global/skills/testing-strategies/SKILL.md +337 -0
- package/global/templates/CHANGE-template.md +105 -0
- package/global/templates/HANDOFF-template.md +63 -0
- package/global/templates/PLAN-template.md +111 -0
- package/global/templates/SPEC-template.md +93 -0
- package/global/templates/ralph/PROMPT.md.template +89 -0
- package/global/templates/ralph/fix_plan.md.template +31 -0
- package/global/templates/ralph/progress.txt.template +23 -0
- package/global/tests/__pycache__/test_doc_coverage.cpython-314.pyc +0 -0
- package/global/tests/test_doc_coverage.py +520 -0
- package/global/tests/test_issue_models.py +299 -0
- package/global/tests/test_local_provider.py +323 -0
- package/global/tools/README.md +178 -0
- package/global/tools/__pycache__/anvil-hud.cpython-314.pyc +0 -0
- package/global/tools/anvil-hud.py +3622 -0
- package/global/tools/anvil-hud.py.bak +3318 -0
- package/global/tools/anvil-issue.py +432 -0
- package/global/tools/anvil-memory/CLAUDE.md +49 -0
- package/global/tools/anvil-memory/README.md +42 -0
- package/global/tools/anvil-memory/bun.lock +25 -0
- package/global/tools/anvil-memory/bunfig.toml +9 -0
- package/global/tools/anvil-memory/package.json +23 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/context-monitor.test.ts +535 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/edge-cases.test.ts +645 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/fixtures.ts +363 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/index.ts +8 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/integration.test.ts +417 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/prompt-generator.test.ts +571 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/ralph-stop.test.ts +440 -0
- package/global/tools/anvil-memory/src/__tests__/ccs/test-utils.ts +252 -0
- package/global/tools/anvil-memory/src/__tests__/commands.test.ts +657 -0
- package/global/tools/anvil-memory/src/__tests__/db.test.ts +641 -0
- package/global/tools/anvil-memory/src/__tests__/hooks.test.ts +272 -0
- package/global/tools/anvil-memory/src/__tests__/performance.test.ts +427 -0
- package/global/tools/anvil-memory/src/__tests__/test-utils.ts +113 -0
- package/global/tools/anvil-memory/src/commands/checkpoint.ts +197 -0
- package/global/tools/anvil-memory/src/commands/get.ts +115 -0
- package/global/tools/anvil-memory/src/commands/init.ts +94 -0
- package/global/tools/anvil-memory/src/commands/observe.ts +163 -0
- package/global/tools/anvil-memory/src/commands/search.ts +112 -0
- package/global/tools/anvil-memory/src/db.ts +638 -0
- package/global/tools/anvil-memory/src/index.ts +205 -0
- package/global/tools/anvil-memory/src/types.ts +122 -0
- package/global/tools/anvil-memory/tsconfig.json +29 -0
- package/global/tools/ralph-loop.sh +359 -0
- package/package.json +45 -0
- package/scripts/anvil +822 -0
- package/scripts/extract_patterns.py +222 -0
- package/scripts/init-project.sh +541 -0
- package/scripts/install.sh +229 -0
- package/scripts/postinstall.js +41 -0
- package/scripts/rollback.sh +188 -0
- package/scripts/sync.sh +623 -0
- package/scripts/test-statusline.sh +248 -0
- package/scripts/update_claude_md.py +224 -0
- package/scripts/verify.sh +255 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# /plan - Create Implementation Plan
|
|
2
|
+
|
|
3
|
+
> Create a detailed implementation plan from an approved specification.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
- After specification is approved
|
|
7
|
+
- Before creating Linear issues
|
|
8
|
+
- When implementation approach needs documentation
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
- **Exploration completed** (`/explore`) — Did you search for existing code first?
|
|
12
|
+
- Specification created and approved (`/spec`)
|
|
13
|
+
- Technical decisions resolved
|
|
14
|
+
- No blocking open questions
|
|
15
|
+
|
|
16
|
+
## Execution Steps
|
|
17
|
+
|
|
18
|
+
### Step 0: Verify Exploration Was Done
|
|
19
|
+
|
|
20
|
+
**Before planning, confirm exploration happened:**
|
|
21
|
+
|
|
22
|
+
Check if an exploration report exists or was discussed:
|
|
23
|
+
- Look for recent `/explore` output in conversation
|
|
24
|
+
- Check for `.claude/specs/current/EXPLORE-*.md` files
|
|
25
|
+
|
|
26
|
+
If no exploration evidence:
|
|
27
|
+
```
|
|
28
|
+
⚠️ **Exploration Check**
|
|
29
|
+
|
|
30
|
+
No recent `/explore` found for this feature.
|
|
31
|
+
|
|
32
|
+
Before planning, run `/explore [feature name]` to:
|
|
33
|
+
- Search for existing code that might solve this
|
|
34
|
+
- Find patterns to follow
|
|
35
|
+
- Discover infrastructure to reuse
|
|
36
|
+
|
|
37
|
+
**Why this matters**: In 5/7 recent retros, we found existing infrastructure
|
|
38
|
+
that would have saved implementation time.
|
|
39
|
+
|
|
40
|
+
Continue anyway? Or run `/explore` first?
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If user chooses to skip: proceed but note the skip in the plan.
|
|
44
|
+
|
|
45
|
+
### Step 1: Review Specification
|
|
46
|
+
Read the approved spec:
|
|
47
|
+
- Understand all requirements
|
|
48
|
+
- Note acceptance criteria
|
|
49
|
+
- Identify technical constraints
|
|
50
|
+
|
|
51
|
+
### Step 2: Design Implementation Phases
|
|
52
|
+
Break work into logical phases:
|
|
53
|
+
- Each phase should be independently deployable if possible
|
|
54
|
+
- Consider dependencies between phases
|
|
55
|
+
- Aim for 1-4 hour tasks
|
|
56
|
+
|
|
57
|
+
### Step 3: Write Implementation Plan
|
|
58
|
+
|
|
59
|
+
Create file at: `.claude/specs/current/PLAN-[spec-id].md`
|
|
60
|
+
|
|
61
|
+
Template:
|
|
62
|
+
```markdown
|
|
63
|
+
---
|
|
64
|
+
plan_id: PLAN-[spec-id]
|
|
65
|
+
spec_ref: SPEC-[number]
|
|
66
|
+
status: draft | approved | in-progress | complete
|
|
67
|
+
created: YYYY-MM-DD
|
|
68
|
+
estimated_hours: [X-Y hours]
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
# Implementation Plan: [Feature Name]
|
|
72
|
+
|
|
73
|
+
## Specification Reference
|
|
74
|
+
- **Spec**: SPEC-[number]
|
|
75
|
+
- **Linear Issue**: [Issue key]
|
|
76
|
+
|
|
77
|
+
## Implementation Strategy
|
|
78
|
+
[High-level approach to implementing this feature]
|
|
79
|
+
|
|
80
|
+
## Phases
|
|
81
|
+
|
|
82
|
+
### Phase 1: [Phase Name] (Est: X hours)
|
|
83
|
+
**Goal**: [What this phase accomplishes]
|
|
84
|
+
|
|
85
|
+
**Tasks**:
|
|
86
|
+
1. [ ] [Task description]
|
|
87
|
+
2. [ ] [Task description]
|
|
88
|
+
3. [ ] [Task description]
|
|
89
|
+
|
|
90
|
+
**Files to Create/Modify**:
|
|
91
|
+
| File | Action | Purpose |
|
|
92
|
+
|------|--------|---------|
|
|
93
|
+
| src/components/X.tsx | Create | [Purpose] |
|
|
94
|
+
| src/services/y.ts | Modify | [Purpose] |
|
|
95
|
+
|
|
96
|
+
**Acceptance**: [How to verify phase is complete]
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Phase 2: [Phase Name] (Est: X hours)
|
|
101
|
+
**Goal**: [What this phase accomplishes]
|
|
102
|
+
**Depends on**: Phase 1
|
|
103
|
+
|
|
104
|
+
**Tasks**:
|
|
105
|
+
1. [ ] [Task description]
|
|
106
|
+
2. [ ] [Task description]
|
|
107
|
+
|
|
108
|
+
**Files to Create/Modify**:
|
|
109
|
+
| File | Action | Purpose |
|
|
110
|
+
|------|--------|---------|
|
|
111
|
+
|
|
112
|
+
**Acceptance**: [How to verify phase is complete]
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### Phase 3: Testing & Polish (Est: X hours)
|
|
117
|
+
**Goal**: Verify all acceptance criteria, fix edge cases
|
|
118
|
+
|
|
119
|
+
**Tasks**:
|
|
120
|
+
1. [ ] Write unit tests for [component]
|
|
121
|
+
2. [ ] Write integration tests for [flow]
|
|
122
|
+
3. [ ] Manual testing of acceptance scenarios
|
|
123
|
+
4. [ ] Address any edge cases found
|
|
124
|
+
|
|
125
|
+
**Acceptance**: All tests pass, all Gherkin scenarios verified
|
|
126
|
+
|
|
127
|
+
## File Change Summary
|
|
128
|
+
|
|
129
|
+
### New Files
|
|
130
|
+
| Path | Purpose |
|
|
131
|
+
|------|---------|
|
|
132
|
+
| src/components/Feature.tsx | Main component |
|
|
133
|
+
| src/hooks/useFeature.ts | Feature logic |
|
|
134
|
+
|
|
135
|
+
### Modified Files
|
|
136
|
+
| Path | Changes |
|
|
137
|
+
|------|---------|
|
|
138
|
+
| src/services/api.ts | Add new endpoint call |
|
|
139
|
+
|
|
140
|
+
### Deleted Files
|
|
141
|
+
| Path | Reason |
|
|
142
|
+
|------|--------|
|
|
143
|
+
| [none expected] | |
|
|
144
|
+
|
|
145
|
+
## Testing Strategy
|
|
146
|
+
|
|
147
|
+
### Unit Tests
|
|
148
|
+
- [ ] [Component/function to test]
|
|
149
|
+
- [ ] [Component/function to test]
|
|
150
|
+
|
|
151
|
+
### Integration Tests
|
|
152
|
+
- [ ] [Flow to test]
|
|
153
|
+
|
|
154
|
+
### Manual Testing
|
|
155
|
+
- [ ] [Scenario to manually verify]
|
|
156
|
+
|
|
157
|
+
## Risks and Rollback
|
|
158
|
+
|
|
159
|
+
### Known Risks
|
|
160
|
+
| Risk | Mitigation |
|
|
161
|
+
|------|------------|
|
|
162
|
+
| [Risk] | [Mitigation] |
|
|
163
|
+
|
|
164
|
+
### Rollback Plan
|
|
165
|
+
[How to rollback if something goes wrong]
|
|
166
|
+
|
|
167
|
+
## Definition of Done
|
|
168
|
+
- [ ] All tasks complete
|
|
169
|
+
- [ ] All tests passing
|
|
170
|
+
- [ ] Code reviewed
|
|
171
|
+
- [ ] Acceptance criteria verified
|
|
172
|
+
- [ ] Documentation updated (if needed)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Step 4: Request Approval
|
|
176
|
+
|
|
177
|
+
Output:
|
|
178
|
+
```
|
|
179
|
+
## Implementation Plan Created
|
|
180
|
+
|
|
181
|
+
**File**: .claude/specs/current/PLAN-[spec-id].md
|
|
182
|
+
**Estimated effort**: X-Y hours
|
|
183
|
+
**Phases**: N phases
|
|
184
|
+
|
|
185
|
+
### Phase Summary
|
|
186
|
+
1. **[Phase 1]**: [Goal] (X hrs)
|
|
187
|
+
2. **[Phase 2]**: [Goal] (X hrs)
|
|
188
|
+
3. **Testing**: [Goal] (X hrs)
|
|
189
|
+
|
|
190
|
+
### Files Affected
|
|
191
|
+
- Create: X files
|
|
192
|
+
- Modify: Y files
|
|
193
|
+
- Delete: Z files
|
|
194
|
+
|
|
195
|
+
**Next Step**: Review and approve plan, then run `/tasks` to create Linear issues.
|
|
196
|
+
|
|
197
|
+
Please confirm:
|
|
198
|
+
- [ ] Phases are logical
|
|
199
|
+
- [ ] Estimates are reasonable
|
|
200
|
+
- [ ] File changes are expected
|
|
201
|
+
- [ ] Testing strategy is adequate
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Key Behaviors
|
|
205
|
+
- Plans must be **approved** before creating tasks
|
|
206
|
+
- Each phase should be completable in one session
|
|
207
|
+
- Include rollback strategy for risky changes
|
|
208
|
+
- Be explicit about file changes
|
|
209
|
+
|
|
210
|
+
## State Sync (ANV-176)
|
|
211
|
+
|
|
212
|
+
After creating the implementation plan, update the session state:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
python3 global/lib/state_manager.py plan ".claude/specs/current/PLAN-XXX.md"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
This updates `.claude/anvil-state.json` with:
|
|
219
|
+
- `phase: "plan"`
|
|
220
|
+
- `activePlan: [path to plan file]`
|
|
221
|
+
- Sets `lastCommand: "/plan"`
|
|
222
|
+
|
|
223
|
+
And syncs to the agent registry for statusline visibility.
|
|
224
|
+
|
|
225
|
+
## Integration Points
|
|
226
|
+
- Follows: `/spec` specification
|
|
227
|
+
- Precedes: `/tasks` issue creation
|
|
228
|
+
- Creates: `.claude/specs/current/PLAN-*.md`
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# /ralph - Ralph Wiggum Long-Running Mode
|
|
2
|
+
|
|
3
|
+
> Enable long-running unattended execution with completion promises and circuit breakers.
|
|
4
|
+
|
|
5
|
+
Based on Geoffrey Huntley's technique: "6 repos overnight", "$50k contract for $297"
|
|
6
|
+
|
|
7
|
+
## Arguments
|
|
8
|
+
|
|
9
|
+
| Argument | Description |
|
|
10
|
+
|----------|-------------|
|
|
11
|
+
| `start [description]` | Initialize Ralph mode with a task |
|
|
12
|
+
| `status` | Show current iteration and progress |
|
|
13
|
+
| `stop` | Force exit Ralph mode cleanly |
|
|
14
|
+
|
|
15
|
+
## Flags
|
|
16
|
+
|
|
17
|
+
| Flag | Default | Description |
|
|
18
|
+
|------|---------|-------------|
|
|
19
|
+
| `--max-iterations` | 50 | Maximum iterations before stopping |
|
|
20
|
+
| `--completion-promise` | COMPLETE | Text that signals completion |
|
|
21
|
+
| `--issue` | — | Linear issue ID to fetch subtasks from (e.g., `ANV-209`) |
|
|
22
|
+
| `--project` | — | Linear project name to process all issues |
|
|
23
|
+
| `--subtasks` | — | Filter subtasks (e.g., `ANV-1..ANV-5` or `ANV-1,ANV-3`) |
|
|
24
|
+
| `--no-sync` | false | Disable syncing status back to Linear |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Execution: /ralph start
|
|
29
|
+
|
|
30
|
+
### Step 1: Gather Task Information
|
|
31
|
+
|
|
32
|
+
**Option A: From Linear Issue (Recommended)**
|
|
33
|
+
|
|
34
|
+
If `--issue` flag is provided:
|
|
35
|
+
```bash
|
|
36
|
+
python3 global/lib/ralph_state.py init-linear \
|
|
37
|
+
--issue "ANV-209" \
|
|
38
|
+
[--filter "ANV-210..ANV-215"] \
|
|
39
|
+
[--no-sync]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This automatically:
|
|
43
|
+
- Fetches the parent issue title as the objective
|
|
44
|
+
- Fetches all subtasks as TODO items
|
|
45
|
+
- Enables Linear sync to update subtask status
|
|
46
|
+
- Creates `[ANV-XXX]` prefixed items in fix_plan.md
|
|
47
|
+
|
|
48
|
+
**Option B: Manual Input**
|
|
49
|
+
|
|
50
|
+
Ask for or parse from arguments:
|
|
51
|
+
- Task name (short identifier)
|
|
52
|
+
- Objective (what needs to be accomplished)
|
|
53
|
+
- TODO items (break down into atomic steps)
|
|
54
|
+
|
|
55
|
+
### Step 2: Create Task Structure
|
|
56
|
+
|
|
57
|
+
Create the following files:
|
|
58
|
+
|
|
59
|
+
**PROMPT.md** - Main prompt fed to Claude each iteration:
|
|
60
|
+
```bash
|
|
61
|
+
# Use template
|
|
62
|
+
cp global/templates/ralph/PROMPT.md.template PROMPT.md
|
|
63
|
+
# Substitute variables
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**fix_plan.md** - TODO list with checkboxes:
|
|
67
|
+
```markdown
|
|
68
|
+
# Fix Plan: [Task Name]
|
|
69
|
+
|
|
70
|
+
## TODO Items
|
|
71
|
+
- [ ] Item 1
|
|
72
|
+
- [ ] Item 2
|
|
73
|
+
- [ ] Item 3
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**When using Linear integration**, items include issue links:
|
|
77
|
+
```markdown
|
|
78
|
+
# Fix Plan: Linear: ANV-209
|
|
79
|
+
|
|
80
|
+
> Linear Issue: [ANV-209](https://linear.app/your-org/issue/ANV-209)
|
|
81
|
+
|
|
82
|
+
## TODO Items
|
|
83
|
+
- [ ] [ANV-210] Phase 1: LinearProvider Implementation
|
|
84
|
+
- [ ] [ANV-211] Phase 2: Ralph State Linear Fields
|
|
85
|
+
- [ ] [ANV-212] Phase 3: Command Interface Update
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**progress.txt** - Iteration progress log:
|
|
89
|
+
```markdown
|
|
90
|
+
# Ralph Wiggum Progress Log
|
|
91
|
+
|
|
92
|
+
## Iteration 0 - Initialization
|
|
93
|
+
- Created fix_plan.md
|
|
94
|
+
- Ready to start
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Step 3: Initialize State
|
|
98
|
+
|
|
99
|
+
Create `.claude/ralph-state.json`:
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"task_name": "...",
|
|
103
|
+
"objective": "...",
|
|
104
|
+
"iteration": 0,
|
|
105
|
+
"started_at": "2026-01-07T00:00:00Z",
|
|
106
|
+
"status": "running",
|
|
107
|
+
"no_change_count": 0,
|
|
108
|
+
"last_diff_hash": ""
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Step 4: Enable Stop Hook
|
|
113
|
+
|
|
114
|
+
The ralph_stop.sh hook will automatically:
|
|
115
|
+
- Block exit until `<promise>COMPLETE</promise>` detected
|
|
116
|
+
- Track iterations and enforce max limit
|
|
117
|
+
- Activate circuit breaker on stuck loops
|
|
118
|
+
- Create git checkpoints before restart
|
|
119
|
+
|
|
120
|
+
### Step 5: Start Loop
|
|
121
|
+
|
|
122
|
+
Begin the Ralph loop (external bash or let Claude Code handle):
|
|
123
|
+
```bash
|
|
124
|
+
while :; do
|
|
125
|
+
cat PROMPT.md | npx --yes @anthropic/claude-code --print
|
|
126
|
+
done
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Execution: /ralph status
|
|
132
|
+
|
|
133
|
+
Show current Ralph mode status:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
## Ralph Wiggum Status
|
|
137
|
+
|
|
138
|
+
| Metric | Value |
|
|
139
|
+
|--------|-------|
|
|
140
|
+
| Status | Running |
|
|
141
|
+
| Iteration | 5 of 50 |
|
|
142
|
+
| Started | 2026-01-07T10:00:00Z |
|
|
143
|
+
| Duration | 45 minutes |
|
|
144
|
+
| Items Complete | 3 of 8 |
|
|
145
|
+
| Last Action | Implemented OAuth callback |
|
|
146
|
+
|
|
147
|
+
### Recent Progress (last 3 iterations)
|
|
148
|
+
- Iteration 5: Added token refresh logic
|
|
149
|
+
- Iteration 4: Fixed callback URL parsing
|
|
150
|
+
- Iteration 3: Implemented OAuth redirect
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**With Linear integration**, additional fields are shown:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
## Ralph Wiggum Status
|
|
157
|
+
|
|
158
|
+
| Metric | Value |
|
|
159
|
+
|--------|-------|
|
|
160
|
+
| Status | Running |
|
|
161
|
+
| Iteration | 5 of 50 |
|
|
162
|
+
| Started | 2026-01-07T10:00:00Z |
|
|
163
|
+
| Duration | 45 minutes |
|
|
164
|
+
| Items Complete | 3 of 8 |
|
|
165
|
+
| Progress | 38% |
|
|
166
|
+
|
|
167
|
+
### Linear Integration
|
|
168
|
+
| Field | Value |
|
|
169
|
+
|-------|-------|
|
|
170
|
+
| Parent Issue | [ANV-209](https://linear.app/your-org/issue/ANV-209) |
|
|
171
|
+
| Subtasks | 3 done, 0 skipped, 5 remaining |
|
|
172
|
+
| Last Sync | 2026-01-07T10:45:00Z |
|
|
173
|
+
| Sync Status | Enabled |
|
|
174
|
+
|
|
175
|
+
### Current Subtask
|
|
176
|
+
[ANV-212] Phase 3: Command Interface Update
|
|
177
|
+
|
|
178
|
+
### Recently Completed
|
|
179
|
+
- [ANV-210] Phase 1: LinearProvider Implementation
|
|
180
|
+
- [ANV-211] Phase 2: Ralph State Linear Fields
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Execution: /ralph stop
|
|
186
|
+
|
|
187
|
+
Force exit Ralph mode:
|
|
188
|
+
|
|
189
|
+
1. Set status to "stopped" in state file
|
|
190
|
+
2. Log the manual stop
|
|
191
|
+
3. Clean up state file
|
|
192
|
+
4. Output summary of progress
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
## Ralph Wiggum Stopped
|
|
196
|
+
|
|
197
|
+
Task: Implement OAuth
|
|
198
|
+
Iterations completed: 5
|
|
199
|
+
Items completed: 3 of 8
|
|
200
|
+
Status: Manually stopped
|
|
201
|
+
|
|
202
|
+
Remaining items:
|
|
203
|
+
- [ ] Add session persistence
|
|
204
|
+
- [ ] Implement logout
|
|
205
|
+
- [ ] Add refresh token handling
|
|
206
|
+
- [ ] Write tests
|
|
207
|
+
|
|
208
|
+
Files modified:
|
|
209
|
+
- src/auth/oauth.ts
|
|
210
|
+
- src/auth/callback.ts
|
|
211
|
+
- src/auth/tokens.ts
|
|
212
|
+
|
|
213
|
+
To resume later, run: /ralph start "Continue OAuth implementation"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Critical Rules
|
|
219
|
+
|
|
220
|
+
| Rule | Reason |
|
|
221
|
+
|------|--------|
|
|
222
|
+
| **ONE item per loop** | Prevents context overflow |
|
|
223
|
+
| **Update progress.txt every iteration** | Prevents repeated mistakes |
|
|
224
|
+
| **Subagents for research** | Keeps main context clean (500 max) |
|
|
225
|
+
| **Single agent for build/test** | Prevents race conditions |
|
|
226
|
+
| **Commit on success** | Each item gets committed |
|
|
227
|
+
| **Tests gate progress** | No marking complete without tests |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Circuit Breaker
|
|
232
|
+
|
|
233
|
+
The Ralph stop hook includes automatic circuit breaker:
|
|
234
|
+
|
|
235
|
+
| Condition | Threshold | Action |
|
|
236
|
+
|-----------|-----------|--------|
|
|
237
|
+
| No file changes | 3 iterations | Stop loop |
|
|
238
|
+
| Repeated errors | 5 iterations | Stop loop |
|
|
239
|
+
| Max iterations | 50 (default) | Stop loop |
|
|
240
|
+
| `<fatal>` signal | Immediate | Stop loop |
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Environment Variables
|
|
245
|
+
|
|
246
|
+
| Variable | Default | Description |
|
|
247
|
+
|----------|---------|-------------|
|
|
248
|
+
| `RALPH_MAX_ITERATIONS` | 50 | Max iterations |
|
|
249
|
+
| `RALPH_COMPLETION_PROMISE` | COMPLETE | Completion text |
|
|
250
|
+
| `RALPH_STATE_FILE` | .claude/ralph-state.json | State file path |
|
|
251
|
+
| `RALPH_ENABLE_LOGGING` | false | Enable detailed logging |
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Cost Considerations
|
|
256
|
+
|
|
257
|
+
| Scenario | Estimated Cost |
|
|
258
|
+
|----------|----------------|
|
|
259
|
+
| 10 iterations, small codebase | $5-15 |
|
|
260
|
+
| 50 iterations, medium codebase | $50-100+ |
|
|
261
|
+
| 100+ iterations, large codebase | $200+ |
|
|
262
|
+
|
|
263
|
+
**Recommendation**: Start with `--max-iterations 10` to understand costs.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## When to Use Ralph
|
|
268
|
+
|
|
269
|
+
**Good for:**
|
|
270
|
+
- Large-scale refactoring with clear completion criteria
|
|
271
|
+
- Framework migrations (Jest→Vitest, etc.)
|
|
272
|
+
- TDD workflows (implement to pass failing tests)
|
|
273
|
+
- Greenfield projects with defined specs
|
|
274
|
+
- Test coverage expansion
|
|
275
|
+
|
|
276
|
+
**Not good for:**
|
|
277
|
+
- Ambiguous requirements
|
|
278
|
+
- Architectural decisions needing human judgment
|
|
279
|
+
- Security-sensitive code
|
|
280
|
+
- Exploratory debugging
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Example Usage
|
|
285
|
+
|
|
286
|
+
### Basic Start
|
|
287
|
+
```
|
|
288
|
+
/ralph start "Migrate all tests from Jest to Vitest"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### With Options
|
|
292
|
+
```
|
|
293
|
+
/ralph start "Add OAuth authentication" --max-iterations 30 --completion-promise "AUTH_COMPLETE"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### From Linear Issue (Recommended)
|
|
297
|
+
```
|
|
298
|
+
/ralph start --issue ANV-209
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
This fetches the issue title and all subtasks automatically.
|
|
302
|
+
|
|
303
|
+
### From Linear with Subtask Filter
|
|
304
|
+
```
|
|
305
|
+
/ralph start --issue ANV-209 --subtasks ANV-210..ANV-213
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Only process phases 1-4 (ANV-210 through ANV-213).
|
|
309
|
+
|
|
310
|
+
### From Linear without Syncing
|
|
311
|
+
```
|
|
312
|
+
/ralph start --issue ANV-209 --no-sync
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Run Ralph but don't update Linear issue statuses.
|
|
316
|
+
|
|
317
|
+
### Check Progress
|
|
318
|
+
```
|
|
319
|
+
/ralph status
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Stop Early
|
|
323
|
+
```
|
|
324
|
+
/ralph stop
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Integration Points
|
|
330
|
+
|
|
331
|
+
- **Stop Hook**: `global/hooks/ralph_stop.sh`
|
|
332
|
+
- **Templates**: `global/templates/ralph/`
|
|
333
|
+
- **State File**: `.claude/ralph-state.json`
|
|
334
|
+
- **Logs**: `.claude/logs/ralph.log`
|
|
335
|
+
- **Linear State**: `global/lib/ralph_state.py` (Linear integration)
|
|
336
|
+
- **Linear Provider**: `global/lib/linear_provider.py` (API wrapper)
|
|
337
|
+
|
|
338
|
+
## Anti-Patterns
|
|
339
|
+
|
|
340
|
+
| Don't | Do Instead |
|
|
341
|
+
|-------|------------|
|
|
342
|
+
| Multiple items per iteration | Complete ONE item, then restart |
|
|
343
|
+
| Skip progress.txt updates | ALWAYS update progress.txt |
|
|
344
|
+
| Ignore test failures | Fix tests before marking complete |
|
|
345
|
+
| Vague completion criteria | Define objective, measurable criteria |
|
|
346
|
+
| Run without max-iterations | Always set a reasonable limit |
|