agentic-loop 1.0.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 (162) hide show
  1. package/.claude/commands/explain.md +114 -0
  2. package/.claude/commands/idea.md +398 -0
  3. package/.claude/commands/my-dna.md +122 -0
  4. package/.claude/commands/prd.md +286 -0
  5. package/.claude/commands/review.md +167 -0
  6. package/.claude/commands/sign.md +32 -0
  7. package/.claude/commands/styleguide.md +450 -0
  8. package/.claude/commands/tour.md +301 -0
  9. package/.claude/commands/vibe-check.md +116 -0
  10. package/.claude/commands/vibe-help.md +47 -0
  11. package/.claude/commands/vibe-list.md +203 -0
  12. package/.pre-commit-hooks.yaml +102 -0
  13. package/LICENSE +21 -0
  14. package/README.md +238 -0
  15. package/bin/agentic-loop.sh +24 -0
  16. package/bin/postinstall.sh +29 -0
  17. package/bin/ralph.sh +171 -0
  18. package/bin/vibe-check.js +19 -0
  19. package/dist/checks/check-any-types.d.ts +6 -0
  20. package/dist/checks/check-any-types.d.ts.map +1 -0
  21. package/dist/checks/check-any-types.js +73 -0
  22. package/dist/checks/check-any-types.js.map +1 -0
  23. package/dist/checks/check-commented-code.d.ts +6 -0
  24. package/dist/checks/check-commented-code.d.ts.map +1 -0
  25. package/dist/checks/check-commented-code.js +81 -0
  26. package/dist/checks/check-commented-code.js.map +1 -0
  27. package/dist/checks/check-console-error.d.ts +6 -0
  28. package/dist/checks/check-console-error.d.ts.map +1 -0
  29. package/dist/checks/check-console-error.js +41 -0
  30. package/dist/checks/check-console-error.js.map +1 -0
  31. package/dist/checks/check-debug-statements.d.ts +6 -0
  32. package/dist/checks/check-debug-statements.d.ts.map +1 -0
  33. package/dist/checks/check-debug-statements.js +120 -0
  34. package/dist/checks/check-debug-statements.js.map +1 -0
  35. package/dist/checks/check-deep-nesting.d.ts +6 -0
  36. package/dist/checks/check-deep-nesting.d.ts.map +1 -0
  37. package/dist/checks/check-deep-nesting.js +116 -0
  38. package/dist/checks/check-deep-nesting.js.map +1 -0
  39. package/dist/checks/check-docker-platform.d.ts +6 -0
  40. package/dist/checks/check-docker-platform.d.ts.map +1 -0
  41. package/dist/checks/check-docker-platform.js +42 -0
  42. package/dist/checks/check-docker-platform.js.map +1 -0
  43. package/dist/checks/check-dry-violations.d.ts +6 -0
  44. package/dist/checks/check-dry-violations.d.ts.map +1 -0
  45. package/dist/checks/check-dry-violations.js +124 -0
  46. package/dist/checks/check-dry-violations.js.map +1 -0
  47. package/dist/checks/check-empty-catch.d.ts +6 -0
  48. package/dist/checks/check-empty-catch.d.ts.map +1 -0
  49. package/dist/checks/check-empty-catch.js +111 -0
  50. package/dist/checks/check-empty-catch.js.map +1 -0
  51. package/dist/checks/check-function-length.d.ts +6 -0
  52. package/dist/checks/check-function-length.d.ts.map +1 -0
  53. package/dist/checks/check-function-length.js +152 -0
  54. package/dist/checks/check-function-length.js.map +1 -0
  55. package/dist/checks/check-hardcoded-ai-models.d.ts +10 -0
  56. package/dist/checks/check-hardcoded-ai-models.d.ts.map +1 -0
  57. package/dist/checks/check-hardcoded-ai-models.js +102 -0
  58. package/dist/checks/check-hardcoded-ai-models.js.map +1 -0
  59. package/dist/checks/check-hardcoded-urls.d.ts +6 -0
  60. package/dist/checks/check-hardcoded-urls.d.ts.map +1 -0
  61. package/dist/checks/check-hardcoded-urls.js +124 -0
  62. package/dist/checks/check-hardcoded-urls.js.map +1 -0
  63. package/dist/checks/check-magic-numbers.d.ts +6 -0
  64. package/dist/checks/check-magic-numbers.d.ts.map +1 -0
  65. package/dist/checks/check-magic-numbers.js +116 -0
  66. package/dist/checks/check-magic-numbers.js.map +1 -0
  67. package/dist/checks/check-secrets.d.ts +6 -0
  68. package/dist/checks/check-secrets.d.ts.map +1 -0
  69. package/dist/checks/check-secrets.js +138 -0
  70. package/dist/checks/check-secrets.js.map +1 -0
  71. package/dist/checks/check-snake-case-ts.d.ts +6 -0
  72. package/dist/checks/check-snake-case-ts.d.ts.map +1 -0
  73. package/dist/checks/check-snake-case-ts.js +78 -0
  74. package/dist/checks/check-snake-case-ts.js.map +1 -0
  75. package/dist/checks/check-todo-fixme.d.ts +6 -0
  76. package/dist/checks/check-todo-fixme.d.ts.map +1 -0
  77. package/dist/checks/check-todo-fixme.js +41 -0
  78. package/dist/checks/check-todo-fixme.js.map +1 -0
  79. package/dist/checks/check-unsafe-html.d.ts +6 -0
  80. package/dist/checks/check-unsafe-html.d.ts.map +1 -0
  81. package/dist/checks/check-unsafe-html.js +101 -0
  82. package/dist/checks/check-unsafe-html.js.map +1 -0
  83. package/dist/checks/index.d.ts +30 -0
  84. package/dist/checks/index.d.ts.map +1 -0
  85. package/dist/checks/index.js +57 -0
  86. package/dist/checks/index.js.map +1 -0
  87. package/dist/cli.d.ts +13 -0
  88. package/dist/cli.d.ts.map +1 -0
  89. package/dist/cli.js +208 -0
  90. package/dist/cli.js.map +1 -0
  91. package/dist/index.d.ts +9 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +10 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/utils/file-reader.d.ts +24 -0
  96. package/dist/utils/file-reader.d.ts.map +1 -0
  97. package/dist/utils/file-reader.js +146 -0
  98. package/dist/utils/file-reader.js.map +1 -0
  99. package/dist/utils/patterns.d.ts +27 -0
  100. package/dist/utils/patterns.d.ts.map +1 -0
  101. package/dist/utils/patterns.js +84 -0
  102. package/dist/utils/patterns.js.map +1 -0
  103. package/dist/utils/reporters.d.ts +21 -0
  104. package/dist/utils/reporters.d.ts.map +1 -0
  105. package/dist/utils/reporters.js +115 -0
  106. package/dist/utils/reporters.js.map +1 -0
  107. package/dist/utils/types.d.ts +71 -0
  108. package/dist/utils/types.d.ts.map +1 -0
  109. package/dist/utils/types.js +5 -0
  110. package/dist/utils/types.js.map +1 -0
  111. package/package.json +83 -0
  112. package/ralph/api.sh +216 -0
  113. package/ralph/backup.sh +838 -0
  114. package/ralph/browser-verify/README.md +135 -0
  115. package/ralph/browser-verify/verify.ts +450 -0
  116. package/ralph/checks/check-fastapi-responses.py +155 -0
  117. package/ralph/hooks/hooks-config.json +72 -0
  118. package/ralph/hooks/inject-context.sh +44 -0
  119. package/ralph/hooks/install.sh +207 -0
  120. package/ralph/hooks/log-tools.sh +45 -0
  121. package/ralph/hooks/protect-prd.sh +27 -0
  122. package/ralph/hooks/save-learnings.sh +36 -0
  123. package/ralph/hooks/warn-debug.sh +54 -0
  124. package/ralph/hooks/warn-empty-catch.sh +63 -0
  125. package/ralph/hooks/warn-secrets.sh +89 -0
  126. package/ralph/hooks/warn-urls.sh +77 -0
  127. package/ralph/init.sh +515 -0
  128. package/ralph/loop.sh +730 -0
  129. package/ralph/playwright.sh +238 -0
  130. package/ralph/prd.sh +295 -0
  131. package/ralph/setup/feature-tour.sh +155 -0
  132. package/ralph/setup/quick-setup.sh +239 -0
  133. package/ralph/setup/tutorial.sh +159 -0
  134. package/ralph/setup/ui.sh +136 -0
  135. package/ralph/setup.sh +401 -0
  136. package/ralph/signs.sh +150 -0
  137. package/ralph/utils.sh +682 -0
  138. package/ralph/verify/browser.sh +324 -0
  139. package/ralph/verify/lint.sh +363 -0
  140. package/ralph/verify/review.sh +152 -0
  141. package/ralph/verify/tests.sh +81 -0
  142. package/ralph/verify.sh +268 -0
  143. package/templates/PROMPT.md +235 -0
  144. package/templates/config/fullstack.json +86 -0
  145. package/templates/config/go.json +81 -0
  146. package/templates/config/minimal.json +76 -0
  147. package/templates/config/node.json +81 -0
  148. package/templates/config/python.json +81 -0
  149. package/templates/config/rust.json +81 -0
  150. package/templates/examples/CLAUDE-django.md +174 -0
  151. package/templates/examples/CLAUDE-fastapi.md +270 -0
  152. package/templates/examples/CLAUDE-fastmcp.md +352 -0
  153. package/templates/examples/CLAUDE-fullstack.md +256 -0
  154. package/templates/examples/CLAUDE-node.md +246 -0
  155. package/templates/examples/CLAUDE-react.md +138 -0
  156. package/templates/optional/cursorrules.template +147 -0
  157. package/templates/optional/eslint.config.js +34 -0
  158. package/templates/optional/lint-staged.config.js +34 -0
  159. package/templates/optional/ruff.toml +125 -0
  160. package/templates/optional/vibe-check.yml +116 -0
  161. package/templates/optional/vscode-settings.json +127 -0
  162. package/templates/signs.json +46 -0
