thrivekit 2.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.
- package/.claude/commands/explain.md +114 -0
- package/.claude/commands/idea.md +370 -0
- package/.claude/commands/my-dna.md +122 -0
- package/.claude/commands/prd.md +286 -0
- package/.claude/commands/review.md +167 -0
- package/.claude/commands/sign.md +32 -0
- package/.claude/commands/styleguide.md +450 -0
- package/.claude/commands/tour.md +301 -0
- package/.claude/commands/vibe-check.md +116 -0
- package/.claude/commands/vibe-help.md +47 -0
- package/.claude/commands/vibe-list.md +203 -0
- package/.claude/settings.json +75 -0
- package/.claude/settings.local.json +12 -0
- package/.pre-commit-hooks.yaml +102 -0
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/bin/postinstall.sh +29 -0
- package/bin/ralph.sh +171 -0
- package/bin/thrivekit.sh +24 -0
- package/bin/vibe-check.js +19 -0
- package/dist/checks/check-any-types.d.ts +6 -0
- package/dist/checks/check-any-types.d.ts.map +1 -0
- package/dist/checks/check-any-types.js +73 -0
- package/dist/checks/check-any-types.js.map +1 -0
- package/dist/checks/check-commented-code.d.ts +6 -0
- package/dist/checks/check-commented-code.d.ts.map +1 -0
- package/dist/checks/check-commented-code.js +81 -0
- package/dist/checks/check-commented-code.js.map +1 -0
- package/dist/checks/check-console-error.d.ts +6 -0
- package/dist/checks/check-console-error.d.ts.map +1 -0
- package/dist/checks/check-console-error.js +41 -0
- package/dist/checks/check-console-error.js.map +1 -0
- package/dist/checks/check-debug-statements.d.ts +6 -0
- package/dist/checks/check-debug-statements.d.ts.map +1 -0
- package/dist/checks/check-debug-statements.js +120 -0
- package/dist/checks/check-debug-statements.js.map +1 -0
- package/dist/checks/check-deep-nesting.d.ts +6 -0
- package/dist/checks/check-deep-nesting.d.ts.map +1 -0
- package/dist/checks/check-deep-nesting.js +116 -0
- package/dist/checks/check-deep-nesting.js.map +1 -0
- package/dist/checks/check-docker-platform.d.ts +6 -0
- package/dist/checks/check-docker-platform.d.ts.map +1 -0
- package/dist/checks/check-docker-platform.js +42 -0
- package/dist/checks/check-docker-platform.js.map +1 -0
- package/dist/checks/check-dry-violations.d.ts +6 -0
- package/dist/checks/check-dry-violations.d.ts.map +1 -0
- package/dist/checks/check-dry-violations.js +124 -0
- package/dist/checks/check-dry-violations.js.map +1 -0
- package/dist/checks/check-empty-catch.d.ts +6 -0
- package/dist/checks/check-empty-catch.d.ts.map +1 -0
- package/dist/checks/check-empty-catch.js +111 -0
- package/dist/checks/check-empty-catch.js.map +1 -0
- package/dist/checks/check-function-length.d.ts +6 -0
- package/dist/checks/check-function-length.d.ts.map +1 -0
- package/dist/checks/check-function-length.js +152 -0
- package/dist/checks/check-function-length.js.map +1 -0
- package/dist/checks/check-hardcoded-ai-models.d.ts +10 -0
- package/dist/checks/check-hardcoded-ai-models.d.ts.map +1 -0
- package/dist/checks/check-hardcoded-ai-models.js +102 -0
- package/dist/checks/check-hardcoded-ai-models.js.map +1 -0
- package/dist/checks/check-hardcoded-urls.d.ts +6 -0
- package/dist/checks/check-hardcoded-urls.d.ts.map +1 -0
- package/dist/checks/check-hardcoded-urls.js +124 -0
- package/dist/checks/check-hardcoded-urls.js.map +1 -0
- package/dist/checks/check-magic-numbers.d.ts +6 -0
- package/dist/checks/check-magic-numbers.d.ts.map +1 -0
- package/dist/checks/check-magic-numbers.js +116 -0
- package/dist/checks/check-magic-numbers.js.map +1 -0
- package/dist/checks/check-secrets.d.ts +6 -0
- package/dist/checks/check-secrets.d.ts.map +1 -0
- package/dist/checks/check-secrets.js +138 -0
- package/dist/checks/check-secrets.js.map +1 -0
- package/dist/checks/check-snake-case-ts.d.ts +6 -0
- package/dist/checks/check-snake-case-ts.d.ts.map +1 -0
- package/dist/checks/check-snake-case-ts.js +78 -0
- package/dist/checks/check-snake-case-ts.js.map +1 -0
- package/dist/checks/check-todo-fixme.d.ts +6 -0
- package/dist/checks/check-todo-fixme.d.ts.map +1 -0
- package/dist/checks/check-todo-fixme.js +41 -0
- package/dist/checks/check-todo-fixme.js.map +1 -0
- package/dist/checks/check-unsafe-html.d.ts +6 -0
- package/dist/checks/check-unsafe-html.d.ts.map +1 -0
- package/dist/checks/check-unsafe-html.js +101 -0
- package/dist/checks/check-unsafe-html.js.map +1 -0
- package/dist/checks/index.d.ts +30 -0
- package/dist/checks/index.d.ts.map +1 -0
- package/dist/checks/index.js +57 -0
- package/dist/checks/index.js.map +1 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +206 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/file-reader.d.ts +24 -0
- package/dist/utils/file-reader.d.ts.map +1 -0
- package/dist/utils/file-reader.js +140 -0
- package/dist/utils/file-reader.js.map +1 -0
- package/dist/utils/patterns.d.ts +27 -0
- package/dist/utils/patterns.d.ts.map +1 -0
- package/dist/utils/patterns.js +84 -0
- package/dist/utils/patterns.js.map +1 -0
- package/dist/utils/reporters.d.ts +21 -0
- package/dist/utils/reporters.d.ts.map +1 -0
- package/dist/utils/reporters.js +115 -0
- package/dist/utils/reporters.js.map +1 -0
- package/dist/utils/types.d.ts +71 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +5 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +82 -0
- package/ralph/api.sh +210 -0
- package/ralph/backup.sh +838 -0
- package/ralph/browser-verify/README.md +135 -0
- package/ralph/browser-verify/verify.ts +450 -0
- package/ralph/checks/check-fastapi-responses.py +155 -0
- package/ralph/hooks/hooks-config.json +72 -0
- package/ralph/hooks/inject-context.sh +44 -0
- package/ralph/hooks/install.sh +207 -0
- package/ralph/hooks/log-tools.sh +45 -0
- package/ralph/hooks/protect-prd.sh +27 -0
- package/ralph/hooks/save-learnings.sh +36 -0
- package/ralph/hooks/warn-debug.sh +54 -0
- package/ralph/hooks/warn-empty-catch.sh +63 -0
- package/ralph/hooks/warn-secrets.sh +89 -0
- package/ralph/hooks/warn-urls.sh +77 -0
- package/ralph/init.sh +388 -0
- package/ralph/loop.sh +570 -0
- package/ralph/playwright.sh +238 -0
- package/ralph/prd.sh +295 -0
- package/ralph/setup/feature-tour.sh +155 -0
- package/ralph/setup/quick-setup.sh +239 -0
- package/ralph/setup/tutorial.sh +159 -0
- package/ralph/setup/ui.sh +136 -0
- package/ralph/setup.sh +353 -0
- package/ralph/signs.sh +150 -0
- package/ralph/utils.sh +682 -0
- package/ralph/verify/browser.sh +324 -0
- package/ralph/verify/lint.sh +363 -0
- package/ralph/verify/review.sh +164 -0
- package/ralph/verify/tests.sh +81 -0
- package/ralph/verify.sh +224 -0
- package/templates/PROMPT.md +235 -0
- package/templates/config/fullstack.json +86 -0
- package/templates/config/go.json +81 -0
- package/templates/config/minimal.json +76 -0
- package/templates/config/node.json +81 -0
- package/templates/config/python.json +81 -0
- package/templates/config/rust.json +81 -0
- package/templates/examples/CLAUDE-django.md +174 -0
- package/templates/examples/CLAUDE-fastapi.md +270 -0
- package/templates/examples/CLAUDE-fastmcp.md +352 -0
- package/templates/examples/CLAUDE-fullstack.md +256 -0
- package/templates/examples/CLAUDE-node.md +246 -0
- package/templates/examples/CLAUDE-react.md +138 -0
- package/templates/optional/cursorrules.template +147 -0
- package/templates/optional/eslint.config.js +34 -0
- package/templates/optional/lint-staged.config.js +34 -0
- package/templates/optional/ruff.toml +125 -0
- package/templates/optional/vibe-check.yml +116 -0
- package/templates/optional/vscode-settings.json +127 -0
- package/templates/signs.json +46 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate an executable PRD for Ralph from an idea file or description.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /prd - Generate PRD for Ralph
|
|
6
|
+
|
|
7
|
+
Generate executable stories for Ralph's autonomous development loop.
|
|
8
|
+
|
|
9
|
+
**CRITICAL: This command does NOT write code. It produces `.ralph/prd.json` only.**
|
|
10
|
+
|
|
11
|
+
## User Input
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
$ARGUMENTS
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
### Step 1: Determine Input Type
|
|
20
|
+
|
|
21
|
+
**If `$ARGUMENTS` is empty:**
|
|
22
|
+
1. Check for idea files:
|
|
23
|
+
```bash
|
|
24
|
+
ls docs/ideas/*.md 2>/dev/null || echo "No ideas found"
|
|
25
|
+
```
|
|
26
|
+
2. Ask: "Would you like to:
|
|
27
|
+
- Convert an idea file (e.g., `/prd auth` for `docs/ideas/auth.md`)
|
|
28
|
+
- Describe a feature directly (e.g., `/prd 'Add user logout button'`)"
|
|
29
|
+
|
|
30
|
+
**If `$ARGUMENTS` looks like a file reference** (no spaces, matches `docs/ideas/*.md`):
|
|
31
|
+
- If it's a full path, use it directly
|
|
32
|
+
- If it's just a name like `content-engine`, look for `docs/ideas/content-engine.md`
|
|
33
|
+
- Proceed to "Read and Understand the Idea"
|
|
34
|
+
|
|
35
|
+
**If `$ARGUMENTS` is a description** (has spaces, is a sentence):
|
|
36
|
+
- This is the **quick PRD flow** - no `docs/ideas/` file created
|
|
37
|
+
- Good for small features that don't need documentation
|
|
38
|
+
- Skip to "Confirm Understanding" below
|
|
39
|
+
|
|
40
|
+
### Step 2a: Read and Understand the Idea (from file)
|
|
41
|
+
|
|
42
|
+
Read the idea file and summarize:
|
|
43
|
+
|
|
44
|
+
Say: "I've read `{path}`. Here's my understanding:
|
|
45
|
+
|
|
46
|
+
**Feature:** {name}
|
|
47
|
+
**Problem:** {one line}
|
|
48
|
+
**Solution:** {one line}
|
|
49
|
+
**Scope:** {key items}
|
|
50
|
+
|
|
51
|
+
I'll now split this into {N} stories for Ralph. Continue?"
|
|
52
|
+
|
|
53
|
+
**STOP and wait for user confirmation.**
|
|
54
|
+
|
|
55
|
+
### Step 2b: Confirm Understanding (from description)
|
|
56
|
+
|
|
57
|
+
If working from a direct description, first explore the codebase briefly:
|
|
58
|
+
```bash
|
|
59
|
+
ls -la src/ app/ 2>/dev/null | head -20
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Then say: "I'll create a PRD for: **{description}**
|
|
63
|
+
|
|
64
|
+
Before I generate stories, quick questions:
|
|
65
|
+
1. **Type:** Frontend, backend, or fullstack?
|
|
66
|
+
2. **Scale:** Any specific limits (users, items, rate limits)?
|
|
67
|
+
3. **Anything else** I should know?
|
|
68
|
+
|
|
69
|
+
(Or say 'go' to proceed with defaults)"
|
|
70
|
+
|
|
71
|
+
**STOP and wait for user input** (can be brief or 'go').
|
|
72
|
+
|
|
73
|
+
### Step 3: Check for Existing PRD
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
cat .ralph/prd.json 2>/dev/null
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If it exists, read it and say:
|
|
80
|
+
"📋 `.ralph/prd.json` exists with {N} stories ({M} completed, {P} pending).
|
|
81
|
+
|
|
82
|
+
Options:
|
|
83
|
+
- **'append'** - Add new stories to the existing PRD (recommended)
|
|
84
|
+
- **'overwrite'** - Replace it entirely
|
|
85
|
+
- **'cancel'** - Stop here"
|
|
86
|
+
|
|
87
|
+
**STOP and wait for user choice.**
|
|
88
|
+
|
|
89
|
+
If user chooses **'append'**:
|
|
90
|
+
- Find highest existing story number (ignore prefix - could be US-005 or TASK-005)
|
|
91
|
+
- **Always use TASK- prefix** for new stories (e.g., if highest is US-005 or TASK-005, new stories start at TASK-006)
|
|
92
|
+
- New stories will be added after existing ones
|
|
93
|
+
|
|
94
|
+
### Step 4: Split into Stories
|
|
95
|
+
|
|
96
|
+
Break the idea into small, executable stories:
|
|
97
|
+
|
|
98
|
+
- Each story completable in one Claude session (~10-15 min)
|
|
99
|
+
- Max 3-4 acceptance criteria per story
|
|
100
|
+
- Order by dependency
|
|
101
|
+
- Max 10 stories (suggest phases if more needed)
|
|
102
|
+
- If appending, start IDs from the next available number
|
|
103
|
+
|
|
104
|
+
### Step 5: Write PRD
|
|
105
|
+
|
|
106
|
+
1. Ensure .ralph directory exists and allow PRD edit:
|
|
107
|
+
```bash
|
|
108
|
+
mkdir -p .ralph && touch .ralph/.prd-edit-allowed
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
2. Write to `.ralph/prd.json`:
|
|
112
|
+
- If **overwriting** or no existing PRD: Create new file with full structure
|
|
113
|
+
- If **appending**: Read existing JSON, add new stories to the `stories` array, update `metadata.estimatedStories` count, write back
|
|
114
|
+
|
|
115
|
+
3. Say: "I've {created|updated} the PRD with {N} stories ({X} new).
|
|
116
|
+
|
|
117
|
+
Review `.ralph/prd.json` and let me know:
|
|
118
|
+
- **'approved'** - Ready for `ralph run`
|
|
119
|
+
- **'edit [changes]'** - Tell me what to change
|
|
120
|
+
- Or edit the JSON directly and say **'done'**"
|
|
121
|
+
|
|
122
|
+
**STOP and wait for user response.**
|
|
123
|
+
|
|
124
|
+
### Step 6: Final Instructions
|
|
125
|
+
|
|
126
|
+
Once approved, say:
|
|
127
|
+
|
|
128
|
+
"PRD is ready!
|
|
129
|
+
|
|
130
|
+
**Source:** `{idea-file-path}`
|
|
131
|
+
**PRD:** `.ralph/prd.json` ({N} stories)
|
|
132
|
+
|
|
133
|
+
To start autonomous development:
|
|
134
|
+
```bash
|
|
135
|
+
ralph run
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Ralph will work through each story, running tests and committing as it goes."
|
|
139
|
+
|
|
140
|
+
**DO NOT start implementing code.**
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## PRD JSON Structure
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"feature": {
|
|
149
|
+
"name": "Feature Name",
|
|
150
|
+
"ideaFile": "docs/ideas/{feature-name}.md",
|
|
151
|
+
"branch": "feature/{feature-name}",
|
|
152
|
+
"status": "pending"
|
|
153
|
+
},
|
|
154
|
+
"metadata": {
|
|
155
|
+
"createdAt": "ISO timestamp",
|
|
156
|
+
"estimatedStories": 5,
|
|
157
|
+
"complexity": "low|medium|high"
|
|
158
|
+
},
|
|
159
|
+
"stories": [
|
|
160
|
+
{
|
|
161
|
+
"id": "TASK-001",
|
|
162
|
+
"type": "frontend|backend",
|
|
163
|
+
"title": "Short description",
|
|
164
|
+
"passes": false,
|
|
165
|
+
|
|
166
|
+
"files": {
|
|
167
|
+
"create": ["paths to new files"],
|
|
168
|
+
"modify": ["paths to existing files"],
|
|
169
|
+
"reuse": ["existing files to import from"]
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
"acceptanceCriteria": [
|
|
173
|
+
"What it should do"
|
|
174
|
+
],
|
|
175
|
+
|
|
176
|
+
"errorHandling": [
|
|
177
|
+
"What happens when things fail"
|
|
178
|
+
],
|
|
179
|
+
|
|
180
|
+
"testSteps": [
|
|
181
|
+
"MUST be executable shell commands - see examples below"
|
|
182
|
+
],
|
|
183
|
+
|
|
184
|
+
"dependsOn": [],
|
|
185
|
+
|
|
186
|
+
"notes": ""
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Frontend stories also need:
|
|
193
|
+
- `testUrl` - URL to test
|
|
194
|
+
- `loadingState` - What shows during async operations
|
|
195
|
+
- `a11y` - Accessibility requirements
|
|
196
|
+
- `mobile` - How it works on mobile
|
|
197
|
+
|
|
198
|
+
### E2E Tests
|
|
199
|
+
Add `"e2e": true` to **any frontend story where users interact** with the feature:
|
|
200
|
+
- Forms, buttons, inputs, modals, wizards → e2e
|
|
201
|
+
- Real-time features, drag & drop, file uploads → e2e
|
|
202
|
+
- Multi-page flows, navigation → e2e
|
|
203
|
+
- Static display-only components (no interaction) → skip e2e
|
|
204
|
+
|
|
205
|
+
When `e2e: true`, the story should:
|
|
206
|
+
- Create a Playwright test file in `tests/e2e/{story-id}.spec.ts`
|
|
207
|
+
- Include the test in `testSteps`: `"npx playwright test tests/e2e/{story-id}.spec.ts"`
|
|
208
|
+
- **Skip in CI** (runs nightly instead): Add `test.skip(!!process.env.CI, 'Runs nightly');` at top of test
|
|
209
|
+
|
|
210
|
+
Don't ask - if users touch it, test it.
|
|
211
|
+
|
|
212
|
+
### Backend stories also need:
|
|
213
|
+
- `apiEndpoints` - Endpoints to test
|
|
214
|
+
- `validation` - Input validation rules
|
|
215
|
+
- `auth` - Authentication requirements
|
|
216
|
+
- `scale` - Rate limiting, pagination (for list endpoints), caching
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Guidelines
|
|
221
|
+
|
|
222
|
+
- **Keep stories small** - If > 3-4 acceptance criteria, split it (~1000 tokens max)
|
|
223
|
+
- **Order by dependency** - Foundation stories first
|
|
224
|
+
- **Specify files explicitly** - Every story says which files to create/modify (max 3-4 files)
|
|
225
|
+
- **Define error handling** - Every story specifies failure behavior
|
|
226
|
+
- **Notes field** - Claude fills this as it works (files created, decisions made)
|
|
227
|
+
|
|
228
|
+
### Context Size Limits
|
|
229
|
+
Each story must be completable in ONE Claude session:
|
|
230
|
+
- **Max ~1000 tokens** for story description
|
|
231
|
+
- **Max 3-4 files** per story
|
|
232
|
+
- If too big, split it
|
|
233
|
+
|
|
234
|
+
### UI Stories Must Include Browser Verification
|
|
235
|
+
For frontend stories, acceptance criteria MUST include:
|
|
236
|
+
- "Page loads without console errors"
|
|
237
|
+
- "Required elements render" (specify which)
|
|
238
|
+
- "Works on mobile viewport (375px)"
|
|
239
|
+
|
|
240
|
+
These get verified by Playwright automatically.
|
|
241
|
+
|
|
242
|
+
### Test Steps - CRITICAL
|
|
243
|
+
**Test steps MUST be executable shell commands.** Ralph runs them with bash.
|
|
244
|
+
|
|
245
|
+
✅ **GOOD test steps (executable):**
|
|
246
|
+
```json
|
|
247
|
+
"testSteps": [
|
|
248
|
+
"curl -s http://localhost:3000/api/health | jq -e '.status == \"ok\"'",
|
|
249
|
+
"curl -s -o /dev/null -w '%{http_code}' http://localhost:8000/api/users | grep 200",
|
|
250
|
+
"test -f frontend/src/components/Button.tsx",
|
|
251
|
+
"grep -q 'export function Button' frontend/src/components/Button.tsx",
|
|
252
|
+
"cd frontend && npx tsc --noEmit",
|
|
253
|
+
"docker compose exec -T web python manage.py test app.tests.TestUserAPI",
|
|
254
|
+
"npx playwright test tests/e2e/dashboard.spec.ts",
|
|
255
|
+
"npx playwright test --grep 'login flow'",
|
|
256
|
+
"cd frontend && npm test -- --testPathPattern=Button.test.tsx"
|
|
257
|
+
]
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**For UI/visual verification, use Playwright tests:**
|
|
261
|
+
```json
|
|
262
|
+
"testSteps": [
|
|
263
|
+
"npx playwright test tests/e2e/chat-panel.spec.ts"
|
|
264
|
+
]
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
The Playwright test file can check:
|
|
268
|
+
- Element visibility and positioning
|
|
269
|
+
- Console errors (no errors in DevTools)
|
|
270
|
+
- Network requests completing
|
|
271
|
+
- Visual layout (screenshots, viewport checks)
|
|
272
|
+
- Accessibility (axe-core integration)
|
|
273
|
+
|
|
274
|
+
❌ **BAD test steps (not executable - will fail):**
|
|
275
|
+
```json
|
|
276
|
+
"testSteps": [
|
|
277
|
+
"Visit http://localhost:3000/dashboard",
|
|
278
|
+
"User can see the dashboard",
|
|
279
|
+
"Click the submit button",
|
|
280
|
+
"Form validates correctly",
|
|
281
|
+
"Chat panel renders in top 60%",
|
|
282
|
+
"Check DevTools for errors"
|
|
283
|
+
]
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**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.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Review code for issues, improvements, and best practices.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Code Review
|
|
6
|
+
|
|
7
|
+
Review code for issues, improvements, and best practices.
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
When asked to review code, perform a thorough analysis looking for:
|
|
12
|
+
|
|
13
|
+
### 1. Security Issues (Critical) - OWASP Top 10
|
|
14
|
+
|
|
15
|
+
- [ ] **Injection**: SQL, command, LDAP injection via string concatenation
|
|
16
|
+
- [ ] **XSS**: innerHTML, dangerouslySetInnerHTML, v-html with user data
|
|
17
|
+
- [ ] **Broken Auth**: Hardcoded credentials, weak passwords, missing rate limiting
|
|
18
|
+
- [ ] **Sensitive Data Exposure**: Secrets in code, sensitive data in logs/URLs
|
|
19
|
+
- [ ] **Broken Access Control**: Missing auth checks, IDOR, privilege escalation
|
|
20
|
+
- [ ] **Security Misconfiguration**: Debug mode, default credentials, verbose errors
|
|
21
|
+
- [ ] **Insecure Deserialization**: pickle, eval() with user input
|
|
22
|
+
- [ ] **Vulnerable Dependencies**: Outdated packages with known CVEs
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// VULNERABLE - SQL injection
|
|
26
|
+
const query = `SELECT * FROM users WHERE name = '${userInput}'`;
|
|
27
|
+
|
|
28
|
+
// SAFE - parameterized query
|
|
29
|
+
const query = "SELECT * FROM users WHERE name = ?";
|
|
30
|
+
db.execute(query, [userInput]);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// VULNERABLE - XSS
|
|
35
|
+
element.innerHTML = userInput;
|
|
36
|
+
|
|
37
|
+
// SAFE
|
|
38
|
+
element.textContent = userInput;
|
|
39
|
+
// or with sanitization
|
|
40
|
+
element.innerHTML = DOMPurify.sanitize(userInput);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Error Handling (High)
|
|
44
|
+
|
|
45
|
+
- [ ] Empty catch blocks
|
|
46
|
+
- [ ] Missing error boundaries
|
|
47
|
+
- [ ] Unhandled promise rejections
|
|
48
|
+
- [ ] Missing null/undefined checks
|
|
49
|
+
- [ ] Silent failures
|
|
50
|
+
|
|
51
|
+
### 3. Type Safety (High for TypeScript)
|
|
52
|
+
|
|
53
|
+
- [ ] Usage of `any` type
|
|
54
|
+
- [ ] Missing type annotations
|
|
55
|
+
- [ ] Type assertions that could fail
|
|
56
|
+
- [ ] Inconsistent types
|
|
57
|
+
|
|
58
|
+
### 4. Code Quality (Medium)
|
|
59
|
+
|
|
60
|
+
- [ ] Functions over 50 lines
|
|
61
|
+
- [ ] Deep nesting (4+ levels)
|
|
62
|
+
- [ ] Code duplication
|
|
63
|
+
- [ ] Magic numbers
|
|
64
|
+
- [ ] Unclear variable names
|
|
65
|
+
- [ ] Missing or outdated comments
|
|
66
|
+
|
|
67
|
+
### 5. Performance (Medium)
|
|
68
|
+
|
|
69
|
+
- [ ] N+1 query patterns
|
|
70
|
+
- [ ] Missing memoization for expensive operations
|
|
71
|
+
- [ ] Unnecessary re-renders (React)
|
|
72
|
+
- [ ] Large bundle imports
|
|
73
|
+
- [ ] Missing pagination
|
|
74
|
+
|
|
75
|
+
### 6. Maintainability (Low)
|
|
76
|
+
|
|
77
|
+
- [ ] Dead code
|
|
78
|
+
- [ ] Commented-out code
|
|
79
|
+
- [ ] TODOs that should be addressed
|
|
80
|
+
- [ ] Inconsistent patterns
|
|
81
|
+
- [ ] Missing tests
|
|
82
|
+
|
|
83
|
+
## Output Format
|
|
84
|
+
|
|
85
|
+
Structure your review like this:
|
|
86
|
+
|
|
87
|
+
```markdown
|
|
88
|
+
## Code Review: [filename or description]
|
|
89
|
+
|
|
90
|
+
### Summary
|
|
91
|
+
[1-2 sentence overview of the code quality]
|
|
92
|
+
|
|
93
|
+
### Critical Issues
|
|
94
|
+
These must be fixed before merging:
|
|
95
|
+
|
|
96
|
+
1. **[Issue Title]** (Line X)
|
|
97
|
+
- Problem: [What's wrong]
|
|
98
|
+
- Risk: [What could happen]
|
|
99
|
+
- Fix: [How to fix it]
|
|
100
|
+
```
|
|
101
|
+
[Code suggestion if applicable]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Improvements
|
|
105
|
+
These should be addressed:
|
|
106
|
+
|
|
107
|
+
1. **[Issue Title]** (Line X)
|
|
108
|
+
- Current: [What it does now]
|
|
109
|
+
- Better: [What it should do]
|
|
110
|
+
- Why: [Benefit of changing]
|
|
111
|
+
|
|
112
|
+
### Minor Suggestions
|
|
113
|
+
Nice to have, low priority:
|
|
114
|
+
|
|
115
|
+
1. **[Suggestion]** (Line X)
|
|
116
|
+
- [Brief explanation]
|
|
117
|
+
|
|
118
|
+
### What's Good
|
|
119
|
+
[Acknowledge good patterns and practices in the code]
|
|
120
|
+
|
|
121
|
+
### Verdict
|
|
122
|
+
[ ] Ready to merge
|
|
123
|
+
[ ] Needs minor changes
|
|
124
|
+
[ ] Needs significant changes
|
|
125
|
+
[ ] Needs rewrite
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Severity Guide
|
|
129
|
+
|
|
130
|
+
| Severity | Block Merge? | Examples |
|
|
131
|
+
|----------|--------------|----------|
|
|
132
|
+
| Critical | Yes | Security vulnerabilities, data loss risks |
|
|
133
|
+
| High | Yes | Missing error handling, type safety issues |
|
|
134
|
+
| Medium | Review | Performance issues, code quality |
|
|
135
|
+
| Low | No | Style preferences, minor improvements |
|
|
136
|
+
|
|
137
|
+
## Review Modes
|
|
138
|
+
|
|
139
|
+
### Quick Review
|
|
140
|
+
Focus only on critical and high-severity issues:
|
|
141
|
+
> "Quick review of this code"
|
|
142
|
+
|
|
143
|
+
### Full Review
|
|
144
|
+
Check everything:
|
|
145
|
+
> "Full review of src/api/users.ts"
|
|
146
|
+
|
|
147
|
+
### Security Review (OWASP Top 10)
|
|
148
|
+
Deep dive on security - injection, XSS, auth, access control, secrets:
|
|
149
|
+
> "Security review of the authentication flow"
|
|
150
|
+
> "Check for SQL injection vulnerabilities"
|
|
151
|
+
> "Full security audit of the API endpoints"
|
|
152
|
+
|
|
153
|
+
### Performance Review
|
|
154
|
+
Focus on performance:
|
|
155
|
+
> "Performance review of the dashboard page"
|
|
156
|
+
|
|
157
|
+
### Dependency Audit
|
|
158
|
+
Check for vulnerable dependencies:
|
|
159
|
+
> "Check our dependencies for known vulnerabilities"
|
|
160
|
+
|
|
161
|
+
## Be Constructive
|
|
162
|
+
|
|
163
|
+
- Explain **why** something is an issue, not just that it is
|
|
164
|
+
- Provide **specific** suggestions for fixes
|
|
165
|
+
- Acknowledge what's **done well**
|
|
166
|
+
- Be **respectful** - we all make mistakes
|
|
167
|
+
- Focus on the **code**, not the coder
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Add a learned pattern (sign) that Ralph will remember for future stories.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Add Sign
|
|
6
|
+
|
|
7
|
+
The user wants to add a sign - a pattern or rule that Ralph should remember for all future work.
|
|
8
|
+
|
|
9
|
+
**Get the pattern from the user.** Ask:
|
|
10
|
+
1. What's the pattern or rule? (e.g., "Always use select_related for foreign keys")
|
|
11
|
+
2. What category? (frontend, backend, general, testing)
|
|
12
|
+
|
|
13
|
+
**Then run:**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx ralph sign "THE PATTERN HERE" CATEGORY
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Examples:**
|
|
20
|
+
```bash
|
|
21
|
+
npx ralph sign "Never hardcode AI model names - use env vars" backend
|
|
22
|
+
npx ralph sign "Always add data-testid for Playwright tests" frontend
|
|
23
|
+
npx ralph sign "Use useCallback for event handlers passed to children" frontend
|
|
24
|
+
npx ralph sign "Always paginate list endpoints" backend
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**After adding, confirm:** "Added sign. Ralph will include this in every future story prompt."
|
|
28
|
+
|
|
29
|
+
**To see all signs:**
|
|
30
|
+
```bash
|
|
31
|
+
npx ralph signs
|
|
32
|
+
```
|