catalyst-os 0.1.2 → 0.1.3
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/build-spec.md +59 -19
- package/.claude/commands/catalyze-project.md +8 -6
- package/.claude/commands/validate-spec.md +2 -4
- 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
|
@@ -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
|
```
|
|
@@ -23,17 +53,17 @@ Implement a specification using **strict TDD**.
|
|
|
23
53
|
|
|
24
54
|
The build MUST follow this exact sequence:
|
|
25
55
|
|
|
26
|
-
1.
|
|
27
|
-
2.
|
|
28
|
-
3. Verify
|
|
29
|
-
4.
|
|
56
|
+
1. Task(subagent_type="forger") -> Create tasks.md
|
|
57
|
+
2. Task(subagent_type="enforcer") -> Write ALL tests (must FAIL)
|
|
58
|
+
3. Verify -> Run tests, confirm RED
|
|
59
|
+
4. Task(subagent_type="smith/shaper/alchemist") -> Implement until GREEN
|
|
30
60
|
```
|
|
31
61
|
|
|
32
62
|
---
|
|
33
63
|
|
|
34
64
|
## ORCHESTRATION MODE
|
|
35
65
|
|
|
36
|
-
|
|
66
|
+
Forge-Master spawns specialized agents using the **Task tool**. Each phase is a separate agent.
|
|
37
67
|
|
|
38
68
|
### Output Location
|
|
39
69
|
|
|
@@ -109,7 +139,7 @@ The **Forge-Master** agent orchestrates the Technologists.
|
|
|
109
139
|
|
|
110
140
|
### Phase 1: Task Breakdown (Forger)
|
|
111
141
|
|
|
112
|
-
**Spawn Forger agent
|
|
142
|
+
**Spawn Forger agent** using `Task` tool with `subagent_type="forger"`:
|
|
113
143
|
|
|
114
144
|
```
|
|
115
145
|
"Break down spec.md into implementable tasks with Build DAG. Write to:
|
|
@@ -118,6 +148,8 @@ The **Forge-Master** agent orchestrates the Technologists.
|
|
|
118
148
|
Include: phases, scope boundaries, dependencies, parallel opportunities."
|
|
119
149
|
```
|
|
120
150
|
|
|
151
|
+
**WAIT for Forger to complete and return before proceeding to Phase 2.**
|
|
152
|
+
|
|
121
153
|
Forger creates `tasks.md` with **Build DAG**:
|
|
122
154
|
|
|
123
155
|
```markdown
|
|
@@ -163,7 +195,7 @@ Forger creates `tasks.md` with **Build DAG**:
|
|
|
163
195
|
|
|
164
196
|
**CRITICAL: This phase MUST complete before ANY implementation starts.**
|
|
165
197
|
|
|
166
|
-
**Spawn Enforcer agent
|
|
198
|
+
**Spawn Enforcer agent** using `Task` tool with `subagent_type="enforcer"`:
|
|
167
199
|
|
|
168
200
|
```
|
|
169
201
|
"Write failing tests for ALL tasks in tasks.md.
|
|
@@ -171,6 +203,8 @@ Tests go in project test folders (src/__tests__/, tests/, etc.).
|
|
|
171
203
|
Update tasks.md Progress section with test file locations."
|
|
172
204
|
```
|
|
173
205
|
|
|
206
|
+
**WAIT for Enforcer to complete and return before proceeding to Gate 1.**
|
|
207
|
+
|
|
174
208
|
Enforcer will:
|
|
175
209
|
1. For EVERY task, write failing tests in project test folders
|
|
176
210
|
2. Update `tasks.md` Progress section with test locations
|
|
@@ -204,7 +238,7 @@ npm test # or appropriate test command
|
|
|
204
238
|
|
|
205
239
|
**Only start this phase AFTER Gate 1 (Red Phase) passes!**
|
|
206
240
|
|
|
207
|
-
**Spawn Alchemist**
|
|
241
|
+
**Spawn Alchemist** using `Task` tool with `subagent_type="alchemist"`:
|
|
208
242
|
|
|
209
243
|
```
|
|
210
244
|
"Implement db-schema task.
|
|
@@ -212,7 +246,9 @@ SCOPE (write): prisma/*, src/db/*
|
|
|
212
246
|
Run tests after to verify progress."
|
|
213
247
|
```
|
|
214
248
|
|
|
215
|
-
**
|
|
249
|
+
**WAIT for Alchemist to complete before spawning Smith.**
|
|
250
|
+
|
|
251
|
+
**Spawn Smith** using `Task` tool with `subagent_type="smith"`:
|
|
216
252
|
|
|
217
253
|
```
|
|
218
254
|
"Implement api-types task.
|
|
@@ -220,38 +256,42 @@ SCOPE (write): src/types/api.ts
|
|
|
220
256
|
Defines shared types for all parallel agents."
|
|
221
257
|
```
|
|
222
258
|
|
|
259
|
+
**WAIT for Smith to complete before proceeding to Phase 5.**
|
|
260
|
+
|
|
223
261
|
---
|
|
224
262
|
|
|
225
263
|
### Phase 5: Parallel Implementation (DAG-Driven)
|
|
226
264
|
|
|
227
265
|
**Only start AFTER contracts phase completes!**
|
|
228
266
|
|
|
229
|
-
**Spawn ALL ready agents in ONE message
|
|
267
|
+
**Spawn ALL ready agents in ONE message** using multiple `Task` tool calls:
|
|
230
268
|
|
|
231
269
|
```
|
|
232
|
-
|
|
270
|
+
Task(subagent_type="smith", prompt="Implement api-auth task.
|
|
233
271
|
SCOPE (write): src/api/auth/**, tests/api/auth/**
|
|
234
272
|
READS (no modify): src/types/**
|
|
235
|
-
Run tests after each change."
|
|
273
|
+
Run tests after each change.")
|
|
236
274
|
|
|
237
|
-
|
|
275
|
+
Task(subagent_type="smith", prompt="Implement api-billing task.
|
|
238
276
|
SCOPE (write): src/api/billing/**, tests/api/billing/**
|
|
239
277
|
READS (no modify): src/types/**
|
|
240
|
-
Run tests after each change."
|
|
278
|
+
Run tests after each change.")
|
|
241
279
|
|
|
242
|
-
|
|
280
|
+
Task(subagent_type="shaper", prompt="Implement ui-pricing task.
|
|
243
281
|
SCOPE (write): src/pages/pricing/**, src/components/pricing/**
|
|
244
282
|
READS (no modify): src/types/**, src/components/shared/**
|
|
245
|
-
Run tests after each change."
|
|
283
|
+
Run tests after each change.")
|
|
246
284
|
|
|
247
|
-
|
|
285
|
+
Task(subagent_type="shaper", prompt="Implement ui-dashboard task.
|
|
248
286
|
SCOPE (write): src/pages/dashboard/**, src/components/dashboard/**
|
|
249
287
|
READS (no modify): src/types/**, src/components/shared/**
|
|
250
|
-
Run tests after each change."
|
|
288
|
+
Run tests after each change.")
|
|
251
289
|
```
|
|
252
290
|
|
|
253
291
|
**CRITICAL**: Include scope in every agent prompt. Agents must NOT modify files outside their scope.
|
|
254
292
|
|
|
293
|
+
**WAIT for ALL parallel agents to complete before proceeding to Phase 6.**
|
|
294
|
+
|
|
255
295
|
Each builder updates `tasks.md` Progress section as they complete tasks.
|
|
256
296
|
|
|
257
297
|
---
|
|
@@ -260,7 +300,7 @@ Each builder updates `tasks.md` Progress section as they complete tasks.
|
|
|
260
300
|
|
|
261
301
|
**Only start AFTER all parallel tasks complete!**
|
|
262
302
|
|
|
263
|
-
**Spawn Enforcer
|
|
303
|
+
**Spawn Enforcer** using `Task` tool with `subagent_type="enforcer"`:
|
|
264
304
|
|
|
265
305
|
```
|
|
266
306
|
"Run integration tests for cross-boundary functionality.
|
|
@@ -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,12 +39,12 @@ 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:
|
|
@@ -251,13 +251,11 @@ 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
256
|
- Security: 1 vulnerability found
|
|
259
257
|
|
|
260
258
|
Created: .catalyst/specs/{slug}/validation.md (with details)
|
|
261
259
|
|
|
262
260
|
Action: Fix issues and re-run /validate-spec
|
|
263
|
-
```
|
|
261
|
+
```
|
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
|
-
|