@@ -0,0 +1,114 @@
1
+ ---
2
+ description: Explain what code does line by line so you can understand and learn from it.
3
+ ---
4
+
5
+ # Explain Code
6
+
7
+ Explain what code does, line by line, so you can understand and learn from it.
8
+
9
+ ## Instructions
10
+
11
+ When the user asks you to explain code:
12
+
13
+ ### Step 1: Identify the Code
14
+
15
+ If the user provides a file path, read that file. If they paste code directly, use that.
16
+
17
+ If no code is specified, ask:
18
+ > "What code would you like me to explain? Please provide a file path or paste the code."
19
+
20
+ ### Step 2: Provide Overview
21
+
22
+ Start with a high-level summary:
23
+ - What is the purpose of this code?
24
+ - What problem does it solve?
25
+ - How does it fit into the larger application?
26
+
27
+ ### Step 3: Walk Through Line by Line
28
+
29
+ For each significant section, explain:
30
+ - **What** it does (literally)
31
+ - **Why** it's needed (purpose)
32
+ - **How** it works (mechanism)
33
+
34
+ Use this format:
35
+
36
+ ```
37
+ Lines X-Y: [Brief description]
38
+ - This code [what it does]
39
+ - It's needed because [why]
40
+ - It works by [how]
41
+ ```
42
+
43
+ ### Step 4: Highlight Key Concepts
44
+
45
+ Point out important patterns and concepts:
46
+ - Design patterns used
47
+ - Language features that might be unfamiliar
48
+ - Best practices demonstrated
49
+ - Potential gotchas or edge cases
50
+
51
+ ### Step 5: Summarize
52
+
53
+ End with:
54
+ - Key takeaways
55
+ - What the user should understand now
56
+ - Suggestions for further learning if applicable
57
+
58
+ ## Example Output
59
+
60
+ ```
61
+ ## Overview
62
+
63
+ This is a React custom hook that manages authentication state. It handles
64
+ login, logout, and automatic token refresh.
65
+
66
+ ## Line-by-Line Explanation
67
+
68
+ ### Lines 1-5: Imports
69
+ ```typescript
70
+ import { useState, useEffect, useCallback } from 'react';
71
+ import { authApi } from '@/services/api';
72
+ import { User } from '@/types';
73
+ ```
74
+ - Imports React hooks for state management and side effects
75
+ - Imports the auth API service for making authentication requests
76
+ - Imports the User type for type safety
77
+
78
+ ### Lines 7-15: Hook Definition and State
79
+ ```typescript
80
+ export function useAuth() {
81
+ const [user, setUser] = useState<User | null>(null);
82
+ const [loading, setLoading] = useState(true);
83
+ ```
84
+ - Creates a custom hook that can be used in any component
85
+ - `user` state holds the current user (or null if logged out)
86
+ - `loading` state tracks whether we're still checking auth status
87
+ - Starting with `loading: true` prevents flash of unauthenticated content
88
+
89
+ ### Lines 17-30: Auto-refresh Effect
90
+ [... continue explanation ...]
91
+
92
+ ## Key Concepts
93
+
94
+ 1. **Custom Hooks**: Reusable logic extracted from components
95
+ 2. **Optimistic Updates**: UI updates before server confirms
96
+ 3. **Token Refresh**: Automatic re-authentication before expiry
97
+
98
+ ## Takeaways
99
+
100
+ - This hook centralizes all auth logic in one place
101
+ - Components just need to call `useAuth()` to access auth state
102
+ - The refresh logic runs automatically in the background
103
+ ```
104
+
105
+ ## Tips for Users
106
+
107
+ Ask me to explain:
108
+ - "Explain this function" (paste code)
109
+ - "Explain src/hooks/useAuth.ts"
110
+ - "Explain lines 50-100 of api.ts"
111
+ - "What does this regex do?"
112
+ - "Why is this pattern used here?"
113
+
114
+ I'll adjust the depth based on what you ask. For simple code, I'll be brief. For complex code, I'll be thorough.
@@ -0,0 +1,398 @@
1
+ ---
2
+ description: Brainstorm a feature idea, then generate PRDs for Ralph autonomous execution.
3
+ ---
4
+
5
+ # /idea - From Brainstorm to PRD
6
+
7
+ You are helping the user go from a rough idea to executable PRDs for Ralph.
8
+
9
+ **CRITICAL: This command does NOT write code. It produces documentation files only.**
10
+
11
+ ## When to Use
12
+
13
+ | Workflow | Best For |
14
+ |----------|----------|
15
+ | **`/idea`** | Structured brainstorming with guided questions - Claude leads |
16
+ | **Plan mode → save to `docs/ideas/`** | Free-form exploration - you lead the thinking |
17
+ | **`/prd "description"`** | Quick PRD, no docs artifact needed |
18
+
19
+ **Both `/idea` and plan mode can produce `docs/ideas/*.md` files.** The difference is who drives the conversation:
20
+ - `/idea` asks you structured questions (scope, UX, edge cases, etc.)
21
+ - Plan mode lets you explore freely with Claude's help
22
+
23
+ Use `/idea` when you want the structured checklist. Use plan mode when you prefer to think through it your way.
24
+
25
+ ## User Input
26
+
27
+ ```text
28
+ $ARGUMENTS
29
+ ```
30
+
31
+ ## Workflow
32
+
33
+ ### Step 1: Start Brainstorming
34
+
35
+ If `$ARGUMENTS` is empty, ask: "What feature or idea would you like to brainstorm?"
36
+
37
+ If `$ARGUMENTS` has content, acknowledge it and proceed.
38
+
39
+ Say: "Let's brainstorm this idea. I'll help you think it through, then we'll create documentation for Ralph to execute."
40
+
41
+ ### Step 2: Explore and Ask Questions
42
+
43
+ Help the user flesh out the idea through conversation:
44
+
45
+ 1. **Understand the goal** - What problem does this solve? Who benefits?
46
+ 2. **Explore the codebase** - Use Glob/Grep/Read to understand what exists and what patterns to follow
47
+ 3. **Ask clarifying questions** - Up to 5 questions about:
48
+ - Scope boundaries (what's in/out)
49
+ - User experience (what does the user see/do)
50
+ - Edge cases (what could go wrong)
51
+ - Dependencies (what does this touch)
52
+ - Security/permissions (who can do what)
53
+ - Scale (how many users/items/requests?)
54
+
55
+ ### Step 3: Summarize Before Writing
56
+
57
+ When you have enough information, summarize what you've learned:
58
+
59
+ Say: "Here's what I understand about the feature:
60
+
61
+ **Problem:** [summary]
62
+ **Solution:** [summary]
63
+ **Key decisions:** [list]
64
+
65
+ Ready to write this to `docs/ideas/{feature-name}.md`? Say **'yes'** or tell me what to adjust."
66
+
67
+ **STOP and wait for user confirmation before writing any files.**
68
+
69
+ ### Step 4: Write the Idea File
70
+
71
+ Once the user confirms, write the idea file:
72
+
73
+ 1. Create the directory if needed:
74
+ ```bash
75
+ mkdir -p docs/ideas
76
+ ```
77
+
78
+ 2. Write to `docs/ideas/{feature-name}.md` with this structure:
79
+ ```markdown
80
+ # {Feature Name}
81
+
82
+ ## Problem
83
+ What problem does this solve?
84
+
85
+ ## Solution
86
+ High-level description of the solution.
87
+
88
+ ## User Stories
89
+ - As a [user], I want to [action] so that [benefit]
90
+ - ...
91
+
92
+ ## Scope
93
+ ### In Scope
94
+ - ...
95
+
96
+ ### Out of Scope
97
+ - ...
98
+
99
+ ## Architecture
100
+ ### Directory Structure
101
+ - Where new files should go (be specific: `src/components/forms/`, not just `src/`)
102
+
103
+ ### Patterns to Follow
104
+ - Existing components/utilities to reuse
105
+ - Naming conventions
106
+
107
+ ### Do NOT Create
108
+ - List things that already exist (avoid duplication)
109
+
110
+ ## Technical Notes
111
+ - Dependencies
112
+ - Security considerations
113
+
114
+ ## Open Questions
115
+ - Any unresolved decisions
116
+ ```
117
+
118
+ 3. Open the file for review:
119
+ ```bash
120
+ open -a TextEdit docs/ideas/{feature-name}.md
121
+ ```
122
+
123
+ 4. Say: "I've written the idea to `docs/ideas/{feature-name}.md`.
124
+
125
+ Review it and let me know:
126
+ - **'approved'** - Ready to split into PRDs
127
+ - **'edit [changes]'** - Tell me what to change"
128
+
129
+ **STOP and wait for user response. Do not proceed until they say 'approved' or 'done'.**
130
+
131
+ ### Step 5: Split into PRDs
132
+
133
+ **Only proceed here after user explicitly approves the idea file.**
134
+
135
+ Say: "Now I'll split this into executable PRDs for Ralph. Each story will be small enough to complete in one session."
136
+
137
+ Break the idea into small, executable PRDs following the JSON structure below.
138
+
139
+ ### Step 6: Write PRD
140
+
141
+ 1. Ensure .ralph directory exists and allow PRD edit:
142
+ ```bash
143
+ mkdir -p .ralph && touch .ralph/.prd-edit-allowed
144
+ ```
145
+
146
+ 2. Write to `.ralph/prd.json` ensuring:
147
+ - Valid JSON syntax
148
+ - `feature.name` is set (not null/empty)
149
+ - `feature.status` is "pending"
150
+ - `stories` array is not empty
151
+ - Each story has `id`, `title`, and `passes: false`
152
+
153
+ 3. Validate the PRD was written correctly:
154
+ ```bash
155
+ jq -e '.feature.name and (.stories | length > 0) and (.stories | all(.id and .title and .passes == false))' .ralph/prd.json && echo "PRD valid" || echo "PRD invalid"
156
+ ```
157
+
158
+ 4. Say: "I've created the PRD with {N} stories in `.ralph/prd.json`.
159
+
160
+ Review and let me know:
161
+ - **'approved'** - Ready for `npx ralph run`
162
+ - **'edit [changes]'** - Tell me what to change"
163
+
164
+ **STOP and wait for user response. Do not proceed until they approve.**
165
+
166
+ ### Step 7: Final Review
167
+
168
+ Before finishing, do a quick sanity check on the PRD:
169
+
170
+ 1. **Read the PRD back:**
171
+ ```bash
172
+ cat .ralph/prd.json | jq '.'
173
+ ```
174
+
175
+ 2. **Review for common issues:**
176
+ - Are story IDs sequential and unique?
177
+ - Does each story have testable acceptance criteria?
178
+ - Are file paths specific (not vague like "src/")?
179
+ - Are dependencies correctly ordered?
180
+ - Are testSteps actually executable shell commands?
181
+ - Is any story too large (>4 acceptance criteria)?
182
+
183
+ 3. **If issues found**, say:
184
+ "I found some issues with the PRD:
185
+ - [issue 1]
186
+ - [issue 2]
187
+
188
+ Fixing now..."
189
+
190
+ Then fix the issues and rewrite the PRD.
191
+
192
+ 4. **If no issues**, proceed to final instructions.
193
+
194
+ ### Step 8: Final Instructions
195
+
196
+ Once the user approves the PRD, say:
197
+
198
+ "Ready for autonomous development!
199
+
200
+ **Idea:** `docs/ideas/{feature-name}.md`
201
+ **PRD:** `.ralph/prd.json` ({N} stories)
202
+
203
+ Run:
204
+ ```bash
205
+ npx ralph run
206
+ ```
207
+
208
+ **DO NOT start implementing code. The user will run `npx ralph run` separately.**
209
+
210
+ ---
211
+
212
+ ## PRD JSON Structure
213
+
214
+ ```json
215
+ {
216
+ "feature": {
217
+ "name": "Feature Name",
218
+ "ideaFile": "docs/ideas/{feature-name}.md",
219
+ "branch": "feature/{feature-name}",
220
+ "status": "pending"
221
+ },
222
+ "metadata": {
223
+ "createdAt": "ISO timestamp",
224
+ "estimatedStories": 5,
225
+ "complexity": "low|medium|high"
226
+ },
227
+ "stories": [
228
+ {
229
+ "id": "TASK-001",
230
+ "type": "frontend|backend",
231
+ "title": "Short description",
232
+ "passes": false,
233
+
234
+ "files": {
235
+ "create": ["paths to new files"],
236
+ "modify": ["paths to existing files"],
237
+ "reuse": ["existing files to import from"]
238
+ },
239
+
240
+ "acceptanceCriteria": [
241
+ "What it should do"
242
+ ],
243
+
244
+ "errorHandling": [
245
+ "What happens when things fail"
246
+ ],
247
+
248
+ "testSteps": [
249
+ "MUST be executable shell commands - see examples below"
250
+ ],
251
+
252
+ "dependsOn": [],
253
+
254
+ "notes": ""
255
+ }
256
+ ]
257
+ }
258
+ ```
259
+
260
+ ### Frontend stories also need:
261
+ - `testUrl` - URL to test
262
+ - `loadingState` - What shows during async operations
263
+ - `a11y` - Accessibility requirements
264
+ - `mobile` - How it works on mobile
265
+
266
+ ### E2E Tests
267
+ Add `"e2e": true` to **any frontend story where users interact** with the feature:
268
+ - Forms, buttons, inputs, modals, wizards → e2e
269
+ - Real-time features, drag & drop, file uploads → e2e
270
+ - Multi-page flows, navigation → e2e
271
+ - Static display-only components (no interaction) → skip e2e
272
+
273
+ When `e2e: true`, the story should:
274
+ - Create a Playwright test file in `tests/e2e/{story-id}.spec.ts`
275
+ - Include the test in `testSteps`: `"npx playwright test tests/e2e/{story-id}.spec.ts"`
276
+ - **Skip in CI** (runs nightly instead): Add `test.skip(!!process.env.CI, 'Runs nightly');` at top of test
277
+
278
+ Don't ask - if users touch it, test it.
279
+
280
+ ### Backend stories also need:
281
+ - `apiEndpoints` - Endpoints to test
282
+ - `validation` - Input validation rules
283
+ - `auth` - Authentication requirements
284
+ - `scale` - Rate limiting, pagination (for list endpoints), caching
285
+
286
+ ---
287
+
288
+ ## Guidelines
289
+
290
+ ### Story Guidelines
291
+ - **Keep stories small** - Max 3-4 acceptance criteria per story, ~1000 tokens max description
292
+ - **Order by dependency** - Stories that depend on others come later
293
+ - **Max 10 stories** - If more, suggest splitting into phases
294
+ - **Define error handling** - Every story specifies what happens on failure
295
+ - **Notes field** - Claude fills this as it works (files created, decisions made, context for next story)
296
+
297
+ ### Context Size Limits
298
+ Each story must be completable in ONE Claude session without context overflow:
299
+ - **Max ~1000 tokens** for story description (title + criteria + error handling)
300
+ - **Max 3-4 files** created or modified per story
301
+ - If a story feels too big, split it
302
+
303
+ ### UI Stories Must Include Browser Verification
304
+ For frontend stories, acceptance criteria MUST include:
305
+ - "Page loads without console errors"
306
+ - "Required elements render" (specify which: header, form, button, etc.)
307
+ - "Works on mobile viewport (375px)"
308
+
309
+ These get verified by Playwright, not just code review.
310
+
311
+ ### Test Steps - CRITICAL
312
+ **Test steps MUST be executable shell commands.** Ralph runs them with bash.
313
+
314
+ ✅ **GOOD test steps (executable):**
315
+ ```json
316
+ "testSteps": [
317
+ "curl -s http://localhost:3000/api/health | jq -e '.status == \"ok\"'",
318
+ "curl -s -o /dev/null -w '%{http_code}' http://localhost:8000/api/users | grep 200",
319
+ "test -f frontend/src/components/Button.tsx",
320
+ "grep -q 'export function Button' frontend/src/components/Button.tsx",
321
+ "cd frontend && npx tsc --noEmit",
322
+ "docker compose exec -T web python manage.py test app.tests.TestUserAPI",
323
+ "npx playwright test tests/e2e/dashboard.spec.ts",
324
+ "npx playwright test --grep 'login flow'",
325
+ "cd frontend && npm test -- --testPathPattern=Button.test.tsx"
326
+ ]
327
+ ```
328
+
329
+ **For UI/visual verification, use Playwright tests:**
330
+ ```json
331
+ "testSteps": [
332
+ "npx playwright test tests/e2e/chat-panel.spec.ts"
333
+ ]
334
+ ```
335
+
336
+ The Playwright test file can check:
337
+ - Element visibility and positioning
338
+ - Console errors (no errors in DevTools)
339
+ - Network requests completing
340
+ - Visual layout (screenshots, viewport checks)
341
+ - Accessibility (axe-core integration)
342
+
343
+ ❌ **BAD test steps (not executable - will fail):**
344
+ ```json
345
+ "testSteps": [
346
+ "Visit http://localhost:3000/dashboard",
347
+ "User can see the dashboard",
348
+ "Click the submit button",
349
+ "Form validates correctly",
350
+ "Chat panel renders in top 60%",
351
+ "Check DevTools for errors"
352
+ ]
353
+ ```
354
+
355
+ **If a step can't be automated**, leave it out of testSteps and put it in acceptanceCriteria instead. Ralph will verify acceptanceCriteria via code review, not by running commands.
356
+
357
+ ### Architecture Guidelines
358
+ - **Domain-driven directories** - Group by feature (`src/contact/`) not type (`src/components/`)
359
+ - **Max 300 lines per file** - Split large files
360
+ - **Reuse over recreate** - Check for existing utilities first
361
+ - **Explicit file paths** - Every story specifies exactly which files
362
+
363
+ ---
364
+
365
+ ## Error Handling
366
+
367
+ - If user provides no arguments, ask what they want to brainstorm
368
+ - If user abandons mid-flow, the idea file is still saved for later
369
+
370
+ ### If PRD Already Exists
371
+
372
+ Before writing to `.ralph/prd.json`, check if it exists:
373
+
374
+ ```bash
375
+ cat .ralph/prd.json 2>/dev/null | jq '{stories: .stories | length, completed: [.stories[] | select(.passes == true)] | length}'
376
+ ```
377
+
378
+ If it exists, say:
379
+ "📋 `.ralph/prd.json` already exists with {N} stories ({M} completed, {P} pending).
380
+
381
+ Options:
382
+ - **'append'** - Add new stories to existing PRD (recommended)
383
+ - **'overwrite'** - Replace entirely
384
+ - **'cancel'** - Stop here"
385
+
386
+ **STOP and wait for user choice.**
387
+
388
+ If **'append'**:
389
+ - Find highest existing story number (ignore prefix - could be US-019 or TASK-019)
390
+ - **Always use TASK- prefix** for new stories (e.g., if highest is US-019 or TASK-019, new stories start at TASK-020)
391
+ - Read existing PRD, add new stories to the `stories` array
392
+ - Update `metadata.estimatedStories` count
393
+ - Write back to `.ralph/prd.json`
394
+
395
+ If **'overwrite'**:
396
+ - Archive first: `mkdir -p .ralph/archive && mv .ralph/prd.json .ralph/archive/prd-$(date +%Y%m%d-%H%M%S).json`
397
+ - Allow edit: `touch .ralph/.prd-edit-allowed`
398
+ - Write new PRD
@@ -0,0 +1,122 @@
1
+ ---
2
+ description: Set up your personal DNA - how you like to work and communicate with Claude.
3
+ ---
4
+
5
+ # My DNA - Personal Style Setup
6
+
7
+ You are helping the user define their DNA - their personal voice and project values. This makes Claude's output match their style.
8
+
9
+ This updates `CLAUDE.md` in the project root with their values and style.
10
+
11
+ ## Step 1: Introduction
12
+
13
+ Say: "Let's set up your DNA so I can match your style and values in this project.
14
+
15
+ Your values shape everything - how we communicate, what we prioritize, and what the product feels like. A few quick questions."
16
+
17
+ ## Step 2: Ask About Core Values
18
+
19
+ Use AskUserQuestion:
20
+
21
+ **Question:** "What values should guide this project? Pick any that resonate."
22
+ **Header:** "Core values"
23
+ **multiSelect:** true
24
+ **Options:**
25
+ - **Respect / Kindness** - "Treat people well, in code and communication"
26
+ - **Simplicity / Clarity** - "Avoid jargon, make things understandable"
27
+ - **Sustainability** - "Build things that last, think long-term"
28
+
29
+ ## Step 3: Ask About Their Voice
30
+
31
+ Use AskUserQuestion:
32
+
33
+ **Question:** "How would you describe your writing style?"
34
+ **Header:** "Your voice"
35
+ **Options:**
36
+ - **Casual & direct** - "I write like I talk, no fluff"
37
+ - **Friendly & warm** - "Approachable, conversational"
38
+ - **Professional & clear** - "Polished but not stiff"
39
+ - **Minimal & precise** - "Say less, mean more"
40
+
41
+ ## Step 4: Ask About Project Priority
42
+
43
+ Use AskUserQuestion:
44
+
45
+ **Question:** "What matters most for this project right now?"
46
+ **Header:** "Priority"
47
+ **Options:**
48
+ - **Ship it** - "Get it working and out the door"
49
+ - **Make it solid** - "Quality and reliability first"
50
+ - **Make it beautiful** - "Design and UX matter most"
51
+ - **Make it scale** - "Building for growth"
52
+
53
+ ## Step 5: Ask About Audience
54
+
55
+ Use AskUserQuestion:
56
+
57
+ **Question:** "Who's this for?"
58
+ **Header:** "Audience"
59
+ **Options:**
60
+ - **Developers** - "Technical users who get it"
61
+ - **Everyone** - "Non-technical users, needs to be simple"
62
+ - **Business users** - "Professional, but not coders"
63
+ - **Just me** - "Personal project, I'm the user"
64
+
65
+ ## Step 6: Ask About Product Tone
66
+
67
+ Use AskUserQuestion:
68
+
69
+ **Question:** "What vibe should the product have?"
70
+ **Header:** "Product tone"
71
+ **Options:**
72
+ - **Friendly** - "Warm, approachable, maybe playful"
73
+ - **Professional** - "Clean, trustworthy, serious"
74
+ - **Minimal** - "Say less, let the product speak"
75
+ - **Bold** - "Confident, opinionated, distinctive"
76
+
77
+ ## Step 7: Optional Writing Sample
78
+
79
+ Ask:
80
+
81
+ "Optional: Paste a writing sample so I can match your voice. Could be anything - an email, a doc, a tweet. Or just say 'skip'."
82
+
83
+ If they provide a sample, note the patterns and include it. If they skip, move on.
84
+
85
+ ## Step 8: Update CLAUDE.md
86
+
87
+ Add a DNA section to `CLAUDE.md` in the project root. If CLAUDE.md exists, append. If not, create it.
88
+
89
+ Use a marker `<!-- my-dna -->` to identify the section. If marker exists, replace that section.
90
+
91
+ ```markdown
92
+ <!-- my-dna -->
93
+ ## DNA
94
+
95
+ ### Core Values
96
+ - [List their selected values]
97
+
98
+ ### Voice
99
+ [Their style + any notes from writing sample]
100
+
101
+ ### Project
102
+ - **Priority:** [ship it / solid / beautiful / scale]
103
+ - **Audience:** [developers / everyone / business / just me]
104
+ - **Tone:** [friendly / professional / minimal / bold]
105
+ ```
106
+
107
+ ## Step 9: Confirm
108
+
109
+ Say:
110
+
111
+ "Done! Added DNA to `CLAUDE.md`.
112
+
113
+ **Your style:** [One sentence summary, e.g., "Casual and direct, shipping fast for developers with a friendly vibe."]
114
+
115
+ I'll match this in code, docs, and commits. Run `/my-dna` again anytime to update."
116
+
117
+ ## Notes
118
+
119
+ - Keep it short - 5 questions max
120
+ - No scanning, just ask
121
+ - If DNA section exists in CLAUDE.md (marker: `<!-- my-dna -->`), replace it
122
+ - The goal is to make Claude's output match their style and values