@graypark/loophaus 3.4.1 → 3.5.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.
Files changed (151) hide show
  1. package/README.ko.md +81 -17
  2. package/README.md +69 -15
  3. package/dist/.claude-plugin/plugin.json +11 -0
  4. package/dist/LICENSE +21 -0
  5. package/dist/README.ko.md +422 -0
  6. package/dist/README.md +336 -0
  7. package/dist/bin/install.d.ts +3 -0
  8. package/dist/bin/install.d.ts.map +1 -0
  9. package/{bin/install.mjs → dist/bin/install.js} +3 -5
  10. package/dist/bin/install.js.map +1 -0
  11. package/dist/bin/loophaus.d.ts +3 -0
  12. package/dist/bin/loophaus.d.ts.map +1 -0
  13. package/dist/bin/loophaus.js +654 -0
  14. package/dist/bin/loophaus.js.map +1 -0
  15. package/dist/bin/uninstall.d.ts +8 -0
  16. package/dist/bin/uninstall.d.ts.map +1 -0
  17. package/dist/bin/uninstall.js +209 -0
  18. package/dist/bin/uninstall.js.map +1 -0
  19. package/dist/codex/commands/cancel-ralph.md +30 -0
  20. package/dist/codex/commands/ralph-loop.md +73 -0
  21. package/dist/commands/cancel-ralph.md +23 -0
  22. package/dist/commands/help.md +96 -0
  23. package/dist/commands/loop-plan.md +257 -0
  24. package/dist/commands/loop-pulse.md +38 -0
  25. package/dist/commands/loop-stop.md +29 -0
  26. package/dist/commands/loop.md +17 -0
  27. package/dist/commands/ralph-loop.md +18 -0
  28. package/dist/core/cost-tracker.d.ts +33 -0
  29. package/dist/core/cost-tracker.d.ts.map +1 -0
  30. package/dist/core/cost-tracker.js +41 -0
  31. package/dist/core/cost-tracker.js.map +1 -0
  32. package/dist/core/engine.d.ts +4 -0
  33. package/dist/core/engine.d.ts.map +1 -0
  34. package/dist/core/engine.js +109 -0
  35. package/dist/core/engine.js.map +1 -0
  36. package/dist/core/event-logger.d.ts +5 -0
  37. package/dist/core/event-logger.d.ts.map +1 -0
  38. package/dist/core/event-logger.js +48 -0
  39. package/dist/core/event-logger.js.map +1 -0
  40. package/dist/core/events.d.ts +34 -0
  41. package/dist/core/events.d.ts.map +1 -0
  42. package/dist/core/events.js +44 -0
  43. package/dist/core/events.js.map +1 -0
  44. package/dist/core/io-helpers.d.ts +3 -0
  45. package/dist/core/io-helpers.d.ts.map +1 -0
  46. package/dist/core/io-helpers.js +65 -0
  47. package/dist/core/io-helpers.js.map +1 -0
  48. package/dist/core/loop-registry.d.ts +10 -0
  49. package/dist/core/loop-registry.d.ts.map +1 -0
  50. package/dist/core/loop-registry.js +37 -0
  51. package/dist/core/loop-registry.js.map +1 -0
  52. package/dist/core/merge-strategy.d.ts +7 -0
  53. package/dist/core/merge-strategy.d.ts.map +1 -0
  54. package/dist/core/merge-strategy.js +82 -0
  55. package/dist/core/merge-strategy.js.map +1 -0
  56. package/dist/core/parallel-runner.d.ts +32 -0
  57. package/dist/core/parallel-runner.d.ts.map +1 -0
  58. package/dist/core/parallel-runner.js +88 -0
  59. package/dist/core/parallel-runner.js.map +1 -0
  60. package/dist/core/policy.d.ts +22 -0
  61. package/dist/core/policy.d.ts.map +1 -0
  62. package/dist/core/policy.js +54 -0
  63. package/dist/core/policy.js.map +1 -0
  64. package/dist/core/quality-scorer.d.ts +40 -0
  65. package/dist/core/quality-scorer.d.ts.map +1 -0
  66. package/dist/core/quality-scorer.js +128 -0
  67. package/dist/core/quality-scorer.js.map +1 -0
  68. package/dist/core/refine-loop.d.ts +16 -0
  69. package/dist/core/refine-loop.d.ts.map +1 -0
  70. package/dist/core/refine-loop.js +26 -0
  71. package/dist/core/refine-loop.js.map +1 -0
  72. package/dist/core/session.d.ts +27 -0
  73. package/dist/core/session.d.ts.map +1 -0
  74. package/dist/core/session.js +67 -0
  75. package/dist/core/session.js.map +1 -0
  76. package/dist/core/trace-analyzer.d.ts +28 -0
  77. package/dist/core/trace-analyzer.d.ts.map +1 -0
  78. package/dist/core/trace-analyzer.js +46 -0
  79. package/dist/core/trace-analyzer.js.map +1 -0
  80. package/dist/core/types.d.ts +99 -0
  81. package/dist/core/types.d.ts.map +1 -0
  82. package/dist/core/types.js +2 -0
  83. package/dist/core/types.js.map +1 -0
  84. package/dist/core/validate.d.ts +7 -0
  85. package/dist/core/validate.d.ts.map +1 -0
  86. package/dist/core/validate.js +55 -0
  87. package/dist/core/validate.js.map +1 -0
  88. package/dist/core/worktree.d.ts +13 -0
  89. package/dist/core/worktree.d.ts.map +1 -0
  90. package/dist/core/worktree.js +108 -0
  91. package/dist/core/worktree.js.map +1 -0
  92. package/dist/hooks/hooks.json +15 -0
  93. package/dist/hooks/stop-hook.mjs +111 -0
  94. package/dist/lib/paths.d.ts +18 -0
  95. package/dist/lib/paths.d.ts.map +1 -0
  96. package/dist/lib/paths.js +74 -0
  97. package/dist/lib/paths.js.map +1 -0
  98. package/dist/lib/stop-hook-core.d.ts +19 -0
  99. package/dist/lib/stop-hook-core.d.ts.map +1 -0
  100. package/dist/lib/stop-hook-core.js +36 -0
  101. package/dist/lib/stop-hook-core.js.map +1 -0
  102. package/dist/package.json +61 -0
  103. package/dist/platforms/claude-code/adapter.mjs +20 -0
  104. package/dist/platforms/claude-code/installer.d.mts +3 -0
  105. package/dist/platforms/claude-code/installer.mjs +173 -0
  106. package/dist/platforms/codex-cli/adapter.mjs +20 -0
  107. package/dist/platforms/codex-cli/installer.d.mts +2 -0
  108. package/dist/platforms/codex-cli/installer.mjs +247 -0
  109. package/dist/platforms/kiro-cli/adapter.mjs +21 -0
  110. package/dist/platforms/kiro-cli/installer.d.mts +3 -0
  111. package/dist/platforms/kiro-cli/installer.mjs +257 -0
  112. package/dist/scripts/setup-ralph-loop.sh +145 -0
  113. package/dist/skills/ralph-claude-cancel/SKILL.md +23 -0
  114. package/dist/skills/ralph-claude-interview/SKILL.md +184 -0
  115. package/dist/skills/ralph-claude-loop/SKILL.md +101 -0
  116. package/dist/skills/ralph-claude-orchestrator/SKILL.md +129 -0
  117. package/dist/skills/ralph-interview/SKILL.md +275 -0
  118. package/dist/skills/ralph-orchestrator/SKILL.md +254 -0
  119. package/dist/store/state-store.d.ts +17 -0
  120. package/dist/store/state-store.d.ts.map +1 -0
  121. package/dist/store/state-store.js +108 -0
  122. package/dist/store/state-store.js.map +1 -0
  123. package/hooks/stop-hook.mjs +6 -6
  124. package/package.json +11 -7
  125. package/platforms/claude-code/installer.d.mts +3 -0
  126. package/platforms/claude-code/installer.mjs +2 -2
  127. package/platforms/codex-cli/installer.d.mts +2 -0
  128. package/platforms/codex-cli/installer.mjs +1 -1
  129. package/platforms/kiro-cli/installer.d.mts +3 -0
  130. package/bin/loophaus.mjs +0 -521
  131. package/bin/uninstall.mjs +0 -255
  132. package/core/cost-tracker.mjs +0 -44
  133. package/core/engine.mjs +0 -123
  134. package/core/event-logger.mjs +0 -37
  135. package/core/events.mjs +0 -48
  136. package/core/io-helpers.mjs +0 -33
  137. package/core/loop-registry.mjs +0 -37
  138. package/core/loop.schema.json +0 -29
  139. package/core/merge-strategy.mjs +0 -72
  140. package/core/parallel-runner.mjs +0 -94
  141. package/core/policy.mjs +0 -58
  142. package/core/quality-scorer.mjs +0 -136
  143. package/core/refine-loop.mjs +0 -29
  144. package/core/session.mjs +0 -66
  145. package/core/state.schema.json +0 -24
  146. package/core/trace-analyzer.mjs +0 -51
  147. package/core/validate.mjs +0 -54
  148. package/core/worktree.mjs +0 -97
  149. package/lib/paths.mjs +0 -99
  150. package/lib/stop-hook-core.mjs +0 -42
  151. package/store/state-store.mjs +0 -106
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: ralph-claude-loop
3
+ description: "Start a PRD-driven Loop in Claude Code. Reads prd.json + progress.txt each iteration. Uses the official loop stop hook."
4
+ ---
5
+
6
+ # Loop (Claude Code)
7
+
8
+ Start a Loop optimized for Claude Code. This skill sets up the loop state, activates the official stop hook, and begins working on the first pending story from prd.json.
9
+
10
+ ## Prerequisites
11
+
12
+ - The `loophaus` plugin must be installed
13
+ - A `prd.json` file must exist in the project root (generate one with `/loop-plan`)
14
+
15
+ ## How It Works
16
+
17
+ 1. This skill writes `.loophaus/state.json` (the state file)
18
+ 2. loophaus's stop hook reads this file and intercepts session exits
19
+ 3. Each iteration follows the **Implement → Discover → Plan → Continue** cycle
20
+ 4. When all stories pass: output `<promise>COMPLETE</promise>`
21
+
22
+ ### Iteration Cycle (per story)
23
+
24
+ ```
25
+ ┌─ IMPLEMENT ─────────────────────────────┐
26
+ │ Pick next story → implement → verify │
27
+ └─────────────────────┬───────────────────┘
28
+
29
+ ┌─ DISCOVER ──────────────────────────────┐
30
+ │ Review what you just built. │
31
+ │ Did you find: │
32
+ │ - Hidden complexity? │
33
+ │ - Missing edge cases? │
34
+ │ - New dependencies? │
35
+ │ - Broken assumptions from the PRD? │
36
+ └─────────────────────┬───────────────────┘
37
+
38
+ ┌─ UPDATE PRD ────────────────────────────┐
39
+ │ If discoveries found: │
40
+ │ 1. Add new stories to prd.json │
41
+ │ 2. Log discoveries in progress.txt │
42
+ │ 3. Adjust max_iterations if needed │
43
+ │ If nothing new: skip │
44
+ └─────────────────────┬───────────────────┘
45
+
46
+ ┌─ CONTINUE ──────────────────────────────┐
47
+ │ Mark current story done → next story │
48
+ └─────────────────────────────────────────┘
49
+ ```
50
+
51
+ ## Activation
52
+
53
+ Run the setup script to create the state file:
54
+
55
+ ```!
56
+ mkdir -p .loophaus && cat > .loophaus/state.json << 'LOOP_STATE'
57
+ {
58
+ "active": true,
59
+ "prompt": "Read prd.json for the task plan. Read progress.txt for current status (check Codebase Patterns section first). Pick the highest priority user story where passes is false. Implement that ONE story. Run verification: $VERIFY_CMD. On failure: read error, fix, retry up to 3 times. On success: commit with message feat: [Story ID] - [Story Title]. Update prd.json: set passes to true for the completed story. DISCOVERY PHASE — After completing the story, review what you just built: did implementation reveal hidden complexity not covered by existing stories? Are there missing edge cases, error handling, or integration points? Did you discover new dependencies or broken assumptions? Are there follow-up tasks needed for what you just built? If YES to any: add new user stories to prd.json with the next available ID (e.g. US-010), set passes: false, and set priority appropriately. Log the discovery in progress.txt under Discoveries section with rationale. If NO: skip, just append progress to progress.txt with learnings. If ALL stories (including newly added ones) have passes true, output <promise>COMPLETE</promise>. When stuck after 3 retries: set notes field in prd.json with error details, move to next story.",
60
+ "completionPromise": "COMPLETE",
61
+ "maxIterations": $MAX_ITERATIONS,
62
+ "currentIteration": 0,
63
+ "sessionId": ""
64
+ }
65
+ LOOP_STATE
66
+ ```
67
+
68
+ Replace `$MAX_ITERATIONS` with the desired limit and `$VERIFY_CMD` with the project's verification command.
69
+
70
+ After setup, immediately begin working:
71
+
72
+ 1. Read prd.json
73
+ 2. Pick the first story with `passes: false`
74
+ 3. Implement it — write real code, make real changes
75
+ 4. Run verification
76
+ 5. Commit
77
+ 6. **Discovery Phase** — review what you just built for hidden complexity, missing cases, new dependencies
78
+ 7. If discoveries found: add new stories to prd.json, log in progress.txt
79
+ 8. Update prd.json (mark current story done) and progress.txt
80
+ 9. The stop hook will re-inject this prompt for the next story
81
+
82
+ ### Discovery Phase Rules
83
+
84
+ - New stories MUST follow the same format (id, title, description, acceptanceCriteria, priority, passes: false)
85
+ - Use next sequential ID (if last is US-007, new ones start at US-008)
86
+ - Set priority relative to remaining work (urgent discoveries get lower priority number)
87
+ - Do NOT add trivial or cosmetic items — only genuinely missing functionality
88
+ - Log each discovery in progress.txt: what was found, why it matters, which story revealed it
89
+ - If adding stories increases scope significantly, update `maxIterations` in `.loophaus/state.json`
90
+
91
+ ### max_iterations Auto-Adjustment
92
+
93
+ When adding N new stories, update maxIterations:
94
+
95
+ ```
96
+ new_max = current_iteration + (remaining_stories + new_stories) * 2 + 3
97
+ ```
98
+
99
+ Only increase, never decrease. Update the value in `.loophaus/state.json`.
100
+
101
+ CRITICAL RULE: Only output `<promise>COMPLETE</promise>` when ALL stories in prd.json (including dynamically added ones) have `passes: true`. Do not output it prematurely.
@@ -0,0 +1,129 @@
1
+ ---
2
+ name: ralph-claude-orchestrator
3
+ description: "Multi-agent orchestration patterns for Loop in Claude Code. Uses the Agent tool for parallel subagent spawning."
4
+ ---
5
+
6
+ # Loop Orchestrator — Multi-Agent Patterns (Claude Code)
7
+
8
+ Orchestration patterns optimized for Claude Code's Agent tool. Analyzes tasks and recommends the best combination of sequential loops and parallel subagents.
9
+
10
+ ## Subagent Configuration (Claude Code Agent Tool)
11
+
12
+ ```
13
+ Agent tool parameters:
14
+ - description: "short task description"
15
+ - prompt: "detailed instructions"
16
+ - subagent_type: "general-purpose" | "Explore" | "Plan" | "coder-fe" | "coder-be"
17
+ - isolation: "worktree" (gives agent an isolated repo copy)
18
+ - run_in_background: true (for parallel execution)
19
+ ```
20
+
21
+ **Best practices:**
22
+
23
+ - Use `subagent_type: "Explore"` for read-only scanning — faster and safer
24
+ - Use `isolation: "worktree"` when agents write to files — prevents merge conflicts
25
+ - Launch parallel agents in a single message with multiple Agent tool calls
26
+ - Use `run_in_background: true` for truly independent work streams
27
+
28
+ ## Orchestration Patterns
29
+
30
+ ### Pattern 1: Parallel Explore then Sequential Implement
31
+
32
+ Best for: Large codebases where you need to understand before you change.
33
+
34
+ ```
35
+ Phase 1 (Parallel Subagents via Agent tool):
36
+ ├── Agent "fe-scan" (Explore, background): Scan src/frontend/** → .loophaus/reports/frontend.md
37
+ ├── Agent "be-scan" (Explore, background): Scan src/backend/** → .loophaus/reports/backend.md
38
+ └── Agent "db-scan" (Explore, background): Scan src/db/** → .loophaus/reports/db.md
39
+
40
+ Phase 2 (Loop):
41
+ └── Read merged reports → implement fixes story by story via prd.json
42
+ ```
43
+
44
+ ### Pattern 2: Divide by Ownership
45
+
46
+ Best for: Multi-service changes where files do not overlap.
47
+
48
+ ```
49
+ Spawn agents with isolation: "worktree":
50
+ ├── Agent "fe-dev" (worktree): ONLY touch src/frontend/** → commit per item
51
+ ├── Agent "be-dev" (worktree): ONLY touch src/backend/** → commit per item
52
+ └── Agent "auth-dev" (worktree): ONLY touch src/auth/** → commit per item
53
+
54
+ After all complete: merge branches, run integration tests
55
+ ```
56
+
57
+ ### Pattern 3: Fan-Out / Fan-In Research
58
+
59
+ Best for: Comprehensive analysis before any action.
60
+
61
+ ```
62
+ Fan-Out (parallel Agent calls in single message):
63
+ ├── Agent "security" (Explore): Audit for OWASP top 10 → findings.md
64
+ ├── Agent "perf" (Explore): Profile and benchmark → findings.md
65
+ └── Agent "a11y" (Explore): Check accessibility → findings.md
66
+
67
+ Fan-In (Loop):
68
+ └── Synthesize all findings → create action plan → implement
69
+ ```
70
+
71
+ ### Pattern 4: Scout-Then-Execute
72
+
73
+ Best for: Unfamiliar codebases or risky changes.
74
+
75
+ ```
76
+ Scout (single Agent, Explore type):
77
+ └── Map codebase, trace dependencies, identify risks → scout-report.md
78
+
79
+ Execute (Loop):
80
+ └── Use scout report as reference, implement changes
81
+ ```
82
+
83
+ ### Pattern 5: Pipeline with Checkpoints
84
+
85
+ Best for: Complex multi-stage transformations.
86
+
87
+ ```
88
+ Stage 1 (Loop): Parse + validate → intermediate output
89
+ checkpoint: verify schema
90
+ Stage 2 (Loop): Transform → draft output
91
+ checkpoint: run regression tests
92
+ Stage 3 (Parallel Agents): Apply to multiple files
93
+ checkpoint: final integration test
94
+ ```
95
+
96
+ ## Decision Matrix
97
+
98
+ | Factor | Score |
99
+ | ------------------------------ | ----- |
100
+ | Files span 3+ directories | +2 |
101
+ | Items are independent | +2 |
102
+ | Need full context to decide | -2 |
103
+ | Order matters | -2 |
104
+ | 10+ similar items | +1 |
105
+ | Needs cross-file understanding | -1 |
106
+ | Multiple services/repos | +3 |
107
+
108
+ - **Score >= 3**: Recommend parallel subagents
109
+ - **Score 0-2**: Sequential loop, optional scout phase
110
+ - **Score < 0**: Single sequential Loop
111
+
112
+ ## Report Convention
113
+
114
+ ```
115
+ .loophaus/
116
+ └── reports/
117
+ ├── {agent-name}.md # Individual agent output
118
+ ├── merged.md # Combined findings
119
+ └── plan.md # Action plan
120
+ ```
121
+
122
+ ## Integration with Loop Interview
123
+
124
+ When `/loop-plan` invokes this skill, provide:
125
+
126
+ 1. Recommended pattern
127
+ 2. Agent breakdown with roles and file boundaries
128
+ 3. Phase structure and checkpoints
129
+ 4. Ready-to-embed Agent tool call instructions for the loop prompt
@@ -0,0 +1,275 @@
1
+ ---
2
+ name: ralph-interview
3
+ description: "Interactive interview that generates optimized loop commands with PRD-based phase tracking. Compatible with ralph-skills prd.json format."
4
+ ---
5
+
6
+ # Loop Interview — Command Generator
7
+
8
+ You are an expert at crafting loop commands for the Loop plugin.
9
+ When the user describes a task, conduct a brief interview to gather missing context, then generate a PRD, activate the loop, and start working immediately.
10
+
11
+ ## Core Principles
12
+
13
+ - **PRD-driven**: All phases and items live in prd.json. The loop reads it each iteration.
14
+ - **Progress tracking**: progress.txt tracks what is done. Each iteration reads it to decide what is next.
15
+ - **One story per iteration**: Each loop iteration implements ONE user story, commits, and updates progress.
16
+ - **Self-correcting**: Every prompt embeds "modify, verify, retry on failure" cycles.
17
+ - **Escape hatches required**: Always specify what to do when stuck after N retries.
18
+ - **Objective completion criteria only**: No subjective criteria. Use test passes, linter clears, etc.
19
+ - **Parallel when possible**: Use loop orchestrator patterns for independent work streams.
20
+
21
+ ## Interview Process
22
+
23
+ When the user provides a task description, ask **concise questions** for any missing items below.
24
+ Skip items already covered. Bundle questions — max 3-5 per round, one round only if possible.
25
+
26
+ ### Required Information
27
+
28
+ | Category | What to confirm |
29
+ | ------------------------- | ------------------------------------------------------------------------------------ |
30
+ | **Scope** | Single feature? Multi-file? Full refactor? |
31
+ | **Success criteria** | What counts as "done"? (tests pass, build succeeds, spec checklist, etc.) |
32
+ | **Verification commands** | Commands for automated checks (`npx tsc --noEmit`, `npm test`, `npm run lint`, etc.) |
33
+ | **References** | Existing code, files, or patterns to follow? |
34
+ | **Spec file** | Is there a spec document? Path? |
35
+ | **Priority** | P1/P2 or other priority tiers? |
36
+ | **Constraints** | Must not break existing tests? Library restrictions? |
37
+ | **When stuck** | User's preferred fallback (document it? skip? suggest alternative?) |
38
+ | **Commit strategy** | Per-item commits? Bulk? Commit message convention? |
39
+ | **Parallelism potential** | Multiple services? Independent file groups? Broad search needed? |
40
+
41
+ ## Phase Design
42
+
43
+ ### When to Split into Phases
44
+
45
+ - **Research needed first** -> Phase 1: Analysis, Phase 2: Implementation
46
+ - **More than 8 items** -> Split by nature (e.g., P1/P2, frontend/backend)
47
+ - **Dependencies exist** -> Prerequisite work in a prior Phase
48
+ - **5 or fewer simple items** -> Single Phase is fine
49
+
50
+ ### When to Use Subagents (via loop orchestrator)
51
+
52
+ Evaluate the task against the loop orchestrator decision matrix:
53
+
54
+ | Factor | Score |
55
+ | ------------------------------ | ----- |
56
+ | Files span 3+ directories | +2 |
57
+ | Items are independent | +2 |
58
+ | Need full context to decide | -2 |
59
+ | Order matters | -2 |
60
+ | 10+ similar items | +1 |
61
+ | Needs cross-file understanding | -1 |
62
+ | Multiple services/repos | +3 |
63
+
64
+ - **Score >= 3**: Recommend parallel subagents within the loop prompt
65
+ - **Score 0-2**: Sequential loop, optional scout phase
66
+ - **Score < 0**: Single sequential Loop
67
+
68
+ ### Recommended max-iterations
69
+
70
+ | Task type | Iterations |
71
+ | ---------------------------------------------- | ---------- |
72
+ | Research only (file reads, pattern extraction) | 3-5 |
73
+ | Simple fixes, 1-3 items | 5-10 |
74
+ | Medium scope, 4-7 items | 10-20 |
75
+ | Large scope, 8+ items | 20-30 |
76
+ | TDD-based feature implementation | 15-30 |
77
+ | Full refactor / migration | 30-50 |
78
+
79
+ **Rule of thumb:** `story_count x 2 + 5` as baseline.
80
+
81
+ ## PRD Format: prd.json (ralph-skills compatible)
82
+
83
+ Generate PRDs in the **prd.json** format used by ralph-skills. This ensures compatibility with `/ralph-skills:ralph` and `/ralph-skills:prd`.
84
+
85
+ ### prd.json
86
+
87
+ ```json
88
+ {
89
+ "project": "[Project Name]",
90
+ "description": "[Feature description]",
91
+ "userStories": [
92
+ {
93
+ "id": "US-001",
94
+ "title": "[Story title]",
95
+ "description": "As a [user], I want [feature] so that [benefit]",
96
+ "acceptanceCriteria": [
97
+ "Specific verifiable criterion",
98
+ "Another criterion",
99
+ "Typecheck passes"
100
+ ],
101
+ "priority": 1,
102
+ "passes": false,
103
+ "notes": ""
104
+ }
105
+ ]
106
+ }
107
+ ```
108
+
109
+ ### Story Sizing Rules
110
+
111
+ Each story MUST be completable in ONE iteration (one context window):
112
+
113
+ - **Right-sized**: Add a DB column, create one component, update one endpoint
114
+ - **Too big (split)**: "Build entire dashboard", "Add authentication", "Refactor API"
115
+ - **Rule of thumb**: If you cannot describe the change in 2-3 sentences, split it
116
+
117
+ ### Story Ordering
118
+
119
+ Stories execute in priority order. Dependencies first:
120
+
121
+ 1. Schema/database changes
122
+ 2. Backend logic / server actions
123
+ 3. UI components that use the backend
124
+ 4. Aggregation views / dashboards
125
+
126
+ ### Acceptance Criteria Rules
127
+
128
+ - MUST be verifiable, not vague
129
+ - Always include: `"Typecheck passes"` (or equivalent verification)
130
+ - For UI stories: add `"Verify in browser"` or equivalent
131
+ - Bad: "Works correctly", "Good UX"
132
+ - Good: "Button shows confirmation dialog before deleting", "Filter persists in URL params"
133
+
134
+ ### progress.txt
135
+
136
+ An append-only log file that tracks iteration history:
137
+
138
+ ```
139
+ ## Codebase Patterns
140
+ - [Reusable patterns discovered during iteration]
141
+
142
+ ## Discoveries
143
+ - [US-008] Added during US-003: Missing input validation for edge case X
144
+ - [US-009] Added during US-005: Need migration script for schema change
145
+
146
+ ---
147
+
148
+ ## [Date] - US-001
149
+ - What was implemented
150
+ - Files changed
151
+ - **Learnings for future iterations:**
152
+ - Patterns discovered
153
+ - Gotchas encountered
154
+ - **Discoveries:** (if any new stories were added)
155
+ - US-008: [reason] — found while implementing [specific part]
156
+ ---
157
+ ```
158
+
159
+ The `## Codebase Patterns` section at the top is read first by each iteration to avoid repeating mistakes.
160
+ The `## Discoveries` section tracks all dynamically added stories with rationale.
161
+
162
+ ## Compatibility with Existing Skills
163
+
164
+ ### ralph-skills:prd (marketplace)
165
+
166
+ - Our prd.json output uses the EXACT same format
167
+ - User can generate PRD with `/ralph-skills:prd`, then use our interview to generate the loop command
168
+ - Or use our interview to generate both PRD and loop command
169
+
170
+ ### ralph-skills:ralph (marketplace)
171
+
172
+ - Our loop prompt follows the same pattern as ralph-skills prompt.md
173
+ - Same prd.json format, same progress.txt format
174
+ - Same `passes: true/false` tracking, same commit convention
175
+ - Same `<promise>COMPLETE</promise>` completion signal
176
+
177
+ ### Official loop plugin (claude-plugins-official)
178
+
179
+ - If the official plugin is installed, this interview works with its stop hook
180
+ - PRD and progress files work with either stop hook
181
+
182
+ ## Rules
183
+
184
+ - **No subjective completion criteria**: Banned phrases: "works well", "looks clean", "properly done."
185
+ - **No prompt without verification**: At least one automated check is mandatory.
186
+ - **No missing escape hatch**: Every prompt MUST have a "When Stuck" section.
187
+ - **No oversized stories**: Each story must be completable in ONE iteration. Split if too big.
188
+ - **Always use prd.json format**: Ensures compatibility with ralph-skills ecosystem.
189
+ - **Default promise is COMPLETE**: Use `<promise>COMPLETE</promise>` to match ralph-skills convention.
190
+ - **Always overwrite**: Never ask before overwriting prd.json or progress.txt. Just write them.
191
+
192
+ ## Conversation Flow
193
+
194
+ ```
195
+ [User] -> /loop-plan "build X feature"
196
+ [Assistant] -> Interview questions (1 round, skip if context is sufficient)
197
+ [User] -> Answers
198
+ [Assistant] -> Shows PRD briefly, asks "Ready?"
199
+ [User] -> "y"
200
+ [Assistant] -> Writes files + activates loop + starts US-001 IN THE SAME RESPONSE
201
+ ```
202
+
203
+ ### Quick-Run
204
+
205
+ If the user includes "run immediately", "just do it", "run it", "바로 실행", "바로 시작", or "--run":
206
+ Skip the "Ready?" prompt. Go straight to activation after showing the PRD briefly.
207
+
208
+ ## Activation Sequence
209
+
210
+ When the user confirms (or quick-run), execute ALL of these steps in a SINGLE response. Do NOT stop between steps.
211
+
212
+ IMPORTANT: Always overwrite existing prd.json and progress.txt without asking. Do NOT check if they exist. Do NOT ask the user for confirmation before overwriting. Do NOT archive old files. Just write them.
213
+
214
+ ### Step 1: Write prd.json via Bash
215
+
216
+ ```bash
217
+ cat > prd.json << 'EOF'
218
+ { ... generated PRD ... }
219
+ EOF
220
+ ```
221
+
222
+ ### Step 2: Write progress.txt via Bash
223
+
224
+ ```bash
225
+ cat > progress.txt << 'EOF'
226
+ ## Codebase Patterns
227
+ (none yet)
228
+ EOF
229
+ ```
230
+
231
+ ### Step 3: Activate the stop hook via Bash
232
+
233
+ Write the loop state file that makes the stop hook intercept session exits:
234
+
235
+ ```bash
236
+ mkdir -p .loophaus
237
+ cat > .loophaus/state.json << 'EOF'
238
+ {
239
+ "active": true,
240
+ "prompt": "Read prd.json for task plan. Read progress.txt for status (Codebase Patterns first). Pick highest priority story where passes is false. Implement that ONE story. Run verification: <VERIFY_CMD>. On failure: fix and retry, max 3 times. On success: commit with feat: [Story ID] - [Title]. Update prd.json: set passes to true. DISCOVERY PHASE: Review what you just built — did you find hidden complexity, missing edge cases, new dependencies, or broken assumptions? If YES: add new stories to prd.json (next sequential ID, passes: false), log discovery in progress.txt under Discoveries section. If NO: just append learnings to progress.txt. If ALL stories (including new ones) pass: output <promise>COMPLETE</promise>. When stuck: set notes in prd.json, skip to next story.",
241
+ "completionPromise": "COMPLETE",
242
+ "maxIterations": <N>,
243
+ "currentIteration": 0,
244
+ "sessionId": ""
245
+ }
246
+ EOF
247
+ ```
248
+
249
+ Replace `<VERIFY_CMD>` with the actual verification command and `<N>` with the recommended max iterations.
250
+
251
+ ### Step 4: START WORKING ON US-001 IMMEDIATELY
252
+
253
+ This is the critical step. After writing files, you MUST begin actual work in the SAME response:
254
+
255
+ 1. Read the prd.json you just wrote
256
+ 2. Pick the first story (US-001)
257
+ 3. Implement it — write real code, make real changes
258
+ 4. Run the verification command
259
+ 5. Commit the changes
260
+ 6. Update prd.json (set passes: true)
261
+ 7. Append to progress.txt
262
+
263
+ Do NOT:
264
+
265
+ - Say "loop is now active" and stop
266
+ - Say "starting work on US-001" and stop
267
+ - Print a summary and wait for user input
268
+ - Ask if the user wants to proceed
269
+
270
+ DO:
271
+
272
+ - Actually write code
273
+ - Actually run tests
274
+ - Actually commit
275
+ - The stop hook will handle continuation to US-002 when you finish