moicle 2.3.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -47
- package/assets/commands/marketing.md +6 -6
- package/assets/skills/docs/sync/SKILL.md +195 -157
- package/assets/skills/feature/build/SKILL.md +891 -0
- package/assets/skills/feature/track/SKILL.md +157 -0
- package/assets/skills/fix/bug/SKILL.md +449 -0
- package/assets/skills/fix/incident/SKILL.md +6 -6
- package/assets/skills/marketing/brand/SKILL.md +304 -0
- package/assets/skills/marketing/content/SKILL.md +199 -141
- package/assets/skills/research/explore/SKILL.md +392 -0
- package/assets/skills/review/code/SKILL.md +622 -0
- package/dist/commands/install/usage.js +2 -2
- package/dist/commands/install/usage.js.map +1 -1
- package/package.json +1 -1
- package/assets/skills/docs/write/SKILL.md +0 -274
- package/assets/skills/feature/api/SKILL.md +0 -277
- package/assets/skills/feature/deprecate/SKILL.md +0 -276
- package/assets/skills/feature/new/SKILL.md +0 -273
- package/assets/skills/feature/refactor/SKILL.md +0 -269
- package/assets/skills/fix/hotfix/SKILL.md +0 -233
- package/assets/skills/fix/pr-comment/SKILL.md +0 -186
- package/assets/skills/fix/root-cause/SKILL.md +0 -276
- package/assets/skills/marketing/logo/SKILL.md +0 -252
- package/assets/skills/marketing/seo-blog/SKILL.md +0 -367
- package/assets/skills/marketing/video/SKILL.md +0 -258
- package/assets/skills/research/onboarding/SKILL.md +0 -225
- package/assets/skills/research/spike/SKILL.md +0 -228
- package/assets/skills/research/web/SKILL.md +0 -204
- package/assets/skills/review/architect/SKILL.md +0 -274
- package/assets/skills/review/branch/SKILL.md +0 -277
- package/assets/skills/review/pr/SKILL.md +0 -231
- package/assets/skills/review/tdd/SKILL.md +0 -245
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: review-pr
|
|
3
|
-
description: Thorough pull request review workflow with architecture compliance checks. Use when reviewing pull requests, checking code changes, or when user says "review pr", "check pr", "review code", "pr review", "review pull request".
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Pull Request Review Workflow
|
|
7
|
-
|
|
8
|
-
Review someone else's PR across 5 dimensions and post structured feedback to GitHub.
|
|
9
|
-
|
|
10
|
-
## When to use this skill
|
|
11
|
-
|
|
12
|
-
- ✅ Reviewing someone else's open PR (`gh pr view <number>` accessible)
|
|
13
|
-
- ✅ Need to post structured feedback (APPROVE / REQUEST CHANGES / COMMENT)
|
|
14
|
-
- ✅ Want a multi-dimensional review (architecture + security + perf + tests)
|
|
15
|
-
- ❌ Self-review of own branch before push → use `/review-branch`
|
|
16
|
-
- ❌ Only checking DDD compliance → use `/review-architect`
|
|
17
|
-
- ❌ Addressing comments on your own PR → use `/fix-pr-comment`
|
|
18
|
-
|
|
19
|
-
## Read Architecture First
|
|
20
|
-
|
|
21
|
-
Load `~/.claude/architecture/ddd-architecture.md` + the stack-specific doc. Detect stack via `~/.claude/architecture/_shared/stack-detection.md`.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Workflow
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
FETCH → ANALYZE → REVIEW (5 dims) → FEEDBACK → POST
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Phase 1: FETCH
|
|
34
|
-
|
|
35
|
-
**Goal:** load PR + diff + context in one pass.
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
PR={number}
|
|
39
|
-
gh pr view $PR --json number,title,body,author,state,headRefName,baseRefName,commits,files
|
|
40
|
-
gh pr diff $PR
|
|
41
|
-
gh pr checks $PR
|
|
42
|
-
gh pr view $PR --comments
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Gate
|
|
46
|
-
- [ ] PR metadata + diff + CI status loaded
|
|
47
|
-
- [ ] PR description explains "what / why" — if missing, ask author before deep review
|
|
48
|
-
- [ ] CI status known (don't review red builds — ask author to fix first)
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Phase 2: ANALYZE
|
|
53
|
-
|
|
54
|
-
**Goal:** understand scope before going line-by-line.
|
|
55
|
-
|
|
56
|
-
1. **Scope check**: does the diff match the PR title / description? Mixed-scope PRs (e.g., feature + drive-by refactor) → ask author to split.
|
|
57
|
-
2. **Risk profile**: which files? domain logic, infra config, migrations, auth — high risk vs UI tweak — low risk.
|
|
58
|
-
3. **Test delta**: are new tests in the diff? coverage % up or down?
|
|
59
|
-
4. **Reference module**: open 1 existing similar module to compare conventions.
|
|
60
|
-
|
|
61
|
-
### Gate
|
|
62
|
-
- [ ] PR scope is single-purpose (or split requested)
|
|
63
|
-
- [ ] Risk level identified (low / medium / high)
|
|
64
|
-
- [ ] Test delta noted
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
## Phase 3: REVIEW — 5 dimensions
|
|
69
|
-
|
|
70
|
-
Severity definitions: `~/.claude/architecture/_shared/severity-levels.md` (code severity table).
|
|
71
|
-
|
|
72
|
-
### 3.1 Architecture (CRITICAL / HIGH)
|
|
73
|
-
|
|
74
|
-
For DDD-aware code, check against architecture doc:
|
|
75
|
-
- Domain has zero framework imports
|
|
76
|
-
- No cross-domain imports
|
|
77
|
-
- Business logic in usecases, not handlers / stores
|
|
78
|
-
- Ports in `ports/` dir (not inline interfaces)
|
|
79
|
-
- Entities raise events on state changes
|
|
80
|
-
- Listeners use background context, not request context
|
|
81
|
-
|
|
82
|
-
**For deep DDD audit:** call `/review-architect` instead and link result.
|
|
83
|
-
|
|
84
|
-
### 3.2 Security (CRITICAL / HIGH)
|
|
85
|
-
|
|
86
|
-
- Input validation at trust boundary (handler / DTO)
|
|
87
|
-
- AuthN + AuthZ checked before sensitive ops
|
|
88
|
-
- No secrets / tokens in code or logs
|
|
89
|
-
- SQL via parameterized queries / ORM — no string concatenation
|
|
90
|
-
- File paths / shell commands sanitized
|
|
91
|
-
- Rate limiting + idempotency on state-mutating endpoints
|
|
92
|
-
- Crypto: standard library, no roll-your-own
|
|
93
|
-
|
|
94
|
-
### 3.3 Performance (HIGH / MEDIUM)
|
|
95
|
-
|
|
96
|
-
- No N+1 queries (eager-load relations the handler uses)
|
|
97
|
-
- Indexes match new query patterns (check `EXPLAIN`)
|
|
98
|
-
- Pagination on list endpoints (cursor preferred)
|
|
99
|
-
- Background work for slow operations (don't block request)
|
|
100
|
-
- Caching where appropriate, invalidation thought through
|
|
101
|
-
- Synchronous external API calls have timeouts
|
|
102
|
-
|
|
103
|
-
### 3.4 Testing (HIGH / MEDIUM)
|
|
104
|
-
|
|
105
|
-
- New business logic has unit tests (usecases, entities, value objects)
|
|
106
|
-
- New endpoints have at least 1 integration test (happy + error)
|
|
107
|
-
- Tests assert on behavior, not implementation
|
|
108
|
-
- Tests don't depend on order, time, or env
|
|
109
|
-
- Coverage didn't drop for touched files
|
|
110
|
-
|
|
111
|
-
### 3.5 Code quality (MEDIUM / LOW)
|
|
112
|
-
|
|
113
|
-
- Names reveal intent (no `data`, `info`, `manager`, `helper`)
|
|
114
|
-
- Functions do one thing
|
|
115
|
-
- No dead branches or commented-out code
|
|
116
|
-
- DRY only where the duplication is real (not coincidental)
|
|
117
|
-
- Errors handled at boundary, not swallowed mid-flow
|
|
118
|
-
|
|
119
|
-
---
|
|
120
|
-
|
|
121
|
-
## Phase 4: FEEDBACK
|
|
122
|
-
|
|
123
|
-
**Goal:** turn findings into actionable comments at the right place.
|
|
124
|
-
|
|
125
|
-
### Decision (pick one)
|
|
126
|
-
|
|
127
|
-
| Decision | When |
|
|
128
|
-
|----------|------|
|
|
129
|
-
| **APPROVE** | 0 CRITICAL / HIGH; LOW only |
|
|
130
|
-
| **REQUEST CHANGES** | Any CRITICAL or HIGH; or multiple MEDIUM in same area |
|
|
131
|
-
| **COMMENT** | Only style / nit comments; or asking questions before final review |
|
|
132
|
-
|
|
133
|
-
### Inline comment format
|
|
134
|
-
|
|
135
|
-
Be specific. File + line + rationale + suggested fix:
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
file: internal/wallet/usecases/withdraw.go:42
|
|
139
|
-
severity: HIGH
|
|
140
|
-
issue: Business logic in handler — `if wallet.Balance < amount` should live in
|
|
141
|
-
the Withdraw usecase, not here. The handler should just call usecase and
|
|
142
|
-
return the error.
|
|
143
|
-
suggest:
|
|
144
|
-
// handler
|
|
145
|
-
result, err := s.WithdrawUsecase.Execute(ctx, req)
|
|
146
|
-
|
|
147
|
-
// usecase
|
|
148
|
-
func (u *WithdrawUsecase) Execute(ctx, req) (Result, error) {
|
|
149
|
-
if !wallet.HasSufficientBalance(amount) { return ErrInsufficient }
|
|
150
|
-
// ...
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Summary comment (top of PR)
|
|
155
|
-
|
|
156
|
-
```markdown
|
|
157
|
-
## Review Summary
|
|
158
|
-
**Decision:** REQUEST CHANGES
|
|
159
|
-
|
|
160
|
-
**Must fix (HIGH):**
|
|
161
|
-
- [ ] `withdraw.go:42` — business logic moved out of handler
|
|
162
|
-
- [ ] `withdraw.go:88` — missing input validation on `amount`
|
|
163
|
-
|
|
164
|
-
**Should fix (MEDIUM):**
|
|
165
|
-
- [ ] `withdraw_test.go` — only happy path tested, add insufficient-balance case
|
|
166
|
-
- [ ] `wallet_store.go:120` — N+1 query loading transactions
|
|
167
|
-
|
|
168
|
-
**Nits (LOW):**
|
|
169
|
-
- [ ] `helper.go:5` — rename `helper` to something specific
|
|
170
|
-
|
|
171
|
-
**What looked great:**
|
|
172
|
-
- Clean port interface, good test naming, clear PR description.
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Gate
|
|
176
|
-
- [ ] Decision matches severity rules
|
|
177
|
-
- [ ] Every HIGH+ has file:line + suggested fix
|
|
178
|
-
- [ ] Summary lists must-fix vs should-fix vs nits
|
|
179
|
-
- [ ] Acknowledged what's good (not just criticism)
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## Phase 5: POST
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
# Inline comments (one per finding)
|
|
187
|
-
gh pr review $PR --request-changes --body "$(cat summary.md)"
|
|
188
|
-
# or
|
|
189
|
-
gh pr review $PR --approve --body "LGTM, see one nit"
|
|
190
|
-
# or
|
|
191
|
-
gh pr review $PR --comment --body "Questions before final review"
|
|
192
|
-
|
|
193
|
-
# Optional: label
|
|
194
|
-
gh pr edit $PR --add-label "needs-changes"
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### Gate
|
|
198
|
-
- [ ] Review posted to GitHub
|
|
199
|
-
- [ ] Author has clear next-step list
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Hard Rules
|
|
204
|
-
|
|
205
|
-
- **Don't review red CI** — ask author to fix tests / lint first
|
|
206
|
-
- **Don't bikeshed style** when the team has a linter — let the tool flag it
|
|
207
|
-
- **Always include "what went well"** — pure-criticism reviews demoralize
|
|
208
|
-
- **One severity per finding** — don't grade-inflate to push for a fix
|
|
209
|
-
- **File:line for every HIGH+** — author shouldn't have to grep for what you mean
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
## Related Skills
|
|
214
|
-
|
|
215
|
-
| When | Use |
|
|
216
|
-
|------|-----|
|
|
217
|
-
| Reviewing own branch before push | `/review-branch` |
|
|
218
|
-
| Only checking DDD architecture | `/review-architect` |
|
|
219
|
-
| Fixing comments on your own PR | `/fix-pr-comment` |
|
|
220
|
-
| Bug surfaced by review | `/fix-hotfix` |
|
|
221
|
-
|
|
222
|
-
## Recommended Agents
|
|
223
|
-
|
|
224
|
-
| Phase | Agent | Purpose |
|
|
225
|
-
|-------|-------|---------|
|
|
226
|
-
| ANALYZE | `@clean-architect` | Architecture context |
|
|
227
|
-
| REVIEW 3.1 | `@clean-architect` | Architecture compliance |
|
|
228
|
-
| REVIEW 3.2 | `@security-audit` | Security findings |
|
|
229
|
-
| REVIEW 3.3 | `@perf-optimizer` | N+1, indexes, slow paths |
|
|
230
|
-
| REVIEW 3.4 | `@test-writer` | Coverage + test quality |
|
|
231
|
-
| REVIEW 3.5 | `@code-reviewer` | Naming + quality |
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: review-tdd
|
|
3
|
-
description: Test-Driven Development workflow. Use when doing TDD, writing tests first, or when user says "tdd", "test first", "test driven", "red green refactor".
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Test-Driven Development (TDD) Workflow
|
|
7
|
-
|
|
8
|
-
Red-Green-Refactor cycle: write failing test → write minimal code to pass → refactor while green.
|
|
9
|
-
|
|
10
|
-
## When to use this skill
|
|
11
|
-
|
|
12
|
-
- ✅ Logic with clear input → output behavior (parsers, validators, business rules, usecases)
|
|
13
|
-
- ✅ Fixing a bug — failing test first, then fix (regression guard)
|
|
14
|
-
- ✅ Refactoring critical code where you need a safety net
|
|
15
|
-
- ❌ UI prototyping / visual tweaks → manual is faster
|
|
16
|
-
- ❌ Exploratory spike → use `/research-spike` (throwaway, no tests)
|
|
17
|
-
- ❌ One-line config change → just change it
|
|
18
|
-
|
|
19
|
-
## Read Architecture First
|
|
20
|
-
|
|
21
|
-
Detect stack via `~/.claude/architecture/_shared/stack-detection.md`. Architecture doc tells you:
|
|
22
|
-
- Test file location convention (`_test.go` next to source, `__tests__/`, `tests/Feature/`, etc.)
|
|
23
|
-
- Test framework (Go `testing`, Jest, Pest, `flutter_test`)
|
|
24
|
-
- Mocking pattern for ports
|
|
25
|
-
- AAA layout convention
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## The TDD Cycle
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
┌──────┐ ┌───────┐ ┌──────────┐
|
|
33
|
-
┌──▶│ RED │───▶│ GREEN │───▶│ REFACTOR │──┐
|
|
34
|
-
│ └──────┘ └───────┘ └──────────┘ │
|
|
35
|
-
│ (fail) (minimal) (cleanup) │
|
|
36
|
-
└──────────────────────────────────────────┘
|
|
37
|
-
next requirement
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Phase 1: RED — failing test
|
|
43
|
-
|
|
44
|
-
**Goal:** describe wanted behavior with a test that fails because the code doesn't exist yet.
|
|
45
|
-
|
|
46
|
-
### Steps
|
|
47
|
-
1. Pick ONE small requirement (smallest verifiable behavior)
|
|
48
|
-
2. Name the test as a sentence describing behavior
|
|
49
|
-
3. Arrange: inputs + mocks
|
|
50
|
-
4. Act: call the method
|
|
51
|
-
5. Assert: verify output / state / interaction
|
|
52
|
-
6. Run — it MUST fail (compile error or assertion fail). If it passes, the test is wrong.
|
|
53
|
-
|
|
54
|
-
### Test naming
|
|
55
|
-
- `should_<behavior>_when_<condition>` (snake_case for Go / Python)
|
|
56
|
-
- `it("returns X when Y", ...)` (Jest / Mocha)
|
|
57
|
-
- `test_<behavior>_<condition>` (PHPUnit / Pest)
|
|
58
|
-
|
|
59
|
-
### AAA pattern
|
|
60
|
-
```
|
|
61
|
-
// Arrange — set up inputs and mocks
|
|
62
|
-
// Act — call function under test
|
|
63
|
-
// Assert — verify result / state / interactions
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Gate
|
|
67
|
-
- [ ] Test fails for the RIGHT reason (not a typo / missing import)
|
|
68
|
-
- [ ] Name describes behavior, not implementation
|
|
69
|
-
- [ ] One behavior per test
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Phase 2: GREEN — minimal code to pass
|
|
74
|
-
|
|
75
|
-
**Goal:** smallest amount of code to pass. **Resist** "doing it properly" — refactor is next.
|
|
76
|
-
|
|
77
|
-
### Rules
|
|
78
|
-
- **Minimal** means: hardcode return values if the test allows it; triangulate with more tests
|
|
79
|
-
- Don't add code not required by a test
|
|
80
|
-
- Don't add error handling unless a test requires it
|
|
81
|
-
- Don't generalize until 3+ tests force it
|
|
82
|
-
|
|
83
|
-
### Steps
|
|
84
|
-
1. Confirm RED
|
|
85
|
-
2. Write just enough code to pass
|
|
86
|
-
3. Run all tests — all must stay green
|
|
87
|
-
4. If others broke, you're not minimal — revert + try smaller
|
|
88
|
-
|
|
89
|
-
### Gate
|
|
90
|
-
- [ ] New test passes
|
|
91
|
-
- [ ] All previous tests still pass
|
|
92
|
-
- [ ] No untested behavior added
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## Phase 3: REFACTOR — clean up while green
|
|
97
|
-
|
|
98
|
-
**Goal:** improve structure without changing behavior. Tests stay green throughout.
|
|
99
|
-
|
|
100
|
-
### What to refactor
|
|
101
|
-
- **Duplication** — extract function / method / class
|
|
102
|
-
- **Long methods** — split when one does multiple things
|
|
103
|
-
- **Bad names** — rename to reveal intent (the most underrated refactor)
|
|
104
|
-
- **Dead branches** — remove code no test exercises
|
|
105
|
-
- **Coupling** — break dependencies that make tests painful
|
|
106
|
-
|
|
107
|
-
### Rules
|
|
108
|
-
- **Run tests after every change** — green is your safety net
|
|
109
|
-
- **One refactor at a time** — extract method, run tests, rename, run tests, …
|
|
110
|
-
- **No new behavior** — if a refactor needs a new test, go back to RED
|
|
111
|
-
|
|
112
|
-
### When NOT to refactor
|
|
113
|
-
- Tests are flaky → fix flakiness first
|
|
114
|
-
- Under time pressure → skip, leave a `// TODO: refactor` linked to a follow-up
|
|
115
|
-
- Code about to be deleted → don't polish trash
|
|
116
|
-
|
|
117
|
-
### Gate
|
|
118
|
-
- [ ] All tests still green
|
|
119
|
-
- [ ] No new public API added
|
|
120
|
-
- [ ] Code easier to read than before
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Test patterns per layer (DDD)
|
|
125
|
-
|
|
126
|
-
| Layer | Test type | Dependencies | Example |
|
|
127
|
-
|-------|-----------|--------------|---------|
|
|
128
|
-
| Value Object | Unit (pure) | None | `Money.add()` |
|
|
129
|
-
| Entity | Unit (pure) | None | `Order.cancel()` raises event |
|
|
130
|
-
| UseCase | Unit | Mock ports | `CreateOrder` calls `OrderStore.save()` |
|
|
131
|
-
| Service | Unit | Mock usecase | Delegates correctly |
|
|
132
|
-
| Handler / Controller | Integration | Real router, mock service | `POST /orders` returns 201 |
|
|
133
|
-
| Infrastructure | Integration | Real DB / testcontainers | `OrderRepository.save()` persists |
|
|
134
|
-
| Listener | Unit | Mock infra | `on_order_created` sends email |
|
|
135
|
-
| API contract (cross-service) | Contract test | Real / sandboxed external | OpenAPI / Pact / Wiremock |
|
|
136
|
-
|
|
137
|
-
### Mock vs real — decision table
|
|
138
|
-
|
|
139
|
-
| Dependency type | Use real | Use stub / fake | Use mock |
|
|
140
|
-
|-----------------|----------|-----------------|----------|
|
|
141
|
-
| Value objects, entities (pure) | ✅ always | — | never (brittle) |
|
|
142
|
-
| Stdlib (time, fs, env) | mostly — use clock / fs abstraction in domain | for determinism | rarely |
|
|
143
|
-
| Repository / port | testcontainers in infra tests | in-memory fake for usecase tests | only when verifying call args |
|
|
144
|
-
| External HTTP API | sandbox URL in integration | wiremock / msw for predictable cases | for failure-mode tests |
|
|
145
|
-
| Auth / session | real in integration | fake user in unit | rarely |
|
|
146
|
-
| Time | clock abstraction | fixed clock in tests | rarely |
|
|
147
|
-
|
|
148
|
-
**Stub vs fake vs mock:**
|
|
149
|
-
- **Stub** — returns canned values (`returnsBalance(100)`)
|
|
150
|
-
- **Fake** — working in-memory implementation (`InMemoryOrderStore`)
|
|
151
|
-
- **Mock** — records calls + verifies them (`expect(store.save).toHaveBeenCalledWith(...)`)
|
|
152
|
-
|
|
153
|
-
Prefer **fake** for repository tests (closest to real behavior). Use **mock** only when call args are the assertion.
|
|
154
|
-
|
|
155
|
-
### Property-based testing
|
|
156
|
-
|
|
157
|
-
For pure logic with many edge cases (parsers, math, encoders), use property-based tests:
|
|
158
|
-
|
|
159
|
-
- Go: `testing/quick`, `gopter`
|
|
160
|
-
- TS / JS: `fast-check`
|
|
161
|
-
- Python: `hypothesis`
|
|
162
|
-
- Dart: `glados`
|
|
163
|
-
|
|
164
|
-
Pattern: "for all valid input X, property P holds." Generates 100s of cases including edge cases you wouldn't think of.
|
|
165
|
-
|
|
166
|
-
Example (TS, fast-check):
|
|
167
|
-
```ts
|
|
168
|
-
test("reverse twice = identity", () => {
|
|
169
|
-
fc.assert(fc.property(fc.array(fc.string()), (arr) => {
|
|
170
|
-
expect(reverse(reverse(arr))).toEqual(arr);
|
|
171
|
-
}));
|
|
172
|
-
});
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Use it for: serializers, parsers, math, sorting, encoding/decoding. Not for: business workflows.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## Common Mistakes
|
|
180
|
-
|
|
181
|
-
| Mistake | Why it's bad | Fix |
|
|
182
|
-
|---------|--------------|-----|
|
|
183
|
-
| Writing tests AFTER the code | Tests what's written, not what's needed | Always RED first |
|
|
184
|
-
| Testing implementation, not behavior | Refactor breaks tests | Assert outputs / observable state |
|
|
185
|
-
| One test, many behaviors | Failure message unclear | One behavior per test |
|
|
186
|
-
| Mocking value objects | Brittle, no benefit | Use real — they're pure |
|
|
187
|
-
| Skipping REFACTOR | Tech debt accumulates | It's a phase, not optional |
|
|
188
|
-
| Test depends on order | Flaky | Each test sets up its own state |
|
|
189
|
-
| Slow tests (>1s each) | People stop running them | Move to integration tier; keep unit <100ms |
|
|
190
|
-
| 100% coverage chase | Forces tests for trivial code | Aim for high-value coverage on domain |
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## Final Report
|
|
195
|
-
|
|
196
|
-
```markdown
|
|
197
|
-
## TDD Cycle Complete: {feature}
|
|
198
|
-
|
|
199
|
-
### Cycles
|
|
200
|
-
| # | RED (behavior) | GREEN (code added) | REFACTOR |
|
|
201
|
-
|---|----------------|--------------------|----------|
|
|
202
|
-
| 1 | rejects negative amount | guard in constructor | extracted validator |
|
|
203
|
-
| 2 | transitions PENDING → ACTIVE | added transition method | — |
|
|
204
|
-
|
|
205
|
-
### Test Coverage
|
|
206
|
-
- {N} tests, all passing
|
|
207
|
-
- Domain coverage: {%} (target ≥80%)
|
|
208
|
-
|
|
209
|
-
### Files
|
|
210
|
-
- Tests: {paths}
|
|
211
|
-
- Code: {paths}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
## Hard Rules
|
|
217
|
-
|
|
218
|
-
- **RED first, always** — no production code without a failing test driving it
|
|
219
|
-
- **Minimal GREEN** — hardcode if test allows; triangulate later
|
|
220
|
-
- **REFACTOR is a phase, not optional**
|
|
221
|
-
- **All tests green at all times** (except briefly during RED)
|
|
222
|
-
- **One behavior per test**, named after the behavior
|
|
223
|
-
- **Unit tests <100ms each** — slow tests don't get run
|
|
224
|
-
- **Test behavior, not implementation** — refactor must not break tests
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
## Related Skills
|
|
229
|
-
|
|
230
|
-
| When | Use |
|
|
231
|
-
|------|-----|
|
|
232
|
-
| Building feature from scratch (with TDD inside) | `/feature-new` + this skill |
|
|
233
|
-
| Adding regression test for a bug | `/fix-hotfix` or `/fix-root-cause` → then this skill |
|
|
234
|
-
| Refactoring untested legacy code | `/feature-refactor` (add tests first) |
|
|
235
|
-
| Reviewing test quality on a PR | `/review-pr` |
|
|
236
|
-
|
|
237
|
-
## Recommended Agents
|
|
238
|
-
|
|
239
|
-
| Phase | Agent | Purpose |
|
|
240
|
-
|-------|-------|---------|
|
|
241
|
-
| RED | `@test-writer` | Failing tests first |
|
|
242
|
-
| GREEN | Stack-specific dev agent | Minimal implementation |
|
|
243
|
-
| REFACTOR | `@refactor` | Patterns + cleanup |
|
|
244
|
-
| REFACTOR | `@code-reviewer` | Review refactored code |
|
|
245
|
-
| REFACTOR | `@perf-optimizer` | Perf tweaks (only with benchmarks) |
|