catalyst-os 0.1.2 → 0.2.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/.catalyst/main/project-config.yaml +21 -0
- package/.catalyst/specs/spec-config.yaml +5 -0
- package/.claude/agents/scribe.md +23 -7
- package/.claude/commands/build-spec.md +172 -21
- package/.claude/commands/catalyze-project.md +67 -10
- package/.claude/commands/validate-spec.md +3 -9
- package/AGENTS.md +18 -14
- package/package.json +1 -1
- package/.catalyst/standards/coding.md +0 -187
- package/.catalyst/standards/git-workflow.md +0 -181
- package/.catalyst/standards/testing.md +0 -185
|
@@ -9,3 +9,24 @@ generated_files:
|
|
|
9
9
|
roadmap.md: "Development phases"
|
|
10
10
|
tech-stack.md: "Technology decisions"
|
|
11
11
|
|
|
12
|
+
# Git Configuration
|
|
13
|
+
git:
|
|
14
|
+
# Base branch for spec development (checkout from this branch)
|
|
15
|
+
# Common names: "development", "develop", "staging", "testing", "pre-prod"
|
|
16
|
+
# This is set during /catalyze-project based on user preference
|
|
17
|
+
development_branch: "development"
|
|
18
|
+
|
|
19
|
+
# Branch prefix for spec feature branches
|
|
20
|
+
# Example: "feat" creates branches like "feat/2026-01-11-supabase-auth"
|
|
21
|
+
branch_prefix: "feat"
|
|
22
|
+
|
|
23
|
+
# Protected branches (cannot commit directly)
|
|
24
|
+
protected_branches:
|
|
25
|
+
- "main"
|
|
26
|
+
- "master"
|
|
27
|
+
|
|
28
|
+
# Commit message templates
|
|
29
|
+
commit_templates:
|
|
30
|
+
red_phase: "test({scope}): write failing tests for {spec}"
|
|
31
|
+
green_phase: "feat({scope}): implement {spec}"
|
|
32
|
+
|
|
@@ -43,6 +43,11 @@ structure:
|
|
|
43
43
|
owner: any
|
|
44
44
|
description: "Images, diagrams, visual references"
|
|
45
45
|
|
|
46
|
+
references/:
|
|
47
|
+
owner: any
|
|
48
|
+
optional: true
|
|
49
|
+
description: "Screenshots, evidence, proof of issues (user-created)"
|
|
50
|
+
|
|
46
51
|
# Completed specs location
|
|
47
52
|
completed: "completed/"
|
|
48
53
|
|
package/.claude/agents/scribe.md
CHANGED
|
@@ -27,20 +27,36 @@ You create and maintain project documentation within the structured spec folder
|
|
|
27
27
|
|
|
28
28
|
**CRITICAL: All documentation goes to `.catalyst/specs/YYYY-MM-DD-{slug}/`**
|
|
29
29
|
|
|
30
|
+
### STRICT ALLOWLIST
|
|
31
|
+
|
|
32
|
+
Spec folders may **ONLY** contain these files:
|
|
33
|
+
|
|
34
|
+
| File | Owner | Purpose |
|
|
35
|
+
|------|-------|---------|
|
|
36
|
+
| `spec.md` | Scribe | Requirements + frontmatter |
|
|
37
|
+
| `research.md` | Scribe | Compiled research findings |
|
|
38
|
+
| `tasks.md` | Forger | Build DAG + progress |
|
|
39
|
+
| `validation.md` | Arbiter | Test results |
|
|
40
|
+
| `handoff.md` | Arbiter | Human-readable summary |
|
|
41
|
+
| `assets/` | Any | Images, diagrams |
|
|
42
|
+
| `references/` | Any | (Optional) Screenshots, evidence, proof |
|
|
43
|
+
|
|
44
|
+
**ANY OTHER FILE IS FORBIDDEN.**
|
|
45
|
+
|
|
30
46
|
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
└── assets/ # Images, diagrams
|
|
47
|
+
DO NOT CREATE:
|
|
48
|
+
✗ README.md
|
|
49
|
+
✗ notes.md
|
|
50
|
+
✗ implementation/
|
|
51
|
+
✗ Any other .md file
|
|
52
|
+
✗ Any other folder
|
|
38
53
|
```
|
|
39
54
|
|
|
40
55
|
**Rules:**
|
|
41
56
|
1. **UPDATE > CREATE** — Always update existing files, never create new random .md files
|
|
42
57
|
2. **No orphan docs** — Every document belongs to a spec folder
|
|
43
58
|
3. **Append to research.md** — Don't create separate research files
|
|
59
|
+
4. **DENY by default** — If it's not in the allowlist above, don't create it
|
|
44
60
|
|
|
45
61
|
## Your Responsibilities
|
|
46
62
|
|
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Implement a specification using **strict TDD**.
|
|
4
4
|
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## FORGE-MASTER BEHAVIORAL RULES
|
|
8
|
+
|
|
9
|
+
**You are an ORCHESTRATOR. You coordinate work, you do NOT do work.**
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
BEFORE writing ANY code or test:
|
|
13
|
+
→ STOP
|
|
14
|
+
→ Ask yourself: "Should a specialized agent do this?"
|
|
15
|
+
→ If YES: Use Task tool with appropriate subagent_type
|
|
16
|
+
→ If NO: You're probably wrong. Use the Task tool.
|
|
17
|
+
|
|
18
|
+
You may ONLY:
|
|
19
|
+
✓ Read files to understand context
|
|
20
|
+
✓ Use Task tool to spawn agents (forger, enforcer, smith, shaper, alchemist)
|
|
21
|
+
✓ Run test commands to verify gates
|
|
22
|
+
✓ Report status to user
|
|
23
|
+
|
|
24
|
+
You may NEVER:
|
|
25
|
+
✗ Write code (use smith or shaper)
|
|
26
|
+
✗ Write tests (use enforcer)
|
|
27
|
+
✗ Create task breakdowns (use forger)
|
|
28
|
+
✗ Write database schemas (use alchemist)
|
|
29
|
+
|
|
30
|
+
IF YOU ARE ABOUT TO USE Edit/Write TOOL ON A .py/.ts/.js FILE → STOP → SPAWN AN AGENT
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
5
35
|
## Usage
|
|
6
36
|
|
|
7
37
|
```
|
|
@@ -16,6 +46,30 @@ Implement a specification using **strict TDD**.
|
|
|
16
46
|
|
|
17
47
|
---
|
|
18
48
|
|
|
49
|
+
## GIT WORKFLOW
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
53
|
+
│ GIT CHECKPOINTS │
|
|
54
|
+
│ ─────────────── │
|
|
55
|
+
│ │
|
|
56
|
+
│ PHASE 0: Setup │
|
|
57
|
+
│ ├── Read .catalyst/main/project-config.yaml │
|
|
58
|
+
│ ├── Checkout to development_branch (default: main) │
|
|
59
|
+
│ └── Create branch: {branch_prefix}/{spec-slug} │
|
|
60
|
+
│ │
|
|
61
|
+
│ GATE 1: RED FLAG │
|
|
62
|
+
│ └── Commit: "test({scope}): write failing tests for {spec}" │
|
|
63
|
+
│ │
|
|
64
|
+
│ GATE 2: GREEN FLAG │
|
|
65
|
+
│ └── Commit: "feat({scope}): implement {spec}" │
|
|
66
|
+
│ │
|
|
67
|
+
│ Then: User runs /validate-spec and /approve-spec │
|
|
68
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
19
73
|
## TDD IS MANDATORY - NO EXCEPTIONS
|
|
20
74
|
|
|
21
75
|
```
|
|
@@ -23,17 +77,17 @@ Implement a specification using **strict TDD**.
|
|
|
23
77
|
|
|
24
78
|
The build MUST follow this exact sequence:
|
|
25
79
|
|
|
26
|
-
1.
|
|
27
|
-
2.
|
|
28
|
-
3. Verify
|
|
29
|
-
4.
|
|
80
|
+
1. Task(subagent_type="forger") -> Create tasks.md
|
|
81
|
+
2. Task(subagent_type="enforcer") -> Write ALL tests (must FAIL)
|
|
82
|
+
3. Verify -> Run tests, confirm RED
|
|
83
|
+
4. Task(subagent_type="smith/shaper/alchemist") -> Implement until GREEN
|
|
30
84
|
```
|
|
31
85
|
|
|
32
86
|
---
|
|
33
87
|
|
|
34
88
|
## ORCHESTRATION MODE
|
|
35
89
|
|
|
36
|
-
|
|
90
|
+
Forge-Master spawns specialized agents using the **Task tool**. Each phase is a separate agent.
|
|
37
91
|
|
|
38
92
|
### Output Location
|
|
39
93
|
|
|
@@ -107,9 +161,44 @@ forger -> enforcer -> GATE -> alchemist -> contracts -> [smith-1 + smith-2 + sha
|
|
|
107
161
|
|
|
108
162
|
The **Forge-Master** agent orchestrates the Technologists.
|
|
109
163
|
|
|
164
|
+
### Phase 0: Git Setup
|
|
165
|
+
|
|
166
|
+
**Before any work begins, set up the git branch for this spec.**
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
170
|
+
│ 📍 GIT SETUP │
|
|
171
|
+
│ ─────────── │
|
|
172
|
+
│ │
|
|
173
|
+
│ 1. Read git config from project-config.yaml: │
|
|
174
|
+
│ $ cat .catalyst/main/project-config.yaml │
|
|
175
|
+
│ │
|
|
176
|
+
│ Extract: │
|
|
177
|
+
│ - development_branch (default: "main") │
|
|
178
|
+
│ - branch_prefix (default: "feat") │
|
|
179
|
+
│ │
|
|
180
|
+
│ 2. Checkout to development branch: │
|
|
181
|
+
│ $ git checkout {development_branch} │
|
|
182
|
+
│ $ git pull origin {development_branch} │
|
|
183
|
+
│ │
|
|
184
|
+
│ 3. Create spec feature branch: │
|
|
185
|
+
│ $ git checkout -b {branch_prefix}/{spec-slug} │
|
|
186
|
+
│ │
|
|
187
|
+
│ Example: git checkout -b feat/2026-01-11-stripe-integration │
|
|
188
|
+
│ │
|
|
189
|
+
│ 4. Confirm branch creation to user: │
|
|
190
|
+
│ "Created branch: feat/{spec-slug} from {development_branch}"│
|
|
191
|
+
│ │
|
|
192
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**WAIT for git setup to complete before proceeding to Phase 1.**
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
110
199
|
### Phase 1: Task Breakdown (Forger)
|
|
111
200
|
|
|
112
|
-
**Spawn Forger agent
|
|
201
|
+
**Spawn Forger agent** using `Task` tool with `subagent_type="forger"`:
|
|
113
202
|
|
|
114
203
|
```
|
|
115
204
|
"Break down spec.md into implementable tasks with Build DAG. Write to:
|
|
@@ -118,6 +207,8 @@ The **Forge-Master** agent orchestrates the Technologists.
|
|
|
118
207
|
Include: phases, scope boundaries, dependencies, parallel opportunities."
|
|
119
208
|
```
|
|
120
209
|
|
|
210
|
+
**WAIT for Forger to complete and return before proceeding to Phase 2.**
|
|
211
|
+
|
|
121
212
|
Forger creates `tasks.md` with **Build DAG**:
|
|
122
213
|
|
|
123
214
|
```markdown
|
|
@@ -163,7 +254,7 @@ Forger creates `tasks.md` with **Build DAG**:
|
|
|
163
254
|
|
|
164
255
|
**CRITICAL: This phase MUST complete before ANY implementation starts.**
|
|
165
256
|
|
|
166
|
-
**Spawn Enforcer agent
|
|
257
|
+
**Spawn Enforcer agent** using `Task` tool with `subagent_type="enforcer"`:
|
|
167
258
|
|
|
168
259
|
```
|
|
169
260
|
"Write failing tests for ALL tasks in tasks.md.
|
|
@@ -171,6 +262,8 @@ Tests go in project test folders (src/__tests__/, tests/, etc.).
|
|
|
171
262
|
Update tasks.md Progress section with test file locations."
|
|
172
263
|
```
|
|
173
264
|
|
|
265
|
+
**WAIT for Enforcer to complete and return before proceeding to Gate 1.**
|
|
266
|
+
|
|
174
267
|
Enforcer will:
|
|
175
268
|
1. For EVERY task, write failing tests in project test folders
|
|
176
269
|
2. Update `tasks.md` Progress section with test locations
|
|
@@ -178,7 +271,7 @@ Enforcer will:
|
|
|
178
271
|
|
|
179
272
|
---
|
|
180
273
|
|
|
181
|
-
### GATE 1: Red Phase Verification
|
|
274
|
+
### GATE 1: Red Phase Verification (RED FLAG)
|
|
182
275
|
|
|
183
276
|
**STOP! Before proceeding to implementation:**
|
|
184
277
|
|
|
@@ -198,13 +291,35 @@ npm test # or appropriate test command
|
|
|
198
291
|
|
|
199
292
|
**If ANY test passes -> STOP and investigate**
|
|
200
293
|
|
|
294
|
+
```
|
|
295
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
296
|
+
│ 🚩 RED FLAG COMMIT │
|
|
297
|
+
│ ───────────────── │
|
|
298
|
+
│ │
|
|
299
|
+
│ After Gate 1 passes, commit the test suite: │
|
|
300
|
+
│ │
|
|
301
|
+
│ $ git add . │
|
|
302
|
+
│ $ git commit -m "test({scope}): write failing tests for {spec}"│
|
|
303
|
+
│ │
|
|
304
|
+
│ Example: │
|
|
305
|
+
│ git commit -m "test(auth): write failing tests for supabase-auth"
|
|
306
|
+
│ │
|
|
307
|
+
│ This checkpoint captures: │
|
|
308
|
+
│ - All test files │
|
|
309
|
+
│ - tasks.md with test locations │
|
|
310
|
+
│ - Any test fixtures or mocks │
|
|
311
|
+
│ │
|
|
312
|
+
│ ✅ Checkpoint saved. Proceeding to implementation. │
|
|
313
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
314
|
+
```
|
|
315
|
+
|
|
201
316
|
---
|
|
202
317
|
|
|
203
318
|
### Phase 3-4: Foundation & Contracts (Sequential)
|
|
204
319
|
|
|
205
320
|
**Only start this phase AFTER Gate 1 (Red Phase) passes!**
|
|
206
321
|
|
|
207
|
-
**Spawn Alchemist**
|
|
322
|
+
**Spawn Alchemist** using `Task` tool with `subagent_type="alchemist"`:
|
|
208
323
|
|
|
209
324
|
```
|
|
210
325
|
"Implement db-schema task.
|
|
@@ -212,7 +327,9 @@ SCOPE (write): prisma/*, src/db/*
|
|
|
212
327
|
Run tests after to verify progress."
|
|
213
328
|
```
|
|
214
329
|
|
|
215
|
-
**
|
|
330
|
+
**WAIT for Alchemist to complete before spawning Smith.**
|
|
331
|
+
|
|
332
|
+
**Spawn Smith** using `Task` tool with `subagent_type="smith"`:
|
|
216
333
|
|
|
217
334
|
```
|
|
218
335
|
"Implement api-types task.
|
|
@@ -220,38 +337,42 @@ SCOPE (write): src/types/api.ts
|
|
|
220
337
|
Defines shared types for all parallel agents."
|
|
221
338
|
```
|
|
222
339
|
|
|
340
|
+
**WAIT for Smith to complete before proceeding to Phase 5.**
|
|
341
|
+
|
|
223
342
|
---
|
|
224
343
|
|
|
225
344
|
### Phase 5: Parallel Implementation (DAG-Driven)
|
|
226
345
|
|
|
227
346
|
**Only start AFTER contracts phase completes!**
|
|
228
347
|
|
|
229
|
-
**Spawn ALL ready agents in ONE message
|
|
348
|
+
**Spawn ALL ready agents in ONE message** using multiple `Task` tool calls:
|
|
230
349
|
|
|
231
350
|
```
|
|
232
|
-
|
|
351
|
+
Task(subagent_type="smith", prompt="Implement api-auth task.
|
|
233
352
|
SCOPE (write): src/api/auth/**, tests/api/auth/**
|
|
234
353
|
READS (no modify): src/types/**
|
|
235
|
-
Run tests after each change."
|
|
354
|
+
Run tests after each change.")
|
|
236
355
|
|
|
237
|
-
|
|
356
|
+
Task(subagent_type="smith", prompt="Implement api-billing task.
|
|
238
357
|
SCOPE (write): src/api/billing/**, tests/api/billing/**
|
|
239
358
|
READS (no modify): src/types/**
|
|
240
|
-
Run tests after each change."
|
|
359
|
+
Run tests after each change.")
|
|
241
360
|
|
|
242
|
-
|
|
361
|
+
Task(subagent_type="shaper", prompt="Implement ui-pricing task.
|
|
243
362
|
SCOPE (write): src/pages/pricing/**, src/components/pricing/**
|
|
244
363
|
READS (no modify): src/types/**, src/components/shared/**
|
|
245
|
-
Run tests after each change."
|
|
364
|
+
Run tests after each change.")
|
|
246
365
|
|
|
247
|
-
|
|
366
|
+
Task(subagent_type="shaper", prompt="Implement ui-dashboard task.
|
|
248
367
|
SCOPE (write): src/pages/dashboard/**, src/components/dashboard/**
|
|
249
368
|
READS (no modify): src/types/**, src/components/shared/**
|
|
250
|
-
Run tests after each change."
|
|
369
|
+
Run tests after each change.")
|
|
251
370
|
```
|
|
252
371
|
|
|
253
372
|
**CRITICAL**: Include scope in every agent prompt. Agents must NOT modify files outside their scope.
|
|
254
373
|
|
|
374
|
+
**WAIT for ALL parallel agents to complete before proceeding to Phase 6.**
|
|
375
|
+
|
|
255
376
|
Each builder updates `tasks.md` Progress section as they complete tasks.
|
|
256
377
|
|
|
257
378
|
---
|
|
@@ -260,7 +381,7 @@ Each builder updates `tasks.md` Progress section as they complete tasks.
|
|
|
260
381
|
|
|
261
382
|
**Only start AFTER all parallel tasks complete!**
|
|
262
383
|
|
|
263
|
-
**Spawn Enforcer
|
|
384
|
+
**Spawn Enforcer** using `Task` tool with `subagent_type="enforcer"`:
|
|
264
385
|
|
|
265
386
|
```
|
|
266
387
|
"Run integration tests for cross-boundary functionality.
|
|
@@ -289,7 +410,7 @@ NEVER modify files outside your SCOPE
|
|
|
289
410
|
|
|
290
411
|
---
|
|
291
412
|
|
|
292
|
-
### GATE 2: Green Phase Verification
|
|
413
|
+
### GATE 2: Green Phase Verification (GREEN FLAG)
|
|
293
414
|
|
|
294
415
|
**Before completing build:**
|
|
295
416
|
|
|
@@ -302,6 +423,28 @@ npm test
|
|
|
302
423
|
# Status: GREEN
|
|
303
424
|
```
|
|
304
425
|
|
|
426
|
+
```
|
|
427
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
428
|
+
│ 🟢 GREEN FLAG COMMIT │
|
|
429
|
+
│ ─────────────────── │
|
|
430
|
+
│ │
|
|
431
|
+
│ After Gate 2 passes, commit the implementation: │
|
|
432
|
+
│ │
|
|
433
|
+
│ $ git add . │
|
|
434
|
+
│ $ git commit -m "feat({scope}): implement {spec}" │
|
|
435
|
+
│ │
|
|
436
|
+
│ Example: │
|
|
437
|
+
│ git commit -m "feat(auth): implement supabase-auth" │
|
|
438
|
+
│ │
|
|
439
|
+
│ This checkpoint captures: │
|
|
440
|
+
│ - All implementation files │
|
|
441
|
+
│ - Updated tasks.md with progress │
|
|
442
|
+
│ - Any configuration changes │
|
|
443
|
+
│ │
|
|
444
|
+
│ ✅ Implementation committed. Ready for validation. │
|
|
445
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
446
|
+
```
|
|
447
|
+
|
|
305
448
|
---
|
|
306
449
|
|
|
307
450
|
## Output
|
|
@@ -310,6 +453,13 @@ npm test
|
|
|
310
453
|
Build complete!
|
|
311
454
|
|
|
312
455
|
Spec: 2025-11-29-stripe-integration
|
|
456
|
+
Branch: feat/2025-11-29-stripe-integration
|
|
457
|
+
|
|
458
|
+
Git Commits:
|
|
459
|
+
┌────────────────────────────────────────────────────────────────┐
|
|
460
|
+
│ 🚩 abc1234 test(payment): write failing tests for stripe-integration
|
|
461
|
+
│ 🟢 def5678 feat(payment): implement stripe-integration
|
|
462
|
+
└────────────────────────────────────────────────────────────────┘
|
|
313
463
|
|
|
314
464
|
TDD Compliance: VERIFIED
|
|
315
465
|
- Red Phase: 45 tests written, all failed
|
|
@@ -328,6 +478,7 @@ Scope Violations: 0
|
|
|
328
478
|
Updated: .catalyst/specs/2025-11-29-stripe-integration/tasks.md
|
|
329
479
|
|
|
330
480
|
Next: Run /validate-spec @2025-11-29-stripe-integration
|
|
481
|
+
Then /approve-spec for final review and merge
|
|
331
482
|
```
|
|
332
483
|
|
|
333
484
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# /catalyze-project
|
|
2
2
|
|
|
3
|
-
Initialize the project foundation.
|
|
3
|
+
Initialize the project foundation. Creates project config and all 6 foundation documents.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -12,9 +12,9 @@ Initialize the project foundation. Always creates all 6 documents.
|
|
|
12
12
|
|
|
13
13
|
## Process
|
|
14
14
|
|
|
15
|
-
### Phase 1: Detection
|
|
15
|
+
### Phase 1: Detection (Silent)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**Do not announce this phase to the user.** Silently scan the project to determine if greenfield or brownfield:
|
|
18
18
|
|
|
19
19
|
| Signal | Greenfield | Brownfield |
|
|
20
20
|
|--------|------------|------------|
|
|
@@ -23,6 +23,8 @@ Scan the project to determine if greenfield or brownfield:
|
|
|
23
23
|
| Git history | < 10 commits | > 10 commits |
|
|
24
24
|
| Lines of code | < 500 | > 500 |
|
|
25
25
|
|
|
26
|
+
Run these checks in the background and proceed directly to Phase 2 based on the result.
|
|
27
|
+
|
|
26
28
|
### Phase 2: Gather Information
|
|
27
29
|
|
|
28
30
|
**If Greenfield** - Heavy questioning via Oracle:
|
|
@@ -37,21 +39,67 @@ Scan the project to determine if greenfield or brownfield:
|
|
|
37
39
|
8. What's the timeline pressure?
|
|
38
40
|
9. Are there similar products to reference?
|
|
39
41
|
|
|
40
|
-
**If Brownfield** - Heavy scanning via 3 parallel
|
|
42
|
+
**If Brownfield** - Heavy scanning via 3 parallel Seer agents (subagent_type="seer"):
|
|
41
43
|
|
|
42
44
|
```
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
Seer 1: Architecture + Tech Stack
|
|
46
|
+
Seer 2: Conventions + Patterns
|
|
47
|
+
Seer 3: Concerns + TODOs
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
Then ask only what can't be inferred:
|
|
49
51
|
1. What's the project's mission? (if no README)
|
|
50
52
|
2. What are the current priorities?
|
|
51
53
|
|
|
52
|
-
### Phase 3:
|
|
54
|
+
### Phase 3: Git Branch Setup
|
|
55
|
+
|
|
56
|
+
**Ask the user about their development branch preference:**
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
60
|
+
│ 🙋 ASK USER: Development Branch │
|
|
61
|
+
│ ─────────────────────────────── │
|
|
62
|
+
│ │
|
|
63
|
+
│ "What should we name the development branch for spec work?" │
|
|
64
|
+
│ │
|
|
65
|
+
│ Options: │
|
|
66
|
+
│ ○ development (Recommended) │
|
|
67
|
+
│ ○ develop │
|
|
68
|
+
│ ○ staging │
|
|
69
|
+
│ ○ Other (custom name) │
|
|
70
|
+
│ │
|
|
71
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**After user responds:**
|
|
75
|
+
|
|
76
|
+
1. Check if branch exists:
|
|
77
|
+
```bash
|
|
78
|
+
git branch --list {branch_name}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
2. If branch doesn't exist, create it from main:
|
|
82
|
+
```bash
|
|
83
|
+
git checkout -b {branch_name}
|
|
84
|
+
git push -u origin {branch_name} # Optional: ask user if they want to push
|
|
85
|
+
git checkout main # Return to main for now
|
|
86
|
+
```
|
|
53
87
|
|
|
54
|
-
|
|
88
|
+
3. Store preference in `project-config.yaml`:
|
|
89
|
+
```yaml
|
|
90
|
+
git:
|
|
91
|
+
development_branch: "{user_choice}"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### Phase 4: Generate Config and Documents
|
|
97
|
+
|
|
98
|
+
Always create in `.catalyst/main/`:
|
|
99
|
+
|
|
100
|
+
| File | Source |
|
|
101
|
+
|------|--------|
|
|
102
|
+
| `project-config.yaml` | User preferences from Phase 3 |
|
|
55
103
|
|
|
56
104
|
| Document | Greenfield Source | Brownfield Source |
|
|
57
105
|
|----------|-------------------|-------------------|
|
|
@@ -66,6 +114,9 @@ Always create all documents in `.catalyst/main/`:
|
|
|
66
114
|
|
|
67
115
|
## Templates
|
|
68
116
|
|
|
117
|
+
Located at `.catalyst/main/`:
|
|
118
|
+
- `project-config.yaml` (git and project settings template)
|
|
119
|
+
|
|
69
120
|
Located at `.catalyst/main/temp/`:
|
|
70
121
|
- `temp-mission.md`
|
|
71
122
|
- `temp-roadmap.md`
|
|
@@ -80,6 +131,7 @@ Located at `.catalyst/main/temp/`:
|
|
|
80
131
|
|
|
81
132
|
```
|
|
82
133
|
.catalyst/main/
|
|
134
|
+
├── project-config.yaml
|
|
83
135
|
├── mission.md
|
|
84
136
|
├── roadmap.md
|
|
85
137
|
├── tech-stack.md
|
|
@@ -91,7 +143,12 @@ Located at `.catalyst/main/temp/`:
|
|
|
91
143
|
```
|
|
92
144
|
✅ Project initialized!
|
|
93
145
|
|
|
94
|
-
|
|
146
|
+
Git Setup:
|
|
147
|
+
- Development branch: {branch_name} (created/verified)
|
|
148
|
+
- Feature branches will be: feat/{spec-slug}
|
|
149
|
+
|
|
150
|
+
Created 7 files in .catalyst/main/
|
|
151
|
+
- project-config.yaml: Git workflow settings
|
|
95
152
|
- Architecture: [summary]
|
|
96
153
|
- Conventions: [count] patterns
|
|
97
154
|
- Concerns: [count] issues
|
|
@@ -251,13 +251,7 @@ Action: Run /build-spec @2025-11-29-stripe-integration
|
|
|
251
251
|
```
|
|
252
252
|
Validation failed!
|
|
253
253
|
|
|
254
|
-
Spec: 2025-11-29-stripe-
|
|
255
|
-
|
|
256
|
-
Failed Checks:
|
|
254
|
+
Spec: 2025-11-29-stripe-integrationFailed Checks:
|
|
257
255
|
- E2E Tests: 2 failures
|
|
258
|
-
- Security: 1 vulnerability
|
|
259
|
-
|
|
260
|
-
Created: .catalyst/specs/{slug}/validation.md (with details)
|
|
261
|
-
|
|
262
|
-
Action: Fix issues and re-run /validate-spec
|
|
263
|
-
```
|
|
256
|
+
- Security: 1 vulnerability foundCreated: .catalyst/specs/{slug}/validation.md (with details)Action: Fix issues and re-run /validate-spec
|
|
257
|
+
```
|
package/AGENTS.md
CHANGED
|
@@ -157,25 +157,29 @@ Scribe is the gatekeeper. This ensures:
|
|
|
157
157
|
- Consistent formatting
|
|
158
158
|
- No orphan documents
|
|
159
159
|
|
|
160
|
-
###
|
|
160
|
+
### STRICT ALLOWLIST
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
Spec folders may **ONLY** contain:
|
|
163
|
+
|
|
164
|
+
| File | Owner | Purpose |
|
|
165
|
+
|------|-------|---------|
|
|
166
|
+
| `spec.md` | Scribe | Requirements + frontmatter |
|
|
167
|
+
| `research.md` | Scribe | Compiled research findings |
|
|
168
|
+
| `tasks.md` | Forger | Build DAG + progress |
|
|
169
|
+
| `validation.md` | Arbiter | Test results |
|
|
170
|
+
| `handoff.md` | Arbiter | Human-readable summary |
|
|
171
|
+
| `assets/` | Any | Images, diagrams |
|
|
172
|
+
| `references/` | Any | (Optional) Screenshots, evidence |
|
|
173
|
+
|
|
174
|
+
**ANY OTHER FILE IS FORBIDDEN.** No README.md, no notes.md, no implementation/.
|
|
171
175
|
|
|
172
176
|
### Rules
|
|
173
177
|
|
|
174
178
|
1. **Scribe is gatekeeper** — All .md writes in specs go through Scribe
|
|
175
|
-
2. **
|
|
176
|
-
3. **
|
|
177
|
-
4. **
|
|
178
|
-
5. **
|
|
179
|
+
2. **DENY by default** — If not in allowlist, don't create it
|
|
180
|
+
3. **Researchers hand off** — Scout/Seer/Oracle give findings to Scribe, don't write directly
|
|
181
|
+
4. **tasks.md is THE living document** — ONE file to read when resuming work
|
|
182
|
+
5. **handoff.md is colleague summary** — Human-readable walkthrough, finalized at end
|
|
179
183
|
|
|
180
184
|
---
|
|
181
185
|
|
package/package.json
CHANGED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# Coding Standards
|
|
2
|
-
|
|
3
|
-
Project-wide coding conventions and style guidelines.
|
|
4
|
-
|
|
5
|
-
## General Principles
|
|
6
|
-
|
|
7
|
-
### Code Style
|
|
8
|
-
- **Clarity over cleverness** - Write code that's easy to understand
|
|
9
|
-
- **Consistency** - Follow existing patterns in the codebase
|
|
10
|
-
- **Self-documenting** - Good names reduce need for comments
|
|
11
|
-
- **Small functions** - Single responsibility, easy to test
|
|
12
|
-
|
|
13
|
-
### Naming Conventions
|
|
14
|
-
|
|
15
|
-
| Type | Convention | Example |
|
|
16
|
-
|------|------------|---------|
|
|
17
|
-
| Variables | camelCase | `userName`, `isActive` |
|
|
18
|
-
| Constants | UPPER_SNAKE | `MAX_RETRIES`, `API_URL` |
|
|
19
|
-
| Functions | camelCase | `getUserById`, `validateInput` |
|
|
20
|
-
| Classes | PascalCase | `UserService`, `PaymentHandler` |
|
|
21
|
-
| Files | kebab-case | `user-service.ts`, `payment-handler.py` |
|
|
22
|
-
| Components | PascalCase | `UserProfile.tsx`, `Button.tsx` |
|
|
23
|
-
|
|
24
|
-
### File Organization
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
src/
|
|
28
|
-
├── components/ # UI components
|
|
29
|
-
├── hooks/ # Custom React hooks
|
|
30
|
-
├── services/ # Business logic
|
|
31
|
-
├── utils/ # Utility functions
|
|
32
|
-
├── types/ # Type definitions
|
|
33
|
-
└── api/ # API routes/handlers
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## TypeScript/JavaScript
|
|
37
|
-
|
|
38
|
-
### Prefer
|
|
39
|
-
```typescript
|
|
40
|
-
// Type interfaces for objects
|
|
41
|
-
interface User {
|
|
42
|
-
id: string
|
|
43
|
-
name: string
|
|
44
|
-
email: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Const over let
|
|
48
|
-
const user = getUser()
|
|
49
|
-
|
|
50
|
-
// Async/await over promises
|
|
51
|
-
const data = await fetchData()
|
|
52
|
-
|
|
53
|
-
// Optional chaining
|
|
54
|
-
const name = user?.profile?.name
|
|
55
|
-
|
|
56
|
-
// Nullish coalescing
|
|
57
|
-
const value = input ?? defaultValue
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Avoid
|
|
61
|
-
```typescript
|
|
62
|
-
// var keyword
|
|
63
|
-
var user = getUser() // ❌
|
|
64
|
-
|
|
65
|
-
// any type
|
|
66
|
-
const data: any = {} // ❌
|
|
67
|
-
|
|
68
|
-
// Nested callbacks
|
|
69
|
-
getData(result => {
|
|
70
|
-
process(result, processed => { // ❌
|
|
71
|
-
save(processed)
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Python
|
|
77
|
-
|
|
78
|
-
### Style
|
|
79
|
-
- Follow PEP 8
|
|
80
|
-
- Use type hints
|
|
81
|
-
- Docstrings for public functions
|
|
82
|
-
|
|
83
|
-
```python
|
|
84
|
-
def get_user_by_id(user_id: str) -> User | None:
|
|
85
|
-
"""
|
|
86
|
-
Retrieve a user by their ID.
|
|
87
|
-
|
|
88
|
-
Args:
|
|
89
|
-
user_id: The unique identifier for the user
|
|
90
|
-
|
|
91
|
-
Returns:
|
|
92
|
-
User object if found, None otherwise
|
|
93
|
-
"""
|
|
94
|
-
return db.users.find_one({"id": user_id})
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## React Components
|
|
98
|
-
|
|
99
|
-
### Function Components
|
|
100
|
-
```tsx
|
|
101
|
-
interface ButtonProps {
|
|
102
|
-
variant: 'primary' | 'secondary'
|
|
103
|
-
children: React.ReactNode
|
|
104
|
-
onClick?: () => void
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function Button({ variant, children, onClick }: ButtonProps) {
|
|
108
|
-
return (
|
|
109
|
-
<button className={styles[variant]} onClick={onClick}>
|
|
110
|
-
{children}
|
|
111
|
-
</button>
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Hooks Rules
|
|
117
|
-
- Only call at top level
|
|
118
|
-
- Only call from React functions
|
|
119
|
-
- Custom hooks start with `use`
|
|
120
|
-
|
|
121
|
-
## Error Handling
|
|
122
|
-
|
|
123
|
-
### Do
|
|
124
|
-
```typescript
|
|
125
|
-
try {
|
|
126
|
-
const result = await riskyOperation()
|
|
127
|
-
return result
|
|
128
|
-
} catch (error) {
|
|
129
|
-
logger.error('Operation failed', { error })
|
|
130
|
-
throw new AppError('OPERATION_FAILED', 'Meaningful message')
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Don't
|
|
135
|
-
```typescript
|
|
136
|
-
try {
|
|
137
|
-
const result = await riskyOperation()
|
|
138
|
-
} catch (e) {
|
|
139
|
-
console.log(e) // ❌ Silent failure
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Comments
|
|
144
|
-
|
|
145
|
-
### When to Comment
|
|
146
|
-
- Complex algorithms
|
|
147
|
-
- Non-obvious business logic
|
|
148
|
-
- Workarounds with context
|
|
149
|
-
- Public API documentation
|
|
150
|
-
|
|
151
|
-
### When NOT to Comment
|
|
152
|
-
```typescript
|
|
153
|
-
// Get the user ❌ (obvious)
|
|
154
|
-
const user = getUser()
|
|
155
|
-
|
|
156
|
-
// Increment counter ❌ (obvious)
|
|
157
|
-
counter++
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Imports
|
|
161
|
-
|
|
162
|
-
### Order
|
|
163
|
-
1. External packages
|
|
164
|
-
2. Internal modules
|
|
165
|
-
3. Relative imports
|
|
166
|
-
4. Types/interfaces
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
// External
|
|
170
|
-
import React from 'react'
|
|
171
|
-
import { useQuery } from '@tanstack/react-query'
|
|
172
|
-
|
|
173
|
-
// Internal
|
|
174
|
-
import { useAuth } from '@/hooks/useAuth'
|
|
175
|
-
import { Button } from '@/components/ui/Button'
|
|
176
|
-
|
|
177
|
-
// Relative
|
|
178
|
-
import { formatDate } from './utils'
|
|
179
|
-
|
|
180
|
-
// Types
|
|
181
|
-
import type { User } from '@/types'
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
*Update this file to match your project's specific standards.*
|
|
187
|
-
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# Git Workflow
|
|
2
|
-
|
|
3
|
-
Branch management and commit conventions.
|
|
4
|
-
|
|
5
|
-
## Branch Strategy
|
|
6
|
-
|
|
7
|
-
### Main Branches
|
|
8
|
-
- `main` - Production-ready code
|
|
9
|
-
- `develop` - Integration branch (optional)
|
|
10
|
-
|
|
11
|
-
### Feature Branches
|
|
12
|
-
```
|
|
13
|
-
feature/{spec-name}
|
|
14
|
-
feature/2025-11-29-stripe-integration
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### Other Branches
|
|
18
|
-
```
|
|
19
|
-
fix/{issue-number}-description
|
|
20
|
-
hotfix/{issue-number}-description
|
|
21
|
-
refactor/{description}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Commit Messages
|
|
25
|
-
|
|
26
|
-
### Conventional Commits
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
<type>(<scope>): <description>
|
|
30
|
-
|
|
31
|
-
[optional body]
|
|
32
|
-
|
|
33
|
-
[optional footer]
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Types
|
|
37
|
-
| Type | Use |
|
|
38
|
-
|------|-----|
|
|
39
|
-
| `feat` | New feature |
|
|
40
|
-
| `fix` | Bug fix |
|
|
41
|
-
| `docs` | Documentation |
|
|
42
|
-
| `style` | Formatting |
|
|
43
|
-
| `refactor` | Code restructure |
|
|
44
|
-
| `test` | Tests |
|
|
45
|
-
| `chore` | Maintenance |
|
|
46
|
-
|
|
47
|
-
### Examples
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
# Feature
|
|
51
|
-
feat(subscriptions): add stripe checkout integration
|
|
52
|
-
|
|
53
|
-
# Fix
|
|
54
|
-
fix(auth): resolve token refresh race condition
|
|
55
|
-
|
|
56
|
-
# With body
|
|
57
|
-
feat(pricing): implement dynamic pricing page
|
|
58
|
-
|
|
59
|
-
- Add plan comparison table
|
|
60
|
-
- Implement feature tooltips
|
|
61
|
-
- Add annual/monthly toggle
|
|
62
|
-
|
|
63
|
-
Spec: 2025-11-29-pricing
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Workflow
|
|
67
|
-
|
|
68
|
-
### Starting Work
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# Update main
|
|
72
|
-
git checkout main
|
|
73
|
-
git pull
|
|
74
|
-
|
|
75
|
-
# Create feature branch
|
|
76
|
-
git checkout -b feature/2025-11-29-stripe-integration
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### During Development
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Commit often
|
|
83
|
-
git add .
|
|
84
|
-
git commit -m "feat(stripe): add subscription service"
|
|
85
|
-
|
|
86
|
-
# Keep updated with main
|
|
87
|
-
git fetch origin
|
|
88
|
-
git rebase origin/main
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Completing Work
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
# Ensure tests pass
|
|
95
|
-
npm test
|
|
96
|
-
|
|
97
|
-
# Push branch
|
|
98
|
-
git push origin feature/2025-11-29-stripe-integration
|
|
99
|
-
|
|
100
|
-
# Create PR or merge
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Code Review
|
|
104
|
-
|
|
105
|
-
### PR Requirements
|
|
106
|
-
- [ ] Tests pass
|
|
107
|
-
- [ ] Linting clean
|
|
108
|
-
- [ ] Spec reference in description
|
|
109
|
-
- [ ] Changes documented
|
|
110
|
-
|
|
111
|
-
### PR Template
|
|
112
|
-
|
|
113
|
-
```markdown
|
|
114
|
-
## Description
|
|
115
|
-
Brief description of changes
|
|
116
|
-
|
|
117
|
-
## Spec Reference
|
|
118
|
-
.catalyst/specs/2025-11-29-stripe-integration
|
|
119
|
-
|
|
120
|
-
## Changes
|
|
121
|
-
- Added subscription service
|
|
122
|
-
- Created checkout flow
|
|
123
|
-
- Added webhook handlers
|
|
124
|
-
|
|
125
|
-
## Testing
|
|
126
|
-
- [ ] Unit tests added
|
|
127
|
-
- [ ] E2E tests added
|
|
128
|
-
- [ ] Manual testing done
|
|
129
|
-
|
|
130
|
-
## Screenshots
|
|
131
|
-
(if UI changes)
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Merge Strategy
|
|
135
|
-
|
|
136
|
-
### Squash Merge (Recommended)
|
|
137
|
-
- Clean history
|
|
138
|
-
- One commit per feature
|
|
139
|
-
- Easy revert
|
|
140
|
-
|
|
141
|
-
### Merge Commit
|
|
142
|
-
- Preserve full history
|
|
143
|
-
- See individual commits
|
|
144
|
-
- More verbose
|
|
145
|
-
|
|
146
|
-
## Tagging Releases
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
# Semantic versioning
|
|
150
|
-
git tag -a v1.0.0 -m "Release 1.0.0"
|
|
151
|
-
git push origin v1.0.0
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Emergency Hotfix
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
# Branch from main
|
|
158
|
-
git checkout main
|
|
159
|
-
git checkout -b hotfix/critical-auth-fix
|
|
160
|
-
|
|
161
|
-
# Fix, test, commit
|
|
162
|
-
git commit -m "fix(auth): patch critical vulnerability"
|
|
163
|
-
|
|
164
|
-
# Merge directly to main
|
|
165
|
-
git checkout main
|
|
166
|
-
git merge hotfix/critical-auth-fix
|
|
167
|
-
git push
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## Don'ts
|
|
171
|
-
|
|
172
|
-
- ❌ Commit directly to main
|
|
173
|
-
- ❌ Force push to shared branches
|
|
174
|
-
- ❌ Commit secrets or credentials
|
|
175
|
-
- ❌ Large commits without description
|
|
176
|
-
- ❌ Merge without tests passing
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
*Adjust branch naming and merge strategy for your team.*
|
|
181
|
-
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# Testing Standards
|
|
2
|
-
|
|
3
|
-
Guidelines for writing and organizing tests.
|
|
4
|
-
|
|
5
|
-
## Philosophy
|
|
6
|
-
|
|
7
|
-
**TDD is mandatory** - Tests are written BEFORE implementation.
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
1. Write test → ❌ FAIL (Red)
|
|
11
|
-
2. Write minimal code → ✅ PASS (Green)
|
|
12
|
-
3. Refactor → ✅ PASS (Refactor)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Test Types
|
|
16
|
-
|
|
17
|
-
### Unit Tests
|
|
18
|
-
- Test individual functions/components in isolation
|
|
19
|
-
- Mock external dependencies
|
|
20
|
-
- Fast execution
|
|
21
|
-
- High coverage
|
|
22
|
-
|
|
23
|
-
### Integration Tests
|
|
24
|
-
- Test multiple units together
|
|
25
|
-
- Real database (test instance)
|
|
26
|
-
- API endpoint testing
|
|
27
|
-
- Moderate coverage
|
|
28
|
-
|
|
29
|
-
### E2E Tests
|
|
30
|
-
- Test complete user flows
|
|
31
|
-
- Real browser automation
|
|
32
|
-
- Critical paths only
|
|
33
|
-
- Selective coverage
|
|
34
|
-
|
|
35
|
-
## Test Structure
|
|
36
|
-
|
|
37
|
-
### Arrange-Act-Assert
|
|
38
|
-
```typescript
|
|
39
|
-
it('should calculate total with discount', () => {
|
|
40
|
-
// Arrange
|
|
41
|
-
const items = [{ price: 100 }, { price: 50 }]
|
|
42
|
-
const discount = 0.1
|
|
43
|
-
|
|
44
|
-
// Act
|
|
45
|
-
const total = calculateTotal(items, discount)
|
|
46
|
-
|
|
47
|
-
// Assert
|
|
48
|
-
expect(total).toBe(135)
|
|
49
|
-
})
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Descriptive Names
|
|
53
|
-
```typescript
|
|
54
|
-
// Good
|
|
55
|
-
describe('UserService', () => {
|
|
56
|
-
describe('createUser', () => {
|
|
57
|
-
it('should create user with valid data', () => {})
|
|
58
|
-
it('should throw on duplicate email', () => {})
|
|
59
|
-
it('should hash password before saving', () => {})
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// Bad
|
|
64
|
-
describe('tests', () => {
|
|
65
|
-
it('test 1', () => {}) // ❌
|
|
66
|
-
it('works', () => {}) // ❌
|
|
67
|
-
})
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Test Organization
|
|
71
|
-
|
|
72
|
-
### File Location
|
|
73
|
-
```
|
|
74
|
-
src/
|
|
75
|
-
├── services/
|
|
76
|
-
│ ├── user.ts
|
|
77
|
-
│ └── user.test.ts # Co-located
|
|
78
|
-
└── __tests__/ # Or centralized
|
|
79
|
-
└── services/
|
|
80
|
-
└── user.test.ts
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Naming
|
|
84
|
-
- `*.test.ts` for unit tests
|
|
85
|
-
- `*.spec.ts` for integration tests
|
|
86
|
-
- `*.e2e.ts` for end-to-end tests
|
|
87
|
-
|
|
88
|
-
## Mocking Guidelines
|
|
89
|
-
|
|
90
|
-
### When to Mock
|
|
91
|
-
- External APIs
|
|
92
|
-
- Database (for unit tests)
|
|
93
|
-
- Time-dependent functions
|
|
94
|
-
- Random values
|
|
95
|
-
|
|
96
|
-
### When NOT to Mock
|
|
97
|
-
- Internal business logic
|
|
98
|
-
- Simple utility functions
|
|
99
|
-
- Integration test boundaries
|
|
100
|
-
|
|
101
|
-
### Mock Example
|
|
102
|
-
```typescript
|
|
103
|
-
import { vi } from 'vitest'
|
|
104
|
-
|
|
105
|
-
// Mock external service
|
|
106
|
-
vi.mock('@/services/stripe', () => ({
|
|
107
|
-
createSubscription: vi.fn().mockResolvedValue({ id: 'sub_123' }),
|
|
108
|
-
}))
|
|
109
|
-
|
|
110
|
-
// Reset between tests
|
|
111
|
-
beforeEach(() => {
|
|
112
|
-
vi.clearAllMocks()
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Fixtures and Factories
|
|
117
|
-
|
|
118
|
-
### Factory Pattern
|
|
119
|
-
```typescript
|
|
120
|
-
// factories/user.ts
|
|
121
|
-
export function createUser(overrides: Partial<User> = {}): User {
|
|
122
|
-
return {
|
|
123
|
-
id: faker.string.uuid(),
|
|
124
|
-
email: faker.internet.email(),
|
|
125
|
-
name: faker.person.fullName(),
|
|
126
|
-
...overrides,
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Database Seeding
|
|
132
|
-
```typescript
|
|
133
|
-
// fixtures/seed.ts
|
|
134
|
-
export async function seedTestData(db: Database) {
|
|
135
|
-
const users = await db.users.createMany([
|
|
136
|
-
createUser({ email: 'admin@test.com' }),
|
|
137
|
-
createUser({ email: 'user@test.com' }),
|
|
138
|
-
])
|
|
139
|
-
return { users }
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Coverage Requirements
|
|
144
|
-
|
|
145
|
-
| Type | Target |
|
|
146
|
-
|------|--------|
|
|
147
|
-
| Unit Tests | 80% |
|
|
148
|
-
| Integration | Critical paths |
|
|
149
|
-
| E2E | Happy paths |
|
|
150
|
-
|
|
151
|
-
## Test Commands
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
# Run all tests
|
|
155
|
-
npm test
|
|
156
|
-
|
|
157
|
-
# Run with coverage
|
|
158
|
-
npm test -- --coverage
|
|
159
|
-
|
|
160
|
-
# Run specific file
|
|
161
|
-
npm test -- user.test.ts
|
|
162
|
-
|
|
163
|
-
# Run in watch mode
|
|
164
|
-
npm test -- --watch
|
|
165
|
-
|
|
166
|
-
# Run E2E
|
|
167
|
-
npm run test:e2e
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## CI Integration
|
|
171
|
-
|
|
172
|
-
```yaml
|
|
173
|
-
test:
|
|
174
|
-
runs-on: ubuntu-latest
|
|
175
|
-
steps:
|
|
176
|
-
- uses: actions/checkout@v4
|
|
177
|
-
- run: npm ci
|
|
178
|
-
- run: npm test -- --coverage
|
|
179
|
-
- run: npm run test:e2e
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
*Update coverage targets and commands for your project.*
|
|
185
|
-
|