agent-directives 0.1.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 +385 -0
- package/directives/adaptive-routing.md +361 -0
- package/directives/architecture-boundaries.md +223 -0
- package/directives/codebase-navigation.md +325 -0
- package/directives/context-handoff.md +220 -0
- package/directives/error-memory.md +169 -0
- package/directives/exploration-mode.md +266 -0
- package/directives/session-decisions.md +193 -0
- package/directives/specification-driven-development.md +278 -0
- package/directives/task-framing.md +154 -0
- package/directives/test-driven-development.md +305 -0
- package/directives/type-driven-development.md +173 -0
- package/directives/verification.md +266 -0
- package/directives/workspace-isolation.md +219 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +232 -0
- package/dist/cli.js.map +1 -0
- package/dist/context-audit.d.ts +30 -0
- package/dist/context-audit.d.ts.map +1 -0
- package/dist/context-audit.js +75 -0
- package/dist/context-audit.js.map +1 -0
- package/dist/install.d.ts +18 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +28 -0
- package/dist/install.js.map +1 -0
- package/dist/manifest.d.ts +25 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +29 -0
- package/dist/manifest.js.map +1 -0
- package/dist/prompt.d.ts +3 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +29 -0
- package/dist/prompt.js.map +1 -0
- package/dist/targets.d.ts +10 -0
- package/dist/targets.d.ts.map +1 -0
- package/dist/targets.js +32 -0
- package/dist/targets.js.map +1 -0
- package/manifest.json +387 -0
- package/package.json +74 -0
- package/skills/architecture-boundary-reviewer/SKILL.md +228 -0
- package/skills/code-reviewer/SKILL.md +77 -0
- package/skills/codebase-health-reviewer/SKILL.md +234 -0
- package/skills/harness-hooks-reviewer/SKILL.md +159 -0
- package/skills/implementation-task-planner/SKILL.md +205 -0
- package/skills/mcp-integration-reviewer/SKILL.md +157 -0
- package/skills/product-requirements-writer/SKILL.md +205 -0
- package/skills/production-readiness-reviewer/SKILL.md +240 -0
- package/skills/self-audit/SKILL.md +134 -0
- package/skills/spec-reviewer/SKILL.md +304 -0
- package/skills/subagent-driven-development/SKILL.md +236 -0
- package/skills/systematic-debugging/SKILL.md +313 -0
- package/skills/test-reviewer/SKILL.md +293 -0
- package/templates/AGENTS.md +120 -0
- package/templates/CLAUDE.md +115 -0
- package/templates/copilot-instructions.md +116 -0
- package/templates/decision-log.md +44 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-driven-development
|
|
3
|
+
description: Defines RED/GREEN/REFACTOR expectations for behavior-changing implementation work and bug fixes.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
required: false
|
|
6
|
+
category: testing
|
|
7
|
+
tools:
|
|
8
|
+
- claude
|
|
9
|
+
- copilot
|
|
10
|
+
- codex
|
|
11
|
+
- cursor
|
|
12
|
+
triggers:
|
|
13
|
+
- behavior-change
|
|
14
|
+
- new-feature
|
|
15
|
+
- bug-fix
|
|
16
|
+
- refactor-with-behavior
|
|
17
|
+
routing:
|
|
18
|
+
load: conditional
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Test Driven Development Directive
|
|
22
|
+
|
|
23
|
+
## When to Use
|
|
24
|
+
|
|
25
|
+
Use TDD by default for behavior-changing code:
|
|
26
|
+
|
|
27
|
+
- New features
|
|
28
|
+
- Bug fixes
|
|
29
|
+
- Refactors that intentionally preserve or alter behavior
|
|
30
|
+
- Edge-case patches
|
|
31
|
+
- Review changes that affect runtime behavior
|
|
32
|
+
|
|
33
|
+
TDD is not required for purely mechanical or non-behavioral work selected by
|
|
34
|
+
`directives/adaptive-routing.md`, such as docs-only edits, formatting-only
|
|
35
|
+
changes, generated files, metadata-only updates, or mechanical renames with no
|
|
36
|
+
behavior/API change. Those tasks still need the relevant quality gates.
|
|
37
|
+
|
|
38
|
+
If you are unsure whether a change affects behavior, choose TDD or ask one
|
|
39
|
+
concise clarifying question.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## ⚠️ DEFAULT: Strict RED/GREEN TDD for Behavior Changes
|
|
44
|
+
|
|
45
|
+
For behavior-changing work, follow strict Test-Driven Development. Do not skip
|
|
46
|
+
RED because the change seems obvious.
|
|
47
|
+
|
|
48
|
+
**Requirements:**
|
|
49
|
+
|
|
50
|
+
- One behavior per test
|
|
51
|
+
- Clear descriptive name ("and" in name? Split it)
|
|
52
|
+
- Real code, not mocks (unless truly unavoidable)
|
|
53
|
+
- Name describes behavior, not implementation
|
|
54
|
+
|
|
55
|
+
### The Cycle
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
┌─────────────────────────────────────────────────────┐
|
|
59
|
+
│ │
|
|
60
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
61
|
+
│ │ RED │ ───▶ │ GREEN │ ───▶ │ REFACTOR│ │
|
|
62
|
+
│ │ │ │ │ │ │ │
|
|
63
|
+
│ │ Write │ │ Write │ │ Clean │ │
|
|
64
|
+
│ │ failing │ │ minimum │ │ up code │ │
|
|
65
|
+
│ │ test │ │ code │ │ │ │
|
|
66
|
+
│ └─────────┘ └─────────┘ └─────────┘ │
|
|
67
|
+
│ ▲ │ │
|
|
68
|
+
│ └──────────────────────────────────┘ │
|
|
69
|
+
│ │
|
|
70
|
+
└─────────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## The Rules
|
|
76
|
+
|
|
77
|
+
### Rule 1: No Implementation Without a Failing Test
|
|
78
|
+
|
|
79
|
+
Before writing behavior-changing implementation code:
|
|
80
|
+
|
|
81
|
+
1. Write a test that describes ONE behavior
|
|
82
|
+
2. Load `skills/test-reviewer/SKILL.md` and apply it as the test-quality lens:
|
|
83
|
+
the test should assert observable behavior, use strong assertions, avoid
|
|
84
|
+
implementation mirroring, and cover relevant edge/error cases
|
|
85
|
+
3. Run the test — it MUST fail (RED)
|
|
86
|
+
4. Only then write implementation
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
❌ WRONG: Implement first, test later
|
|
90
|
+
✅ RIGHT: Test fails first, then implement
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Rule 2: Write ONE Test at a Time
|
|
94
|
+
|
|
95
|
+
- Never write multiple tests before implementing
|
|
96
|
+
- Never write tests for multiple methods at once
|
|
97
|
+
- One test = one behavior = one implementation cycle
|
|
98
|
+
|
|
99
|
+
### Rule 3: Write the MINIMUM Code to Pass
|
|
100
|
+
|
|
101
|
+
The GREEN phase is about making the test pass with the least code possible:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// ❌ WRONG: Over-engineering
|
|
105
|
+
export function add(a: number, b: number): number {
|
|
106
|
+
// What if they pass strings? What about overflow? Let me handle all cases...
|
|
107
|
+
if (typeof a !== "number" || typeof b !== "number") {
|
|
108
|
+
throw new TypeError("Arguments must be numbers");
|
|
109
|
+
}
|
|
110
|
+
const result = a + b;
|
|
111
|
+
if (result > Number.MAX_SAFE_INTEGER) {
|
|
112
|
+
console.warn("Potential overflow detected");
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ✅ RIGHT: Minimum to pass the test
|
|
118
|
+
export function add(a: number, b: number): number {
|
|
119
|
+
return a + b;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
If the test doesn't require it, don't implement it. YAGNI (You Aren't Gonna Need It).
|
|
124
|
+
|
|
125
|
+
### Rule 4: Verify Types After GREEN
|
|
126
|
+
|
|
127
|
+
After making a test pass, verify the implementation still satisfies the type contract:
|
|
128
|
+
|
|
129
|
+
Run the project's type-check command (for TypeScript projects, `tsc --noEmit`).
|
|
130
|
+
|
|
131
|
+
If types fail, the implementation is wrong. Fix before continuing.
|
|
132
|
+
|
|
133
|
+
### Rule 5: Never Refactor During GREEN
|
|
134
|
+
|
|
135
|
+
Refactoring happens AFTER the test passes, in a dedicated phase:
|
|
136
|
+
|
|
137
|
+
1. RED — Write failing test
|
|
138
|
+
2. GREEN — Make it pass (may be ugly)
|
|
139
|
+
3. REFACTOR — Clean up while keeping test green
|
|
140
|
+
4. Commit AFTER REFACTOR, not after GREEN
|
|
141
|
+
|
|
142
|
+
Never refactor while the test is still failing. Never refactor while writing new tests.
|
|
143
|
+
|
|
144
|
+
### Rule 6: No Skipping RED
|
|
145
|
+
|
|
146
|
+
You cannot:
|
|
147
|
+
|
|
148
|
+
- Comment out tests to make them "pass"
|
|
149
|
+
- Write tests that always pass
|
|
150
|
+
- Skip the RED phase because "I know what to implement"
|
|
151
|
+
|
|
152
|
+
If the test doesn't fail, the cycle is invalid.
|
|
153
|
+
|
|
154
|
+
### Rule 7: No Retrofitting
|
|
155
|
+
|
|
156
|
+
You cannot:
|
|
157
|
+
|
|
158
|
+
- Write implementation first, then write a test for it, then commit them
|
|
159
|
+
in sequence to create the appearance of TDD
|
|
160
|
+
- Edit implementation and test files in the same editing pass before
|
|
161
|
+
running tests between edits
|
|
162
|
+
- Hold implementation code in context while writing the "failing" test
|
|
163
|
+
|
|
164
|
+
The RED phase must produce genuine discovery. If you already wrote the
|
|
165
|
+
fix, the test is not driving anything — it's theater.
|
|
166
|
+
|
|
167
|
+
**Checkpoint:** After editing ONLY the test file, run the test suite.
|
|
168
|
+
Confirm the new test fails. This failure output is evidence that RED
|
|
169
|
+
happened. Do not open the implementation file until you have seen this
|
|
170
|
+
failure.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## The Workflow
|
|
175
|
+
|
|
176
|
+
### Step-by-Step Process
|
|
177
|
+
|
|
178
|
+
```text
|
|
179
|
+
1. Pick ONE method/behavior to implement
|
|
180
|
+
|
|
181
|
+
2. RED Phase:
|
|
182
|
+
- Write a test for that behavior
|
|
183
|
+
- Review the test with `skills/test-reviewer/SKILL.md` before opening implementation code
|
|
184
|
+
- Run test: MUST fail
|
|
185
|
+
- If it passes, the test is wrong — fix it
|
|
186
|
+
|
|
187
|
+
3. GREEN Phase:
|
|
188
|
+
- Write minimum code to make test pass
|
|
189
|
+
- Run all tests: MUST pass (new test passes, no regressions)
|
|
190
|
+
- Run type check: MUST pass
|
|
191
|
+
|
|
192
|
+
4. REFACTOR Phase (skip only if code is already clean):
|
|
193
|
+
- Clean up implementation
|
|
194
|
+
- Remove duplication
|
|
195
|
+
- Improve readability
|
|
196
|
+
- Extract helpers
|
|
197
|
+
- Simplify expressions
|
|
198
|
+
- Run all tests: MUST still pass
|
|
199
|
+
- Run type check: MUST still pass
|
|
200
|
+
|
|
201
|
+
5. GATES — Run the project's full quality-gate command suite (test, lint, build/type-check). The specific commands depend on the project.
|
|
202
|
+
All must pass. Fix failures before proceeding.
|
|
203
|
+
|
|
204
|
+
6. Commit AFTER GATES, not after GREEN
|
|
205
|
+
|
|
206
|
+
7. Return to step 1 for next behavior
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Examples
|
|
212
|
+
|
|
213
|
+
For a project-specific example, see Rule 7 (no retrofitting) above.
|
|
214
|
+
|
|
215
|
+
## TDD Applies to Fixes and Review Changes Too
|
|
216
|
+
|
|
217
|
+
Bug fixes, review feedback, and edge-case patches are NOT exempt from
|
|
218
|
+
the RED/GREEN cycle. The cycle is the same:
|
|
219
|
+
|
|
220
|
+
1. RED — Write a test that demonstrates the bug or missing edge case
|
|
221
|
+
2. Confirm it fails
|
|
222
|
+
3. GREEN — Write the fix
|
|
223
|
+
4. GATES + COMMIT
|
|
224
|
+
|
|
225
|
+
The temptation to "just fix it" is strongest for small changes. That
|
|
226
|
+
is exactly when discipline matters most — small changes have the
|
|
227
|
+
highest ratio of assumption to verification.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Quality Gates
|
|
232
|
+
|
|
233
|
+
After each RED/GREEN/REFACTOR cycle, ALL of these must pass:
|
|
234
|
+
|
|
235
|
+
Run the project's full quality-gate command suite (test, lint, build/type-check). The specific commands depend on the project.
|
|
236
|
+
|
|
237
|
+
If any fail, the cycle is incomplete. Fix before moving to next test.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Forbidden Patterns
|
|
242
|
+
|
|
243
|
+
| Pattern | Why Forbidden |
|
|
244
|
+
| ----------------------------------- | -------------------------------------- |
|
|
245
|
+
| `it.skip()` | Skipping tests defeats TDD |
|
|
246
|
+
| `// TODO: write test later` | No test = no implementation |
|
|
247
|
+
| Implementing without a failing test | RED must precede GREEN — no exceptions |
|
|
248
|
+
| Copy-pasting tests to pass quickly | Tests must reflect real behavior |
|
|
249
|
+
| `expect(true).toBe(true)` | Fake test, no constraint |
|
|
250
|
+
| Writing test after implementation | That's not TDD |
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## The Commit Cadence
|
|
255
|
+
|
|
256
|
+
Commit AFTER GATES, not after GREEN
|
|
257
|
+
|
|
258
|
+
GREEN means it works. REFACTOR means it's clean. GATES means it's verified. Commit when all three are done.
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
git commit -m "feat: implement UserRepository.findById (found case)"
|
|
262
|
+
git commit -m "feat: implement UserRepository.findById (not found case)"
|
|
263
|
+
git commit -m "feat: implement UserRepository.findById (error handling)"
|
|
264
|
+
git commit -m "refactor: extract query logic in UserRepository"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Small commits = easy to review, easy to revert, easy to understand.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## Verification Checklist
|
|
272
|
+
|
|
273
|
+
Before marking work complete:
|
|
274
|
+
|
|
275
|
+
- [ ] Every behavior-changing function/method has a test
|
|
276
|
+
- [ ] Watched each test fail before implementing
|
|
277
|
+
- [ ] Each test failed for expected reason (feature missing, not typo)
|
|
278
|
+
- [ ] Wrote minimal code to pass each test
|
|
279
|
+
- [ ] All tests pass
|
|
280
|
+
- [ ] Output pristine (no errors, warnings)
|
|
281
|
+
- [ ] Tests use real code (mocks only if unavoidable)
|
|
282
|
+
- [ ] Edge cases and errors covered
|
|
283
|
+
|
|
284
|
+
Can't check all boxes for behavior-changing work? You skipped TDD. Start over.
|
|
285
|
+
|
|
286
|
+
## Quick Reference
|
|
287
|
+
|
|
288
|
+
| Phase | Action | Must Be |
|
|
289
|
+
| -------- | --------------------------------------------- | ------------------------------- |
|
|
290
|
+
| RED | Write test | Failing |
|
|
291
|
+
| GREEN | Write code | Minimum to pass, no regressions |
|
|
292
|
+
| REFACTOR | Clean up | All tests still pass |
|
|
293
|
+
| GATES | Run project quality gates (test, lint, build) | All pass |
|
|
294
|
+
| COMMIT | Atomic commit | One behavior per commit |
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Final Rule
|
|
299
|
+
|
|
300
|
+
```text
|
|
301
|
+
Behavior-changing production code → test exists and failed first
|
|
302
|
+
Otherwise → not TDD
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
No exceptions for behavior-changing work without the user's explicit permission.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: type-driven-development
|
|
3
|
+
description: Requires type and contract definition before implementation in typed projects or public API work.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
required: false
|
|
6
|
+
category: testing
|
|
7
|
+
tools:
|
|
8
|
+
- claude
|
|
9
|
+
- copilot
|
|
10
|
+
- codex
|
|
11
|
+
- cursor
|
|
12
|
+
triggers:
|
|
13
|
+
- types
|
|
14
|
+
- public-api
|
|
15
|
+
- typed-project
|
|
16
|
+
- service-boundary
|
|
17
|
+
routing:
|
|
18
|
+
load: conditional
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Type-First Development Directive
|
|
22
|
+
|
|
23
|
+
**When to load:** Load this directive before defining types for a new feature, module, or service boundary.
|
|
24
|
+
|
|
25
|
+
## ⚠️ MANDATORY: Type-First Development
|
|
26
|
+
|
|
27
|
+
You MUST define types before writing any implementation code. This is non-negotiable.
|
|
28
|
+
|
|
29
|
+
### The Rule
|
|
30
|
+
|
|
31
|
+
**No types = no code.**
|
|
32
|
+
|
|
33
|
+
Before implementing ANY function, class, or module:
|
|
34
|
+
|
|
35
|
+
1. **Check** — Do types/interfaces already exist for what you're building?
|
|
36
|
+
2. **Define** — If not, create type definitions FIRST in a `types.ts` file
|
|
37
|
+
3. **Verify** — Run the project's type-check command (for TypeScript projects, `tsc --noEmit`) to ensure types compile
|
|
38
|
+
4. **Confirm** — If introducing new type contracts with 5+ types or complex generics, ask the user to confirm the contract is correct
|
|
39
|
+
5. **Hand off** — Types are done. Proceed to the test-driven development cycle (RED/GREEN/REFACTOR)
|
|
40
|
+
|
|
41
|
+
### What This Means in Practice
|
|
42
|
+
|
|
43
|
+
#### ❌ WRONG: Implementation First
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// Don't do this
|
|
47
|
+
export function processOrder(order) {
|
|
48
|
+
return {
|
|
49
|
+
id: order.id,
|
|
50
|
+
status: "processed",
|
|
51
|
+
total: order.items.reduce((sum, item) => sum + item.price, 0),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### ✅ RIGHT: Types First
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// Step 1: Define types
|
|
60
|
+
export type OrderItem = {
|
|
61
|
+
productId: string;
|
|
62
|
+
quantity: number;
|
|
63
|
+
price: number;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type Order = {
|
|
67
|
+
id: string;
|
|
68
|
+
items: OrderItem[];
|
|
69
|
+
createdAt: Date;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type ProcessedOrder = {
|
|
73
|
+
id: string;
|
|
74
|
+
status: "processed";
|
|
75
|
+
total: number;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export function processOrder(order: Order): ProcessedOrder;
|
|
79
|
+
|
|
80
|
+
// Implementation comes later via test-driven development
|
|
81
|
+
// Shown here for completeness only:
|
|
82
|
+
export function processOrder(order: Order): ProcessedOrder {
|
|
83
|
+
return {
|
|
84
|
+
id: order.id,
|
|
85
|
+
status: "processed",
|
|
86
|
+
total: order.items.reduce((sum, item) => sum + item.price, 0),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Required Type Elements
|
|
92
|
+
|
|
93
|
+
Always define:
|
|
94
|
+
|
|
95
|
+
1. **Domain types** — The core data structures (User, Order, Post, etc.)
|
|
96
|
+
2. **Input types** — What goes in (UserInsert, OrderCreate, etc.)
|
|
97
|
+
3. **Output types** — What comes out (User, ProcessedOrder, etc.)
|
|
98
|
+
|
|
99
|
+
Define as applicable:
|
|
100
|
+
|
|
101
|
+
4. **Error types** — For operations that can fail (discriminated unions for public APIs)
|
|
102
|
+
5. **Interface contracts** — For services, repositories, or collaborators that need a boundary
|
|
103
|
+
|
|
104
|
+
### Error Handling Pattern
|
|
105
|
+
|
|
106
|
+
Prefer discriminated unions for public APIs and service boundaries:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// For public APIs and service boundaries, prefer discriminated unions:
|
|
110
|
+
type FindUserResult =
|
|
111
|
+
| { success: true; user: User }
|
|
112
|
+
| { success: false; error: "not-found" | "access-denied" };
|
|
113
|
+
|
|
114
|
+
function findUser(id: string): Promise[FindUserResult];
|
|
115
|
+
|
|
116
|
+
// For internal helpers, `| null` is acceptable when the meaning is unambiguous:
|
|
117
|
+
function describeKind(node: Expression): string | null;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Forbidden Patterns
|
|
121
|
+
|
|
122
|
+
| Pattern | Why It's Forbidden |
|
|
123
|
+
| -------------------------------------- | -------------------------------------------- |
|
|
124
|
+
| `any` type | Defeats type safety, infinite solution space |
|
|
125
|
+
| Implicit `any` | Same problem, hidden |
|
|
126
|
+
| `Function` type | Too permissive, no contract |
|
|
127
|
+
| Returning `null` without explicit type | Ambiguous error handling |
|
|
128
|
+
| Throwing without return type change | Hides failure modes |
|
|
129
|
+
|
|
130
|
+
### Quality Gate
|
|
131
|
+
|
|
132
|
+
Before types are considered complete:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Must pass the project's type check
|
|
136
|
+
# For TypeScript projects, example:
|
|
137
|
+
npx tsc --noEmit
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
After implementation (via TDD), all gates must pass:
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
Run the project's full quality-gate command suite (test, lint, build/type-check)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
If any fail, the implementation is incomplete.
|
|
147
|
+
|
|
148
|
+
### When Types Are Complex
|
|
149
|
+
|
|
150
|
+
If a type contract is non-trivial (5+ types, complex unions, generics), present the types to the user BEFORE implementing:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
I've defined the type contract for [feature]. Please confirm this matches your intent:
|
|
154
|
+
|
|
155
|
+
[Show types]
|
|
156
|
+
|
|
157
|
+
Once confirmed, I'll implement against these types.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Quick Reference
|
|
163
|
+
|
|
164
|
+
| Step | Action | Command |
|
|
165
|
+
| ---- | -------------------- | -------------------------------------------------------------------- |
|
|
166
|
+
| 1 | Define types | Create/edit the project's type definitions file (for example, `types.ts`) |
|
|
167
|
+
| 2 | Verify types | Run the project's type-check command (for TypeScript, `npx tsc --noEmit`) |
|
|
168
|
+
| 3 | Confirm (if complex) | Present types to user |
|
|
169
|
+
| 4 | Hand off to TDD | Proceed to the test-driven development cycle (RED/GREEN/REFACTOR) |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
_After types are verified, proceed to test-driven development. Do not implement without tests._
|