spec-lite 1.1.1 → 1.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/README.md +72 -21
- package/bin/cli.js +5 -1
- package/package.json +1 -1
- package/skills/build/SKILL.md +38 -0
- package/skills/code-review-and-quality/SKILL.md +347 -0
- package/skills/performance-optimization/SKILL.md +350 -0
- package/skills/review/SKILL.md +30 -0
- package/skills/security-and-hardening/SKILL.md +349 -0
- package/skills/spec-brownfield-init/SKILL.md +12 -0
- package/skills/spec-sad/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -12,30 +12,19 @@ npx spec-lite install
|
|
|
12
12
|
|
|
13
13
|
Lệnh này copy `skills/` và `templates/` vào thư mục `.claude/` của project.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
---
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Greenfield — dự án mới chưa có code
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Chạy một lần để bootstrap main artifacts, sau đó vào Integration Pipeline.
|
|
20
20
|
|
|
21
21
|
```
|
|
22
22
|
/spec-prd → /spec-sad
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/spec-new
|
|
27
|
-
│
|
|
28
|
-
/spec-tech
|
|
29
|
-
│
|
|
30
|
-
/plan
|
|
31
|
-
│
|
|
32
|
-
/build
|
|
23
|
+
│
|
|
24
|
+
▼
|
|
25
|
+
Integration Pipeline
|
|
33
26
|
```
|
|
34
27
|
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
### Seed skills — chạy một lần khi bắt đầu dự án
|
|
38
|
-
|
|
39
28
|
#### `/spec-prd`
|
|
40
29
|
Tạo hoặc cập nhật `specs/main/prd.md` thông qua interview có cấu trúc. Đồng thời scaffold `specs/main/domain.md` skeleton.
|
|
41
30
|
|
|
@@ -48,7 +37,59 @@ Sections: Architectural Style · System Overview · Tech Stack · Cross-Cutting
|
|
|
48
37
|
|
|
49
38
|
---
|
|
50
39
|
|
|
51
|
-
|
|
40
|
+
## Brownfield — project đã có code
|
|
41
|
+
|
|
42
|
+
Scan codebase để extract main artifacts, sau đó vào Integration Pipeline. Thứ tự bắt buộc: `init` → `component` → `feature`.
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
/spec-brownfield-init
|
|
46
|
+
│
|
|
47
|
+
▼
|
|
48
|
+
/spec-brownfield-component
|
|
49
|
+
│
|
|
50
|
+
▼
|
|
51
|
+
/spec-brownfield-feature
|
|
52
|
+
│
|
|
53
|
+
▼
|
|
54
|
+
(fill in NEEDS_CLARIFY khi có thêm context)
|
|
55
|
+
│
|
|
56
|
+
▼
|
|
57
|
+
Integration Pipeline
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### `/spec-brownfield-init [path]`
|
|
61
|
+
Scan codebase, tạo `prd.md` (không có Component/Feature Index), `domain.md` (Glossary only), `sad.md`. Interview 5 phần: Problem Statement · Target Users · Scope · NFRs · Business Constraints. Component Index và Feature Index để placeholder — sẽ được điền bởi hai skill tiếp theo.
|
|
62
|
+
|
|
63
|
+
#### `/spec-brownfield-component [path]`
|
|
64
|
+
Scan module dirs, tạo `crd.md` + `cdd.md` cho từng component, điền Component Index vào `prd.md`, cascade Shared Entities vào `domain.md`. Yêu cầu `init` đã chạy.
|
|
65
|
+
|
|
66
|
+
#### `/spec-brownfield-feature [path]`
|
|
67
|
+
Scan routes/use cases/tests, tạo `frd.md` + `fdd.md` cho từng feature, điền Feature Index vào `prd.md`. Yêu cầu `component` đã chạy (fdd.md cần C-XXX IDs từ Component Index).
|
|
68
|
+
|
|
69
|
+
> **NEEDS_CLARIFY:** Các mục chưa rõ khi scan được đánh dấu `[NEEDS_CLARIFY]` — không block workflow, fill in dần khi có thêm context.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Integration Pipeline — dùng cho cả greenfield và brownfield
|
|
74
|
+
|
|
75
|
+
Mỗi requirement mới đều đi qua pipeline này.
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
/spec-new [requirement]
|
|
79
|
+
(human review + apply cascade proposals + approve)
|
|
80
|
+
│
|
|
81
|
+
/spec-tech
|
|
82
|
+
(human review + apply cascade proposals + approve)
|
|
83
|
+
│
|
|
84
|
+
/plan
|
|
85
|
+
(human approve)
|
|
86
|
+
│
|
|
87
|
+
/build ◄──────────────┐
|
|
88
|
+
│ │
|
|
89
|
+
/review │ (nếu Critical/Important → sửa và build lại)
|
|
90
|
+
│ │
|
|
91
|
+
[approve] ───────────┘ (nếu chỉ Suggestion hoặc không có finding)
|
|
92
|
+
```
|
|
52
93
|
|
|
53
94
|
#### `/spec-new [requirement]`
|
|
54
95
|
Tạo `specs/integrations/{slug}/spec.md` cho một integration mới.
|
|
@@ -68,17 +109,27 @@ Tạo `plan.md` và `todo.md` từ `spec.md` + `tech.md`.
|
|
|
68
109
|
#### `/build`
|
|
69
110
|
Implement từng task trong `plan.md`/`todo.md` theo TDD incremental.
|
|
70
111
|
|
|
112
|
+
#### `/review`
|
|
113
|
+
Review implementation sau `/build` theo năm trục: correctness, readability, architecture, security, performance. Đối chiếu trực tiếp với `spec.md` và `tech.md`.
|
|
114
|
+
|
|
115
|
+
- Critical/Important → dừng, sửa, re-review
|
|
116
|
+
- Chỉ Suggestion hoặc không có finding → approve, tiếp tục `/build` task tiếp theo
|
|
117
|
+
|
|
71
118
|
---
|
|
72
119
|
|
|
73
|
-
|
|
120
|
+
## Files được tạo ra
|
|
74
121
|
|
|
75
122
|
| Command | Output |
|
|
76
123
|
|---------|--------|
|
|
77
124
|
| `/spec-prd` | `specs/main/prd.md`, `specs/main/domain.md` (skeleton) |
|
|
78
125
|
| `/spec-sad` | `specs/main/sad.md` |
|
|
126
|
+
| `/spec-brownfield-init` | `specs/main/prd.md`, `specs/main/domain.md`, `specs/main/sad.md` |
|
|
127
|
+
| `/spec-brownfield-component` | `specs/main/component/{C-XXX}-*/crd.md + cdd.md` |
|
|
128
|
+
| `/spec-brownfield-feature` | `specs/main/feature/{F-XXX}-*/frd.md + fdd.md` |
|
|
79
129
|
| `/spec-new` | `specs/integrations/{slug}/spec.md` |
|
|
80
130
|
| `/spec-tech` | `specs/integrations/{slug}/tech.md` |
|
|
81
131
|
| `/plan` | `specs/integrations/{slug}/plan.md`, `todo.md` |
|
|
82
|
-
| `/build` |
|
|
132
|
+
| `/build` | *(implements tasks từ `plan.md`/`todo.md`)* |
|
|
133
|
+
| `/review` | *(findings report — không tạo file)* |
|
|
83
134
|
|
|
84
|
-
Component
|
|
135
|
+
Component và feature artifacts trong greenfield mọc dần qua **cascade proposals** từ integrations — không có skill chuyên biệt để tạo.
|
package/bin/cli.js
CHANGED
|
@@ -20,7 +20,11 @@ if (command === 'install') {
|
|
|
20
20
|
// Copy templates → .claude/templates/
|
|
21
21
|
cpSync(join(pkgRoot, 'templates'), join(claudeDir, 'templates'), { recursive: true })
|
|
22
22
|
console.log('✓ templates → .claude/templates/')
|
|
23
|
+
|
|
24
|
+
// Copy references → .claude/references/
|
|
25
|
+
cpSync(join(pkgRoot, 'references'), join(claudeDir, 'references'), { recursive: true })
|
|
26
|
+
console.log('✓ references → .claude/references/')
|
|
23
27
|
} else {
|
|
24
|
-
console.log('Usage: npx
|
|
28
|
+
console.log('Usage: npx spec-lite install')
|
|
25
29
|
process.exit(1)
|
|
26
30
|
}
|
package/package.json
CHANGED
package/skills/build/SKILL.md
CHANGED
|
@@ -38,6 +38,44 @@ Chọn số integration:
|
|
|
38
38
|
- Nếu chỉ có 1 integration có task pending → chọn luôn, không hỏi
|
|
39
39
|
- Nếu tất cả đều done → thông báo: "Tất cả integration đã hoàn thành."
|
|
40
40
|
|
|
41
|
+
### Bước 0b: Chọn chế độ worktree (tùy chọn)
|
|
42
|
+
|
|
43
|
+
Hỏi user:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Bạn muốn build trong worktree riêng cho integration này không? (y/n)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Nếu chọn "n":** Tiếp tục build trong working directory hiện tại.
|
|
50
|
+
|
|
51
|
+
**Nếu chọn "y":**
|
|
52
|
+
|
|
53
|
+
1. **Tạo worktree mới**
|
|
54
|
+
- Tên branch: `build/{integration-slug}` (ví dụ: `build/002-implement-todo`)
|
|
55
|
+
- Đường dẫn worktree: `../{repo-name}-{integration-slug}` (ví dụ: `../myapp-002-implement-todo`)
|
|
56
|
+
- Lệnh:
|
|
57
|
+
```bash
|
|
58
|
+
git worktree add -b build/{slug} ../{repo}-{slug}
|
|
59
|
+
```
|
|
60
|
+
- Nếu branch đã tồn tại, dùng `--force` hoặc checkout branch cũ.
|
|
61
|
+
|
|
62
|
+
2. **Detect package manager**
|
|
63
|
+
- Kiểm tra theo thứ tự: `pnpm-lock.yaml` → `yarn.lock` → `package-lock.json` → `package.json`
|
|
64
|
+
- Dùng package manager tương ứng: `pnpm install` / `yarn install` / `npm install`
|
|
65
|
+
- Nếu không có `package.json` → bỏ qua bước install.
|
|
66
|
+
|
|
67
|
+
3. **Copy env files**
|
|
68
|
+
- Tìm tất cả file `.env*` ở root của working directory gốc (`.env`, `.env.local`, `.env.development`, v.v.)
|
|
69
|
+
- Copy từng file vào worktree mới:
|
|
70
|
+
```bash
|
|
71
|
+
cp .env* ../{repo}-{slug}/
|
|
72
|
+
```
|
|
73
|
+
- Bỏ qua nếu không có file `.env*` nào.
|
|
74
|
+
|
|
75
|
+
4. **Chuyển working context sang worktree mới**
|
|
76
|
+
- Tất cả các bước build tiếp theo đều chạy trong đường dẫn worktree mới.
|
|
77
|
+
- Nhắc user biết đang build tại: `../{repo}-{slug}`
|
|
78
|
+
|
|
41
79
|
### Với mỗi task pending
|
|
42
80
|
|
|
43
81
|
**1. Chọn task** (`incremental-implementation` — Increment Cycle)
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review-and-quality
|
|
3
|
+
description: Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Review and Quality
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Multi-dimensional code review with quality gates. Every change gets reviewed before merge — no exceptions. Review covers five axes: correctness, readability, architecture, security, and performance.
|
|
11
|
+
|
|
12
|
+
**The approval standard:** Approve a change when it definitely improves overall code health, even if it isn't perfect. Perfect code doesn't exist — the goal is continuous improvement. Don't block a change because it isn't exactly how you would have written it. If it improves the codebase and follows the project's conventions, approve it.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- Before merging any PR or change
|
|
17
|
+
- After completing a feature implementation
|
|
18
|
+
- When another agent or model produced code you need to evaluate
|
|
19
|
+
- When refactoring existing code
|
|
20
|
+
- After any bug fix (review both the fix and the regression test)
|
|
21
|
+
|
|
22
|
+
## The Five-Axis Review
|
|
23
|
+
|
|
24
|
+
Every review evaluates code across these dimensions:
|
|
25
|
+
|
|
26
|
+
### 1. Correctness
|
|
27
|
+
|
|
28
|
+
Does the code do what it claims to do?
|
|
29
|
+
|
|
30
|
+
- Does it match the spec or task requirements?
|
|
31
|
+
- Are edge cases handled (null, empty, boundary values)?
|
|
32
|
+
- Are error paths handled (not just the happy path)?
|
|
33
|
+
- Does it pass all tests? Are the tests actually testing the right things?
|
|
34
|
+
- Are there off-by-one errors, race conditions, or state inconsistencies?
|
|
35
|
+
|
|
36
|
+
### 2. Readability & Simplicity
|
|
37
|
+
|
|
38
|
+
Can another engineer (or agent) understand this code without the author explaining it?
|
|
39
|
+
|
|
40
|
+
- Are names descriptive and consistent with project conventions? (No `temp`, `data`, `result` without context)
|
|
41
|
+
- Is the control flow straightforward (avoid nested ternaries, deep callbacks)?
|
|
42
|
+
- Is the code organized logically (related code grouped, clear module boundaries)?
|
|
43
|
+
- Are there any "clever" tricks that should be simplified?
|
|
44
|
+
- **Could this be done in fewer lines?** (1000 lines where 100 suffice is a failure)
|
|
45
|
+
- **Are abstractions earning their complexity?** (Don't generalize until the third use case)
|
|
46
|
+
- Would comments help clarify non-obvious intent? (But don't comment obvious code.)
|
|
47
|
+
- Are there dead code artifacts: no-op variables (`_unused`), backwards-compat shims, or `// removed` comments?
|
|
48
|
+
|
|
49
|
+
### 3. Architecture
|
|
50
|
+
|
|
51
|
+
Does the change fit the system's design?
|
|
52
|
+
|
|
53
|
+
- Does it follow existing patterns or introduce a new one? If new, is it justified?
|
|
54
|
+
- Does it maintain clean module boundaries?
|
|
55
|
+
- Is there code duplication that should be shared?
|
|
56
|
+
- Are dependencies flowing in the right direction (no circular dependencies)?
|
|
57
|
+
- Is the abstraction level appropriate (not over-engineered, not too coupled)?
|
|
58
|
+
|
|
59
|
+
### 4. Security
|
|
60
|
+
|
|
61
|
+
For detailed security guidance, see `security-and-hardening`. Does the change introduce vulnerabilities?
|
|
62
|
+
|
|
63
|
+
- Is user input validated and sanitized?
|
|
64
|
+
- Are secrets kept out of code, logs, and version control?
|
|
65
|
+
- Is authentication/authorization checked where needed?
|
|
66
|
+
- Are SQL queries parameterized (no string concatenation)?
|
|
67
|
+
- Are outputs encoded to prevent XSS?
|
|
68
|
+
- Are dependencies from trusted sources with no known vulnerabilities?
|
|
69
|
+
- Is data from external sources (APIs, logs, user content, config files) treated as untrusted?
|
|
70
|
+
- Are external data flows validated at system boundaries before use in logic or rendering?
|
|
71
|
+
|
|
72
|
+
### 5. Performance
|
|
73
|
+
|
|
74
|
+
For detailed profiling and optimization, see `performance-optimization`. Does the change introduce performance problems?
|
|
75
|
+
|
|
76
|
+
- Any N+1 query patterns?
|
|
77
|
+
- Any unbounded loops or unconstrained data fetching?
|
|
78
|
+
- Any synchronous operations that should be async?
|
|
79
|
+
- Any unnecessary re-renders in UI components?
|
|
80
|
+
- Any missing pagination on list endpoints?
|
|
81
|
+
- Any large objects created in hot paths?
|
|
82
|
+
|
|
83
|
+
## Change Sizing
|
|
84
|
+
|
|
85
|
+
Small, focused changes are easier to review, faster to merge, and safer to deploy. Target these sizes:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
~100 lines changed → Good. Reviewable in one sitting.
|
|
89
|
+
~300 lines changed → Acceptable if it's a single logical change.
|
|
90
|
+
~1000 lines changed → Too large. Split it.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**What counts as "one change":** A single self-contained modification that addresses one thing, includes related tests, and keeps the system functional after submission. One part of a feature — not the whole feature.
|
|
94
|
+
|
|
95
|
+
**Splitting strategies when a change is too large:**
|
|
96
|
+
|
|
97
|
+
| Strategy | How | When |
|
|
98
|
+
|----------|-----|------|
|
|
99
|
+
| **Stack** | Submit a small change, start the next one based on it | Sequential dependencies |
|
|
100
|
+
| **By file group** | Separate changes for groups needing different reviewers | Cross-cutting concerns |
|
|
101
|
+
| **Horizontal** | Create shared code/stubs first, then consumers | Layered architecture |
|
|
102
|
+
| **Vertical** | Break into smaller full-stack slices of the feature | Feature work |
|
|
103
|
+
|
|
104
|
+
**When large changes are acceptable:** Complete file deletions and automated refactoring where the reviewer only needs to verify intent, not every line.
|
|
105
|
+
|
|
106
|
+
**Separate refactoring from feature work.** A change that refactors existing code and adds new behavior is two changes — submit them separately. Small cleanups (variable renaming) can be included at reviewer discretion.
|
|
107
|
+
|
|
108
|
+
## Change Descriptions
|
|
109
|
+
|
|
110
|
+
Every change needs a description that stands alone in version control history.
|
|
111
|
+
|
|
112
|
+
**First line:** Short, imperative, standalone. "Delete the FizzBuzz RPC" not "Deleting the FizzBuzz RPC." Must be informative enough that someone searching history can understand the change without reading the diff.
|
|
113
|
+
|
|
114
|
+
**Body:** What is changing and why. Include context, decisions, and reasoning not visible in the code itself. Link to bug numbers, benchmark results, or design docs where relevant. Acknowledge approach shortcomings when they exist.
|
|
115
|
+
|
|
116
|
+
**Anti-patterns:** "Fix bug," "Fix build," "Add patch," "Moving code from A to B," "Phase 1," "Add convenience functions."
|
|
117
|
+
|
|
118
|
+
## Review Process
|
|
119
|
+
|
|
120
|
+
### Step 1: Understand the Context
|
|
121
|
+
|
|
122
|
+
Before looking at code, understand the intent:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
- What is this change trying to accomplish?
|
|
126
|
+
- What spec or task does it implement?
|
|
127
|
+
- What is the expected behavior change?
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Step 2: Review the Tests First
|
|
131
|
+
|
|
132
|
+
Tests reveal intent and coverage:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
- Do tests exist for the change?
|
|
136
|
+
- Do they test behavior (not implementation details)?
|
|
137
|
+
- Are edge cases covered?
|
|
138
|
+
- Do tests have descriptive names?
|
|
139
|
+
- Would the tests catch a regression if the code changed?
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Step 3: Review the Implementation
|
|
143
|
+
|
|
144
|
+
Walk through the code with the five axes in mind:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
For each file changed:
|
|
148
|
+
1. Correctness: Does this code do what the test says it should?
|
|
149
|
+
2. Readability: Can I understand this without help?
|
|
150
|
+
3. Architecture: Does this fit the system?
|
|
151
|
+
4. Security: Any vulnerabilities?
|
|
152
|
+
5. Performance: Any bottlenecks?
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Step 4: Categorize Findings
|
|
156
|
+
|
|
157
|
+
Label every comment with its severity so the author knows what's required vs optional:
|
|
158
|
+
|
|
159
|
+
| Prefix | Meaning | Author Action |
|
|
160
|
+
|--------|---------|---------------|
|
|
161
|
+
| *(no prefix)* | Required change | Must address before merge |
|
|
162
|
+
| **Critical:** | Blocks merge | Security vulnerability, data loss, broken functionality |
|
|
163
|
+
| **Nit:** | Minor, optional | Author may ignore — formatting, style preferences |
|
|
164
|
+
| **Optional:** / **Consider:** | Suggestion | Worth considering but not required |
|
|
165
|
+
| **FYI** | Informational only | No action needed — context for future reference |
|
|
166
|
+
|
|
167
|
+
This prevents authors from treating all feedback as mandatory and wasting time on optional suggestions.
|
|
168
|
+
|
|
169
|
+
### Step 5: Verify the Verification
|
|
170
|
+
|
|
171
|
+
Check the author's verification story:
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
- What tests were run?
|
|
175
|
+
- Did the build pass?
|
|
176
|
+
- Was the change tested manually?
|
|
177
|
+
- Are there screenshots for UI changes?
|
|
178
|
+
- Is there a before/after comparison?
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Multi-Model Review Pattern
|
|
182
|
+
|
|
183
|
+
Use different models for different review perspectives:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
Model A writes the code
|
|
187
|
+
│
|
|
188
|
+
▼
|
|
189
|
+
Model B reviews for correctness and architecture
|
|
190
|
+
│
|
|
191
|
+
▼
|
|
192
|
+
Model A addresses the feedback
|
|
193
|
+
│
|
|
194
|
+
▼
|
|
195
|
+
Human makes the final call
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
This catches issues that a single model might miss — different models have different blind spots.
|
|
199
|
+
|
|
200
|
+
**Example prompt for a review agent:**
|
|
201
|
+
```
|
|
202
|
+
Review this code change for correctness, security, and adherence to
|
|
203
|
+
our project conventions. The spec says [X]. The change should [Y].
|
|
204
|
+
Flag any issues as Critical, Important, or Suggestion.
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Dead Code Hygiene
|
|
208
|
+
|
|
209
|
+
After any refactoring or implementation change, check for orphaned code:
|
|
210
|
+
|
|
211
|
+
1. Identify code that is now unreachable or unused
|
|
212
|
+
2. List it explicitly
|
|
213
|
+
3. **Ask before deleting:** "Should I remove these now-unused elements: [list]?"
|
|
214
|
+
|
|
215
|
+
Don't leave dead code lying around — it confuses future readers and agents. But don't silently delete things you're not sure about. When in doubt, ask.
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
DEAD CODE IDENTIFIED:
|
|
219
|
+
- formatLegacyDate() in src/utils/date.ts — replaced by formatDate()
|
|
220
|
+
- OldTaskCard component in src/components/ — replaced by TaskCard
|
|
221
|
+
- LEGACY_API_URL constant in src/config.ts — no remaining references
|
|
222
|
+
→ Safe to remove these?
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Review Speed
|
|
226
|
+
|
|
227
|
+
Slow reviews block entire teams. The cost of context-switching to review is less than the waiting cost imposed on others.
|
|
228
|
+
|
|
229
|
+
- **Respond within one business day** — this is the maximum, not the target
|
|
230
|
+
- **Ideal cadence:** Respond shortly after a review request arrives, unless deep in focused coding. A typical change should complete multiple review rounds in a single day
|
|
231
|
+
- **Prioritize fast individual responses** over quick final approval. Quick feedback reduces frustration even if multiple rounds are needed
|
|
232
|
+
- **Large changes:** Ask the author to split them rather than reviewing one massive changeset
|
|
233
|
+
|
|
234
|
+
## Handling Disagreements
|
|
235
|
+
|
|
236
|
+
When resolving review disputes, apply this hierarchy:
|
|
237
|
+
|
|
238
|
+
1. **Technical facts and data** override opinions and preferences
|
|
239
|
+
2. **Style guides** are the absolute authority on style matters
|
|
240
|
+
3. **Software design** must be evaluated on engineering principles, not personal preference
|
|
241
|
+
4. **Codebase consistency** is acceptable if it doesn't degrade overall health
|
|
242
|
+
|
|
243
|
+
**Don't accept "I'll clean it up later."** Experience shows deferred cleanup rarely happens. Require cleanup before submission unless it's a genuine emergency. If surrounding issues can't be addressed in this change, require filing a bug with self-assignment.
|
|
244
|
+
|
|
245
|
+
## Honesty in Review
|
|
246
|
+
|
|
247
|
+
When reviewing code — whether written by you, another agent, or a human:
|
|
248
|
+
|
|
249
|
+
- **Don't rubber-stamp.** "LGTM" without evidence of review helps no one.
|
|
250
|
+
- **Don't soften real issues.** "This might be a minor concern" when it's a bug that will hit production is dishonest.
|
|
251
|
+
- **Quantify problems when possible.** "This N+1 query will add ~50ms per item in the list" is better than "this could be slow."
|
|
252
|
+
- **Push back on approaches with clear problems.** Sycophancy is a failure mode in reviews. If the implementation has issues, say so directly and propose alternatives.
|
|
253
|
+
- **Accept override gracefully.** If the author has full context and disagrees, defer to their judgment. Comment on code, not people — reframe personal critiques to focus on the code itself.
|
|
254
|
+
|
|
255
|
+
## Dependency Discipline
|
|
256
|
+
|
|
257
|
+
Part of code review is dependency review:
|
|
258
|
+
|
|
259
|
+
**Before adding any dependency:**
|
|
260
|
+
1. Does the existing stack solve this? (Often it does.)
|
|
261
|
+
2. How large is the dependency? (Check bundle impact.)
|
|
262
|
+
3. Is it actively maintained? (Check last commit, open issues.)
|
|
263
|
+
4. Does it have known vulnerabilities? (`npm audit`)
|
|
264
|
+
5. What's the license? (Must be compatible with the project.)
|
|
265
|
+
|
|
266
|
+
**Rule:** Prefer standard library and existing utilities over new dependencies. Every dependency is a liability.
|
|
267
|
+
|
|
268
|
+
## The Review Checklist
|
|
269
|
+
|
|
270
|
+
```markdown
|
|
271
|
+
## Review: [PR/Change title]
|
|
272
|
+
|
|
273
|
+
### Context
|
|
274
|
+
- [ ] I understand what this change does and why
|
|
275
|
+
|
|
276
|
+
### Correctness
|
|
277
|
+
- [ ] Change matches spec/task requirements
|
|
278
|
+
- [ ] Edge cases handled
|
|
279
|
+
- [ ] Error paths handled
|
|
280
|
+
- [ ] Tests cover the change adequately
|
|
281
|
+
|
|
282
|
+
### Readability
|
|
283
|
+
- [ ] Names are clear and consistent
|
|
284
|
+
- [ ] Logic is straightforward
|
|
285
|
+
- [ ] No unnecessary complexity
|
|
286
|
+
|
|
287
|
+
### Architecture
|
|
288
|
+
- [ ] Follows existing patterns
|
|
289
|
+
- [ ] No unnecessary coupling or dependencies
|
|
290
|
+
- [ ] Appropriate abstraction level
|
|
291
|
+
|
|
292
|
+
### Security
|
|
293
|
+
- [ ] No secrets in code
|
|
294
|
+
- [ ] Input validated at boundaries
|
|
295
|
+
- [ ] No injection vulnerabilities
|
|
296
|
+
- [ ] Auth checks in place
|
|
297
|
+
- [ ] External data sources treated as untrusted
|
|
298
|
+
|
|
299
|
+
### Performance
|
|
300
|
+
- [ ] No N+1 patterns
|
|
301
|
+
- [ ] No unbounded operations
|
|
302
|
+
- [ ] Pagination on list endpoints
|
|
303
|
+
|
|
304
|
+
### Verification
|
|
305
|
+
- [ ] Tests pass
|
|
306
|
+
- [ ] Build succeeds
|
|
307
|
+
- [ ] Manual verification done (if applicable)
|
|
308
|
+
|
|
309
|
+
### Verdict
|
|
310
|
+
- [ ] **Approve** — Ready to merge
|
|
311
|
+
- [ ] **Request changes** — Issues must be addressed
|
|
312
|
+
```
|
|
313
|
+
## See Also
|
|
314
|
+
|
|
315
|
+
- For detailed security review guidance, see `references/security-checklist.md`
|
|
316
|
+
- For performance review checks, see `references/performance-checklist.md`
|
|
317
|
+
|
|
318
|
+
## Common Rationalizations
|
|
319
|
+
|
|
320
|
+
| Rationalization | Reality |
|
|
321
|
+
|---|---|
|
|
322
|
+
| "It works, that's good enough" | Working code that's unreadable, insecure, or architecturally wrong creates debt that compounds. |
|
|
323
|
+
| "I wrote it, so I know it's correct" | Authors are blind to their own assumptions. Every change benefits from another set of eyes. |
|
|
324
|
+
| "We'll clean it up later" | Later never comes. The review is the quality gate — use it. Require cleanup before merge, not after. |
|
|
325
|
+
| "AI-generated code is probably fine" | AI code needs more scrutiny, not less. It's confident and plausible, even when wrong. |
|
|
326
|
+
| "The tests pass, so it's good" | Tests are necessary but not sufficient. They don't catch architecture problems, security issues, or readability concerns. |
|
|
327
|
+
|
|
328
|
+
## Red Flags
|
|
329
|
+
|
|
330
|
+
- PRs merged without any review
|
|
331
|
+
- Review that only checks if tests pass (ignoring other axes)
|
|
332
|
+
- "LGTM" without evidence of actual review
|
|
333
|
+
- Security-sensitive changes without security-focused review
|
|
334
|
+
- Large PRs that are "too big to review properly" (split them)
|
|
335
|
+
- No regression tests with bug fix PRs
|
|
336
|
+
- Review comments without severity labels — makes it unclear what's required vs optional
|
|
337
|
+
- Accepting "I'll fix it later" — it never happens
|
|
338
|
+
|
|
339
|
+
## Verification
|
|
340
|
+
|
|
341
|
+
After review is complete:
|
|
342
|
+
|
|
343
|
+
- [ ] All Critical issues are resolved
|
|
344
|
+
- [ ] All Important issues are resolved or explicitly deferred with justification
|
|
345
|
+
- [ ] Tests pass
|
|
346
|
+
- [ ] Build succeeds
|
|
347
|
+
- [ ] The verification story is documented (what changed, how it was verified)
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance-optimization
|
|
3
|
+
description: Optimizes application performance. Use when performance requirements exist, when you suspect performance regressions, or when Core Web Vitals or load times need improvement. Use when profiling reveals bottlenecks that need fixing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Performance Optimization
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Measure before optimizing. Performance work without measurement is guessing — and guessing leads to premature optimization that adds complexity without improving what matters. Profile first, identify the actual bottleneck, fix it, measure again. Optimize only what measurements prove matters.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Performance requirements exist in the spec (load time budgets, response time SLAs)
|
|
15
|
+
- Users or monitoring report slow behavior
|
|
16
|
+
- Core Web Vitals scores are below thresholds
|
|
17
|
+
- You suspect a change introduced a regression
|
|
18
|
+
- Building features that handle large datasets or high traffic
|
|
19
|
+
|
|
20
|
+
**When NOT to use:** Don't optimize before you have evidence of a problem. Premature optimization adds complexity that costs more than the performance it gains.
|
|
21
|
+
|
|
22
|
+
## Core Web Vitals Targets
|
|
23
|
+
|
|
24
|
+
| Metric | Good | Needs Improvement | Poor |
|
|
25
|
+
|--------|------|-------------------|------|
|
|
26
|
+
| **LCP** (Largest Contentful Paint) | ≤ 2.5s | ≤ 4.0s | > 4.0s |
|
|
27
|
+
| **INP** (Interaction to Next Paint) | ≤ 200ms | ≤ 500ms | > 500ms |
|
|
28
|
+
| **CLS** (Cumulative Layout Shift) | ≤ 0.1 | ≤ 0.25 | > 0.25 |
|
|
29
|
+
|
|
30
|
+
## The Optimization Workflow
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
1. MEASURE → Establish baseline with real data
|
|
34
|
+
2. IDENTIFY → Find the actual bottleneck (not assumed)
|
|
35
|
+
3. FIX → Address the specific bottleneck
|
|
36
|
+
4. VERIFY → Measure again, confirm improvement
|
|
37
|
+
5. GUARD → Add monitoring or tests to prevent regression
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step 1: Measure
|
|
41
|
+
|
|
42
|
+
Two complementary approaches — use both:
|
|
43
|
+
|
|
44
|
+
- **Synthetic (Lighthouse, DevTools Performance tab):** Controlled conditions, reproducible. Best for CI regression detection and isolating specific issues.
|
|
45
|
+
- **RUM (web-vitals library, CrUX):** Real user data in real conditions. Required to validate that a fix actually improved user experience.
|
|
46
|
+
|
|
47
|
+
**Frontend:**
|
|
48
|
+
```bash
|
|
49
|
+
# Synthetic: Lighthouse in Chrome DevTools (or CI)
|
|
50
|
+
# Chrome DevTools → Performance tab → Record
|
|
51
|
+
# Chrome DevTools MCP → Performance trace
|
|
52
|
+
|
|
53
|
+
# RUM: Web Vitals library in code
|
|
54
|
+
import { onLCP, onINP, onCLS } from 'web-vitals';
|
|
55
|
+
|
|
56
|
+
onLCP(console.log);
|
|
57
|
+
onINP(console.log);
|
|
58
|
+
onCLS(console.log);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Backend:**
|
|
62
|
+
```bash
|
|
63
|
+
# Response time logging
|
|
64
|
+
# Application Performance Monitoring (APM)
|
|
65
|
+
# Database query logging with timing
|
|
66
|
+
|
|
67
|
+
# Simple timing
|
|
68
|
+
console.time('db-query');
|
|
69
|
+
const result = await db.query(...);
|
|
70
|
+
console.timeEnd('db-query');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Where to Start Measuring
|
|
74
|
+
|
|
75
|
+
Use the symptom to decide what to measure first:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
What is slow?
|
|
79
|
+
├── First page load
|
|
80
|
+
│ ├── Large bundle? --> Measure bundle size, check code splitting
|
|
81
|
+
│ ├── Slow server response? --> Measure TTFB in DevTools Network waterfall
|
|
82
|
+
│ │ ├── DNS long? --> Add dns-prefetch / preconnect for known origins
|
|
83
|
+
│ │ ├── TCP/TLS long? --> Enable HTTP/2, check edge deployment, keep-alive
|
|
84
|
+
│ │ └── Waiting (server) long? --> Profile backend, check queries and caching
|
|
85
|
+
│ └── Render-blocking resources? --> Check network waterfall for CSS/JS blocking
|
|
86
|
+
├── Interaction feels sluggish
|
|
87
|
+
│ ├── UI freezes on click? --> Profile main thread, look for long tasks (>50ms)
|
|
88
|
+
│ ├── Form input lag? --> Check re-renders, controlled component overhead
|
|
89
|
+
│ └── Animation jank? --> Check layout thrashing, forced reflows
|
|
90
|
+
├── Page after navigation
|
|
91
|
+
│ ├── Data loading? --> Measure API response times, check for waterfalls
|
|
92
|
+
│ └── Client rendering? --> Profile component render time, check for N+1 fetches
|
|
93
|
+
└── Backend / API
|
|
94
|
+
├── Single endpoint slow? --> Profile database queries, check indexes
|
|
95
|
+
├── All endpoints slow? --> Check connection pool, memory, CPU
|
|
96
|
+
└── Intermittent slowness? --> Check for lock contention, GC pauses, external deps
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Step 2: Identify the Bottleneck
|
|
100
|
+
|
|
101
|
+
Common bottlenecks by category:
|
|
102
|
+
|
|
103
|
+
**Frontend:**
|
|
104
|
+
|
|
105
|
+
| Symptom | Likely Cause | Investigation |
|
|
106
|
+
|---------|-------------|---------------|
|
|
107
|
+
| Slow LCP | Large images, render-blocking resources, slow server | Check network waterfall, image sizes |
|
|
108
|
+
| High CLS | Images without dimensions, late-loading content, font shifts | Check layout shift attribution |
|
|
109
|
+
| Poor INP | Heavy JavaScript on main thread, large DOM updates | Check long tasks in Performance trace |
|
|
110
|
+
| Slow initial load | Large bundle, many network requests | Check bundle size, code splitting |
|
|
111
|
+
|
|
112
|
+
**Backend:**
|
|
113
|
+
|
|
114
|
+
| Symptom | Likely Cause | Investigation |
|
|
115
|
+
|---------|-------------|---------------|
|
|
116
|
+
| Slow API responses | N+1 queries, missing indexes, unoptimized queries | Check database query log |
|
|
117
|
+
| Memory growth | Leaked references, unbounded caches, large payloads | Heap snapshot analysis |
|
|
118
|
+
| CPU spikes | Synchronous heavy computation, regex backtracking | CPU profiling |
|
|
119
|
+
| High latency | Missing caching, redundant computation, network hops | Trace requests through the stack |
|
|
120
|
+
|
|
121
|
+
### Step 3: Fix Common Anti-Patterns
|
|
122
|
+
|
|
123
|
+
#### N+1 Queries (Backend)
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// BAD: N+1 — one query per task for the owner
|
|
127
|
+
const tasks = await db.tasks.findMany();
|
|
128
|
+
for (const task of tasks) {
|
|
129
|
+
task.owner = await db.users.findUnique({ where: { id: task.ownerId } });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// GOOD: Single query with join/include
|
|
133
|
+
const tasks = await db.tasks.findMany({
|
|
134
|
+
include: { owner: true },
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Unbounded Data Fetching
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// BAD: Fetching all records
|
|
142
|
+
const allTasks = await db.tasks.findMany();
|
|
143
|
+
|
|
144
|
+
// GOOD: Paginated with limits
|
|
145
|
+
const tasks = await db.tasks.findMany({
|
|
146
|
+
take: 20,
|
|
147
|
+
skip: (page - 1) * 20,
|
|
148
|
+
orderBy: { createdAt: 'desc' },
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Missing Image Optimization (Frontend)
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<!-- BAD: No dimensions, no format optimization -->
|
|
156
|
+
<img src="/hero.jpg" />
|
|
157
|
+
|
|
158
|
+
<!-- GOOD: Hero / LCP image — art direction + resolution switching, high priority -->
|
|
159
|
+
<!--
|
|
160
|
+
Two techniques combined:
|
|
161
|
+
- Art direction (media): different crop/composition per breakpoint
|
|
162
|
+
- Resolution switching (srcset + sizes): right file size per screen density
|
|
163
|
+
-->
|
|
164
|
+
<picture>
|
|
165
|
+
<!-- Mobile: portrait crop (8:10) -->
|
|
166
|
+
<source
|
|
167
|
+
media="(max-width: 767px)"
|
|
168
|
+
srcset="/hero-mobile-400.avif 400w, /hero-mobile-800.avif 800w"
|
|
169
|
+
sizes="100vw"
|
|
170
|
+
width="800"
|
|
171
|
+
height="1000"
|
|
172
|
+
type="image/avif"
|
|
173
|
+
/>
|
|
174
|
+
<source
|
|
175
|
+
media="(max-width: 767px)"
|
|
176
|
+
srcset="/hero-mobile-400.webp 400w, /hero-mobile-800.webp 800w"
|
|
177
|
+
sizes="100vw"
|
|
178
|
+
width="800"
|
|
179
|
+
height="1000"
|
|
180
|
+
type="image/webp"
|
|
181
|
+
/>
|
|
182
|
+
<!-- Desktop: landscape crop (2:1) -->
|
|
183
|
+
<source
|
|
184
|
+
srcset="/hero-800.avif 800w, /hero-1200.avif 1200w, /hero-1600.avif 1600w"
|
|
185
|
+
sizes="(max-width: 1200px) 100vw, 1200px"
|
|
186
|
+
width="1200"
|
|
187
|
+
height="600"
|
|
188
|
+
type="image/avif"
|
|
189
|
+
/>
|
|
190
|
+
<source
|
|
191
|
+
srcset="/hero-800.webp 800w, /hero-1200.webp 1200w, /hero-1600.webp 1600w"
|
|
192
|
+
sizes="(max-width: 1200px) 100vw, 1200px"
|
|
193
|
+
width="1200"
|
|
194
|
+
height="600"
|
|
195
|
+
type="image/webp"
|
|
196
|
+
/>
|
|
197
|
+
<img
|
|
198
|
+
src="/hero-desktop.jpg"
|
|
199
|
+
width="1200"
|
|
200
|
+
height="600"
|
|
201
|
+
fetchpriority="high"
|
|
202
|
+
alt="Hero image description"
|
|
203
|
+
/>
|
|
204
|
+
</picture>
|
|
205
|
+
|
|
206
|
+
<!-- GOOD: Below-the-fold image — lazy loaded + async decoding -->
|
|
207
|
+
<img
|
|
208
|
+
src="/content.webp"
|
|
209
|
+
width="800"
|
|
210
|
+
height="400"
|
|
211
|
+
loading="lazy"
|
|
212
|
+
decoding="async"
|
|
213
|
+
alt="Content image description"
|
|
214
|
+
/>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### Unnecessary Re-renders (React)
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
// BAD: Creates new object on every render, causing children to re-render
|
|
221
|
+
function TaskList() {
|
|
222
|
+
return <TaskFilters options={{ sortBy: 'date', order: 'desc' }} />;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// GOOD: Stable reference
|
|
226
|
+
const DEFAULT_OPTIONS = { sortBy: 'date', order: 'desc' } as const;
|
|
227
|
+
function TaskList() {
|
|
228
|
+
return <TaskFilters options={DEFAULT_OPTIONS} />;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Use React.memo for expensive components
|
|
232
|
+
const TaskItem = React.memo(function TaskItem({ task }: Props) {
|
|
233
|
+
return <div>{/* expensive render */}</div>;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Use useMemo for expensive computations
|
|
237
|
+
function TaskStats({ tasks }: Props) {
|
|
238
|
+
const stats = useMemo(() => calculateStats(tasks), [tasks]);
|
|
239
|
+
return <div>{stats.completed} / {stats.total}</div>;
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### Large Bundle Size
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// Modern bundlers (Vite, webpack 5+) handle named imports with tree-shaking automatically,
|
|
247
|
+
// provided the dependency ships ESM and is marked `sideEffects: false` in package.json.
|
|
248
|
+
// Profile before changing import styles — the real gains come from splitting and lazy loading.
|
|
249
|
+
|
|
250
|
+
// GOOD: Dynamic import for heavy, rarely-used features
|
|
251
|
+
const ChartLibrary = lazy(() => import('./ChartLibrary'));
|
|
252
|
+
|
|
253
|
+
// GOOD: Route-level code splitting wrapped in Suspense
|
|
254
|
+
const SettingsPage = lazy(() => import('./pages/Settings'));
|
|
255
|
+
|
|
256
|
+
function App() {
|
|
257
|
+
return (
|
|
258
|
+
<Suspense fallback={<Spinner />}>
|
|
259
|
+
<SettingsPage />
|
|
260
|
+
</Suspense>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### Missing Caching (Backend)
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// Cache frequently-read, rarely-changed data
|
|
269
|
+
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
270
|
+
let cachedConfig: AppConfig | null = null;
|
|
271
|
+
let cacheExpiry = 0;
|
|
272
|
+
|
|
273
|
+
async function getAppConfig(): Promise<AppConfig> {
|
|
274
|
+
if (cachedConfig && Date.now() < cacheExpiry) {
|
|
275
|
+
return cachedConfig;
|
|
276
|
+
}
|
|
277
|
+
cachedConfig = await db.config.findFirst();
|
|
278
|
+
cacheExpiry = Date.now() + CACHE_TTL;
|
|
279
|
+
return cachedConfig;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// HTTP caching headers for static assets
|
|
283
|
+
app.use('/static', express.static('public', {
|
|
284
|
+
maxAge: '1y', // Cache for 1 year
|
|
285
|
+
immutable: true, // Never revalidate (use content hashing in filenames)
|
|
286
|
+
}));
|
|
287
|
+
|
|
288
|
+
// Cache-Control for API responses
|
|
289
|
+
res.set('Cache-Control', 'public, max-age=300'); // 5 minutes
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Performance Budget
|
|
293
|
+
|
|
294
|
+
Set budgets and enforce them:
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
JavaScript bundle: < 200KB gzipped (initial load)
|
|
298
|
+
CSS: < 50KB gzipped
|
|
299
|
+
Images: < 200KB per image (above the fold)
|
|
300
|
+
Fonts: < 100KB total
|
|
301
|
+
API response time: < 200ms (p95)
|
|
302
|
+
Time to Interactive: < 3.5s on 4G
|
|
303
|
+
Lighthouse Performance score: ≥ 90
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Enforce in CI:**
|
|
307
|
+
```bash
|
|
308
|
+
# Bundle size check
|
|
309
|
+
npx bundlesize --config bundlesize.config.json
|
|
310
|
+
|
|
311
|
+
# Lighthouse CI
|
|
312
|
+
npx lhci autorun
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## See Also
|
|
316
|
+
|
|
317
|
+
For detailed performance checklists, optimization commands, and anti-pattern reference, see `references/performance-checklist.md`.
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
## Common Rationalizations
|
|
321
|
+
|
|
322
|
+
| Rationalization | Reality |
|
|
323
|
+
|---|---|
|
|
324
|
+
| "We'll optimize later" | Performance debt compounds. Fix obvious anti-patterns now, defer micro-optimizations. |
|
|
325
|
+
| "It's fast on my machine" | Your machine isn't the user's. Profile on representative hardware and networks. |
|
|
326
|
+
| "This optimization is obvious" | If you didn't measure, you don't know. Profile first. |
|
|
327
|
+
| "Users won't notice 100ms" | Research shows 100ms delays impact conversion rates. Users notice more than you think. |
|
|
328
|
+
| "The framework handles performance" | Frameworks prevent some issues but can't fix N+1 queries or oversized bundles. |
|
|
329
|
+
|
|
330
|
+
## Red Flags
|
|
331
|
+
|
|
332
|
+
- Optimization without profiling data to justify it
|
|
333
|
+
- N+1 query patterns in data fetching
|
|
334
|
+
- List endpoints without pagination
|
|
335
|
+
- Images without dimensions, lazy loading, or responsive sizes
|
|
336
|
+
- Bundle size growing without review
|
|
337
|
+
- No performance monitoring in production
|
|
338
|
+
- `React.memo` and `useMemo` everywhere (overusing is as bad as underusing)
|
|
339
|
+
|
|
340
|
+
## Verification
|
|
341
|
+
|
|
342
|
+
After any performance-related change:
|
|
343
|
+
|
|
344
|
+
- [ ] Before and after measurements exist (specific numbers)
|
|
345
|
+
- [ ] The specific bottleneck is identified and addressed
|
|
346
|
+
- [ ] Core Web Vitals are within "Good" thresholds
|
|
347
|
+
- [ ] Bundle size hasn't increased significantly
|
|
348
|
+
- [ ] No N+1 queries in new data fetching code
|
|
349
|
+
- [ ] Performance budget passes in CI (if configured)
|
|
350
|
+
- [ ] Existing tests still pass (optimization didn't break behavior)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review
|
|
3
|
+
description: Review code sau bước /build theo năm trục — correctness, readability, architecture, security, performance. Dùng sau khi hoàn thành một hoặc nhiều task trong todo.md. Đối chiếu implementation với spec.md và tech.md để xác nhận đúng yêu cầu.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Review
|
|
7
|
+
|
|
8
|
+
## Tổng quan
|
|
9
|
+
|
|
10
|
+
Invoke `code-review-and-quality` để review toàn bộ thay đổi sau `/build`.
|
|
11
|
+
|
|
12
|
+
Trước khi bắt đầu review, load context từ working integration:
|
|
13
|
+
|
|
14
|
+
1. `specs/integrations/{slug}/spec.md` — yêu cầu nghiệp vụ, acceptance criteria
|
|
15
|
+
2. `specs/integrations/{slug}/tech.md` — thiết kế kỹ thuật, API contract, data model
|
|
16
|
+
3. `specs/integrations/{slug}/plan.md` — task breakdown và acceptance criteria chi tiết
|
|
17
|
+
4. `specs/integrations/{slug}/todo.md` — task nào đã được implement (`[x]`)
|
|
18
|
+
|
|
19
|
+
Chạy `git diff main...HEAD` để lấy thay đổi cần review.
|
|
20
|
+
|
|
21
|
+
## Xác định integration
|
|
22
|
+
|
|
23
|
+
**Nếu có ARGUMENT:** Parse số thứ tự (`2`, `002`) hoặc slug (`002-implement-todo`). Quét `specs/integrations/*/todo.md`, dùng integration khớp.
|
|
24
|
+
|
|
25
|
+
**Nếu không có ARGUMENT:** Liệt kê integrations có task đã done, cho user chọn.
|
|
26
|
+
|
|
27
|
+
## Sau khi review
|
|
28
|
+
|
|
29
|
+
- **Có Critical/Important:** Dừng, không tiếp tục `/build`. Sửa và re-review.
|
|
30
|
+
- **Chỉ Suggestion hoặc không có finding:** Approve, tiếp tục `/build` task tiếp theo.
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-and-hardening
|
|
3
|
+
description: Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. Use when building any feature that accepts untrusted data, manages user sessions, or interacts with third-party services.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security and Hardening
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Security-first development practices for web applications. Treat every external input as hostile, every secret as sacred, and every authorization check as mandatory. Security isn't a phase — it's a constraint on every line of code that touches user data, authentication, or external systems.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Building anything that accepts user input
|
|
15
|
+
- Implementing authentication or authorization
|
|
16
|
+
- Storing or transmitting sensitive data
|
|
17
|
+
- Integrating with external APIs or services
|
|
18
|
+
- Adding file uploads, webhooks, or callbacks
|
|
19
|
+
- Handling payment or PII data
|
|
20
|
+
|
|
21
|
+
## The Three-Tier Boundary System
|
|
22
|
+
|
|
23
|
+
### Always Do (No Exceptions)
|
|
24
|
+
|
|
25
|
+
- **Validate all external input** at the system boundary (API routes, form handlers)
|
|
26
|
+
- **Parameterize all database queries** — never concatenate user input into SQL
|
|
27
|
+
- **Encode output** to prevent XSS (use framework auto-escaping, don't bypass it)
|
|
28
|
+
- **Use HTTPS** for all external communication
|
|
29
|
+
- **Hash passwords** with bcrypt/scrypt/argon2 (never store plaintext)
|
|
30
|
+
- **Set security headers** (CSP, HSTS, X-Frame-Options, X-Content-Type-Options)
|
|
31
|
+
- **Use httpOnly, secure, sameSite cookies** for sessions
|
|
32
|
+
- **Run `npm audit`** (or equivalent) before every release
|
|
33
|
+
|
|
34
|
+
### Ask First (Requires Human Approval)
|
|
35
|
+
|
|
36
|
+
- Adding new authentication flows or changing auth logic
|
|
37
|
+
- Storing new categories of sensitive data (PII, payment info)
|
|
38
|
+
- Adding new external service integrations
|
|
39
|
+
- Changing CORS configuration
|
|
40
|
+
- Adding file upload handlers
|
|
41
|
+
- Modifying rate limiting or throttling
|
|
42
|
+
- Granting elevated permissions or roles
|
|
43
|
+
|
|
44
|
+
### Never Do
|
|
45
|
+
|
|
46
|
+
- **Never commit secrets** to version control (API keys, passwords, tokens)
|
|
47
|
+
- **Never log sensitive data** (passwords, tokens, full credit card numbers)
|
|
48
|
+
- **Never trust client-side validation** as a security boundary
|
|
49
|
+
- **Never disable security headers** for convenience
|
|
50
|
+
- **Never use `eval()` or `innerHTML`** with user-provided data
|
|
51
|
+
- **Never store sessions in client-accessible storage** (localStorage for auth tokens)
|
|
52
|
+
- **Never expose stack traces** or internal error details to users
|
|
53
|
+
|
|
54
|
+
## OWASP Top 10 Prevention
|
|
55
|
+
|
|
56
|
+
### 1. Injection (SQL, NoSQL, OS Command)
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// BAD: SQL injection via string concatenation
|
|
60
|
+
const query = `SELECT * FROM users WHERE id = '${userId}'`;
|
|
61
|
+
|
|
62
|
+
// GOOD: Parameterized query
|
|
63
|
+
const user = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
|
|
64
|
+
|
|
65
|
+
// GOOD: ORM with parameterized input
|
|
66
|
+
const user = await prisma.user.findUnique({ where: { id: userId } });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Broken Authentication
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// Password hashing
|
|
73
|
+
import { hash, compare } from 'bcrypt';
|
|
74
|
+
|
|
75
|
+
const SALT_ROUNDS = 12;
|
|
76
|
+
const hashedPassword = await hash(plaintext, SALT_ROUNDS);
|
|
77
|
+
const isValid = await compare(plaintext, hashedPassword);
|
|
78
|
+
|
|
79
|
+
// Session management
|
|
80
|
+
app.use(session({
|
|
81
|
+
secret: process.env.SESSION_SECRET, // From environment, not code
|
|
82
|
+
resave: false,
|
|
83
|
+
saveUninitialized: false,
|
|
84
|
+
cookie: {
|
|
85
|
+
httpOnly: true, // Not accessible via JavaScript
|
|
86
|
+
secure: true, // HTTPS only
|
|
87
|
+
sameSite: 'lax', // CSRF protection
|
|
88
|
+
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. Cross-Site Scripting (XSS)
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// BAD: Rendering user input as HTML
|
|
97
|
+
element.innerHTML = userInput;
|
|
98
|
+
|
|
99
|
+
// GOOD: Use framework auto-escaping (React does this by default)
|
|
100
|
+
return <div>{userInput}</div>;
|
|
101
|
+
|
|
102
|
+
// If you MUST render HTML, sanitize first
|
|
103
|
+
import DOMPurify from 'dompurify';
|
|
104
|
+
const clean = DOMPurify.sanitize(userInput);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4. Broken Access Control
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Always check authorization, not just authentication
|
|
111
|
+
app.patch('/api/tasks/:id', authenticate, async (req, res) => {
|
|
112
|
+
const task = await taskService.findById(req.params.id);
|
|
113
|
+
|
|
114
|
+
// Check that the authenticated user owns this resource
|
|
115
|
+
if (task.ownerId !== req.user.id) {
|
|
116
|
+
return res.status(403).json({
|
|
117
|
+
error: { code: 'FORBIDDEN', message: 'Not authorized to modify this task' }
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Proceed with update
|
|
122
|
+
const updated = await taskService.update(req.params.id, req.body);
|
|
123
|
+
return res.json(updated);
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 5. Security Misconfiguration
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// Security headers (use helmet for Express)
|
|
131
|
+
import helmet from 'helmet';
|
|
132
|
+
app.use(helmet());
|
|
133
|
+
|
|
134
|
+
// Content Security Policy
|
|
135
|
+
app.use(helmet.contentSecurityPolicy({
|
|
136
|
+
directives: {
|
|
137
|
+
defaultSrc: ["'self'"],
|
|
138
|
+
scriptSrc: ["'self'"],
|
|
139
|
+
styleSrc: ["'self'", "'unsafe-inline'"], // Tighten if possible
|
|
140
|
+
imgSrc: ["'self'", 'data:', 'https:'],
|
|
141
|
+
connectSrc: ["'self'"],
|
|
142
|
+
},
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
// CORS — restrict to known origins
|
|
146
|
+
app.use(cors({
|
|
147
|
+
origin: process.env.ALLOWED_ORIGINS?.split(',') || 'http://localhost:3000',
|
|
148
|
+
credentials: true,
|
|
149
|
+
}));
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 6. Sensitive Data Exposure
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
// Never return sensitive fields in API responses
|
|
156
|
+
function sanitizeUser(user: UserRecord): PublicUser {
|
|
157
|
+
const { passwordHash, resetToken, ...publicFields } = user;
|
|
158
|
+
return publicFields;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Use environment variables for secrets
|
|
162
|
+
const API_KEY = process.env.STRIPE_API_KEY;
|
|
163
|
+
if (!API_KEY) throw new Error('STRIPE_API_KEY not configured');
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Input Validation Patterns
|
|
167
|
+
|
|
168
|
+
### Schema Validation at Boundaries
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { z } from 'zod';
|
|
172
|
+
|
|
173
|
+
const CreateTaskSchema = z.object({
|
|
174
|
+
title: z.string().min(1).max(200).trim(),
|
|
175
|
+
description: z.string().max(2000).optional(),
|
|
176
|
+
priority: z.enum(['low', 'medium', 'high']).default('medium'),
|
|
177
|
+
dueDate: z.string().datetime().optional(),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Validate at the route handler
|
|
181
|
+
app.post('/api/tasks', async (req, res) => {
|
|
182
|
+
const result = CreateTaskSchema.safeParse(req.body);
|
|
183
|
+
if (!result.success) {
|
|
184
|
+
return res.status(422).json({
|
|
185
|
+
error: {
|
|
186
|
+
code: 'VALIDATION_ERROR',
|
|
187
|
+
message: 'Invalid input',
|
|
188
|
+
details: result.error.flatten(),
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// result.data is now typed and validated
|
|
193
|
+
const task = await taskService.create(result.data);
|
|
194
|
+
return res.status(201).json(task);
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### File Upload Safety
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// Restrict file types and sizes
|
|
202
|
+
const ALLOWED_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
|
|
203
|
+
const MAX_SIZE = 5 * 1024 * 1024; // 5MB
|
|
204
|
+
|
|
205
|
+
function validateUpload(file: UploadedFile) {
|
|
206
|
+
if (!ALLOWED_TYPES.includes(file.mimetype)) {
|
|
207
|
+
throw new ValidationError('File type not allowed');
|
|
208
|
+
}
|
|
209
|
+
if (file.size > MAX_SIZE) {
|
|
210
|
+
throw new ValidationError('File too large (max 5MB)');
|
|
211
|
+
}
|
|
212
|
+
// Don't trust the file extension — check magic bytes if critical
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Triaging npm audit Results
|
|
217
|
+
|
|
218
|
+
Not all audit findings require immediate action. Use this decision tree:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
npm audit reports a vulnerability
|
|
222
|
+
├── Severity: critical or high
|
|
223
|
+
│ ├── Is the vulnerable code reachable in your app?
|
|
224
|
+
│ │ ├── YES --> Fix immediately (update, patch, or replace the dependency)
|
|
225
|
+
│ │ └── NO (dev-only dep, unused code path) --> Fix soon, but not a blocker
|
|
226
|
+
│ └── Is a fix available?
|
|
227
|
+
│ ├── YES --> Update to the patched version
|
|
228
|
+
│ └── NO --> Check for workarounds, consider replacing the dependency, or add to allowlist with a review date
|
|
229
|
+
├── Severity: moderate
|
|
230
|
+
│ ├── Reachable in production? --> Fix in the next release cycle
|
|
231
|
+
│ └── Dev-only? --> Fix when convenient, track in backlog
|
|
232
|
+
└── Severity: low
|
|
233
|
+
└── Track and fix during regular dependency updates
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Key questions:**
|
|
237
|
+
- Is the vulnerable function actually called in your code path?
|
|
238
|
+
- Is the dependency a runtime dependency or dev-only?
|
|
239
|
+
- Is the vulnerability exploitable given your deployment context (e.g., a server-side vulnerability in a client-only app)?
|
|
240
|
+
|
|
241
|
+
When you defer a fix, document the reason and set a review date.
|
|
242
|
+
|
|
243
|
+
## Rate Limiting
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import rateLimit from 'express-rate-limit';
|
|
247
|
+
|
|
248
|
+
// General API rate limit
|
|
249
|
+
app.use('/api/', rateLimit({
|
|
250
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
251
|
+
max: 100, // 100 requests per window
|
|
252
|
+
standardHeaders: true,
|
|
253
|
+
legacyHeaders: false,
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
// Stricter limit for auth endpoints
|
|
257
|
+
app.use('/api/auth/', rateLimit({
|
|
258
|
+
windowMs: 15 * 60 * 1000,
|
|
259
|
+
max: 10, // 10 attempts per 15 minutes
|
|
260
|
+
}));
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Secrets Management
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
.env files:
|
|
267
|
+
├── .env.example → Committed (template with placeholder values)
|
|
268
|
+
├── .env → NOT committed (contains real secrets)
|
|
269
|
+
└── .env.local → NOT committed (local overrides)
|
|
270
|
+
|
|
271
|
+
.gitignore must include:
|
|
272
|
+
.env
|
|
273
|
+
.env.local
|
|
274
|
+
.env.*.local
|
|
275
|
+
*.pem
|
|
276
|
+
*.key
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Always check before committing:**
|
|
280
|
+
```bash
|
|
281
|
+
# Check for accidentally staged secrets
|
|
282
|
+
git diff --cached | grep -i "password\|secret\|api_key\|token"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Security Review Checklist
|
|
286
|
+
|
|
287
|
+
```markdown
|
|
288
|
+
### Authentication
|
|
289
|
+
- [ ] Passwords hashed with bcrypt/scrypt/argon2 (salt rounds ≥ 12)
|
|
290
|
+
- [ ] Session tokens are httpOnly, secure, sameSite
|
|
291
|
+
- [ ] Login has rate limiting
|
|
292
|
+
- [ ] Password reset tokens expire
|
|
293
|
+
|
|
294
|
+
### Authorization
|
|
295
|
+
- [ ] Every endpoint checks user permissions
|
|
296
|
+
- [ ] Users can only access their own resources
|
|
297
|
+
- [ ] Admin actions require admin role verification
|
|
298
|
+
|
|
299
|
+
### Input
|
|
300
|
+
- [ ] All user input validated at the boundary
|
|
301
|
+
- [ ] SQL queries are parameterized
|
|
302
|
+
- [ ] HTML output is encoded/escaped
|
|
303
|
+
|
|
304
|
+
### Data
|
|
305
|
+
- [ ] No secrets in code or version control
|
|
306
|
+
- [ ] Sensitive fields excluded from API responses
|
|
307
|
+
- [ ] PII encrypted at rest (if applicable)
|
|
308
|
+
|
|
309
|
+
### Infrastructure
|
|
310
|
+
- [ ] Security headers configured (CSP, HSTS, etc.)
|
|
311
|
+
- [ ] CORS restricted to known origins
|
|
312
|
+
- [ ] Dependencies audited for vulnerabilities
|
|
313
|
+
- [ ] Error messages don't expose internals
|
|
314
|
+
```
|
|
315
|
+
## See Also
|
|
316
|
+
|
|
317
|
+
For detailed security checklists and pre-commit verification steps, see `references/security-checklist.md`.
|
|
318
|
+
|
|
319
|
+
## Common Rationalizations
|
|
320
|
+
|
|
321
|
+
| Rationalization | Reality |
|
|
322
|
+
|---|---|
|
|
323
|
+
| "This is an internal tool, security doesn't matter" | Internal tools get compromised. Attackers target the weakest link. |
|
|
324
|
+
| "We'll add security later" | Security retrofitting is 10x harder than building it in. Add it now. |
|
|
325
|
+
| "No one would try to exploit this" | Automated scanners will find it. Security by obscurity is not security. |
|
|
326
|
+
| "The framework handles security" | Frameworks provide tools, not guarantees. You still need to use them correctly. |
|
|
327
|
+
| "It's just a prototype" | Prototypes become production. Security habits from day one. |
|
|
328
|
+
|
|
329
|
+
## Red Flags
|
|
330
|
+
|
|
331
|
+
- User input passed directly to database queries, shell commands, or HTML rendering
|
|
332
|
+
- Secrets in source code or commit history
|
|
333
|
+
- API endpoints without authentication or authorization checks
|
|
334
|
+
- Missing CORS configuration or wildcard (`*`) origins
|
|
335
|
+
- No rate limiting on authentication endpoints
|
|
336
|
+
- Stack traces or internal errors exposed to users
|
|
337
|
+
- Dependencies with known critical vulnerabilities
|
|
338
|
+
|
|
339
|
+
## Verification
|
|
340
|
+
|
|
341
|
+
After implementing security-relevant code:
|
|
342
|
+
|
|
343
|
+
- [ ] `npm audit` shows no critical or high vulnerabilities
|
|
344
|
+
- [ ] No secrets in source code or git history
|
|
345
|
+
- [ ] All user input validated at system boundaries
|
|
346
|
+
- [ ] Authentication and authorization checked on every protected endpoint
|
|
347
|
+
- [ ] Security headers present in response (check with browser DevTools)
|
|
348
|
+
- [ ] Error responses don't expose internal details
|
|
349
|
+
- [ ] Rate limiting active on auth endpoints
|
|
@@ -11,6 +11,18 @@ Tạo `specs/main/prd.md`, `specs/main/domain.md`, và `specs/main/sad.md` cho m
|
|
|
11
11
|
|
|
12
12
|
Skill này chỉ tập trung vào **product và architecture level** — những gì có thể extract từ README, docs, config, và kiến trúc tổng thể. Component Index và Feature Index trong prd.md sẽ **để trống** — chúng sẽ được điền bởi `/spec-brownfield-component` và `/spec-brownfield-feature` sau khi scan code chuyên sâu.
|
|
13
13
|
|
|
14
|
+
## Templates
|
|
15
|
+
|
|
16
|
+
Mỗi file output được sinh ra từ template tương ứng — đọc template trước khi điền nội dung:
|
|
17
|
+
|
|
18
|
+
| Output file | Template |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `specs/main/prd.md` | `templates/main/prd-template.md` |
|
|
21
|
+
| `specs/main/domain.md` | `templates/main/domain-template.md` |
|
|
22
|
+
| `specs/main/sad.md` | `templates/main/sad-template.md` |
|
|
23
|
+
|
|
24
|
+
Giữ nguyên cấu trúc section và frontmatter từ template. Điền nội dung thu thập được từ scan và interview vào đúng vị trí.
|
|
25
|
+
|
|
14
26
|
Thông tin không thể detect từ code được đánh dấu nhất quán:
|
|
15
27
|
|
|
16
28
|
```
|
package/skills/spec-sad/SKILL.md
CHANGED
|
@@ -22,7 +22,7 @@ SAD không chứa: feature-level design, business rules, entity details — nh
|
|
|
22
22
|
## When NOT to Use
|
|
23
23
|
|
|
24
24
|
- `prd.md` chưa có nội dung → chạy `/spec-prd` trước
|
|
25
|
-
- Đang muốn thiết kế một feature cụ thể → dùng `/spec-
|
|
25
|
+
- Đang muốn thiết kế một feature cụ thể → dùng `/spec-tech`
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -168,7 +168,7 @@ Thông báo kết quả:
|
|
|
168
168
|
✓ specs/main/sad.md đã được cập nhật (status: draft)
|
|
169
169
|
|
|
170
170
|
Bước tiếp theo:
|
|
171
|
-
- /spec-
|
|
171
|
+
- /spec-new {feature-name} → định nghĩa requirements của từng feature
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
---
|