@tianhai/pi-workflow-kit 0.17.1 → 1.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.
Files changed (67) hide show
  1. package/README.md +91 -64
  2. package/agents/pwk-hazard-reviewer.md +24 -0
  3. package/agents/pwk-smell-reviewer.md +17 -0
  4. package/agents/pwk-spec-reviewer.md +14 -0
  5. package/agents/pwk-tracing-reviewer.md +14 -0
  6. package/docs/developer-usage-guide.md +49 -37
  7. package/docs/lessons.md +13 -0
  8. package/docs/oversight-model.md +19 -9
  9. package/docs/workflow-phases.md +58 -29
  10. package/extensions/workflow-guard.ts +190 -91
  11. package/package.json +19 -3
  12. package/skills/pwk-brainstorming/SKILL.md +60 -0
  13. package/skills/pwk-code-review/SKILL.md +46 -0
  14. package/skills/{diagnose → pwk-diagnose}/SKILL.md +3 -2
  15. package/skills/pwk-executing-tasks/SKILL.md +154 -0
  16. package/skills/pwk-finalizing/SKILL.md +78 -0
  17. package/skills/pwk-status/SKILL.md +28 -0
  18. package/skills/pwk-writing-plans/SKILL.md +83 -0
  19. package/docs/plans/2026-06-03-karpathy-guidelines-ab-comparison.md +0 -166
  20. package/docs/plans/completed/2026-04-11-checkpoint-review-gates-design.md +0 -50
  21. package/docs/plans/completed/2026-04-11-checkpoint-review-gates-implementation.md +0 -98
  22. package/docs/plans/completed/2026-04-11-finalizing-merge-options-design.md +0 -33
  23. package/docs/plans/completed/2026-04-11-finalizing-merge-options-implementation.md +0 -75
  24. package/docs/plans/completed/2026-04-11-workspace-setup-design.md +0 -28
  25. package/docs/plans/completed/2026-04-11-workspace-setup-implementation.md +0 -57
  26. package/docs/plans/completed/2026-04-15-bash-guard-design.md +0 -39
  27. package/docs/plans/completed/2026-04-15-bash-guard-implementation.md +0 -229
  28. package/docs/plans/completed/2026-04-21-workflow-guard-safe-commands-design.md +0 -172
  29. package/docs/plans/completed/2026-04-21-workflow-guard-safe-commands-implementation.md +0 -168
  30. package/docs/plans/completed/2026-04-22-go-readonly-safe-commands-implementation.md +0 -54
  31. package/docs/plans/completed/2026-04-28-executing-tasks-redesign-design.md +0 -171
  32. package/docs/plans/completed/2026-04-28-executing-tasks-redesign-implementation.md +0 -208
  33. package/docs/plans/completed/2026-04-28-executing-tasks-redesign-progress.md +0 -14
  34. package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-design.md +0 -154
  35. package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-implementation.md +0 -315
  36. package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-progress.md +0 -15
  37. package/docs/plans/completed/2026-05-08-checkpoint-gates-design.md +0 -235
  38. package/docs/plans/completed/2026-05-08-checkpoint-gates-implementation.md +0 -83
  39. package/docs/plans/completed/2026-05-08-checkpoint-gates-progress.md +0 -11
  40. package/docs/plans/completed/2026-05-08-lessons-learned-design.md +0 -76
  41. package/docs/plans/completed/2026-05-08-lessons-learned-implementation.md +0 -219
  42. package/docs/plans/completed/2026-05-08-lessons-learned-progress.md +0 -15
  43. package/docs/plans/completed/2026-05-08-migrate-earendil-works-design.md +0 -39
  44. package/docs/plans/completed/2026-05-08-migrate-earendil-works-implementation.md +0 -45
  45. package/docs/plans/completed/2026-05-08-migrate-earendil-works-progress.md +0 -10
  46. package/docs/plans/completed/2026-05-08-worktree-handoff-design.md +0 -118
  47. package/docs/plans/completed/2026-05-08-worktree-handoff-implementation.md +0 -140
  48. package/docs/plans/completed/2026-05-08-worktree-handoff-progress.md +0 -10
  49. package/docs/plans/completed/2026-05-20-generic-lessons-design.md +0 -70
  50. package/docs/plans/completed/2026-05-20-generic-lessons-implementation.md +0 -114
  51. package/docs/plans/completed/2026-05-20-generic-lessons-progress.md +0 -11
  52. package/docs/plans/completed/2026-05-22-agentic-agile-enhancements-design.md +0 -77
  53. package/docs/plans/completed/2026-05-22-agentic-agile-enhancements-implementation.md +0 -473
  54. package/docs/plans/completed/2026-05-25-design-review-split-implementation.md +0 -622
  55. package/docs/plans/completed/2026-05-25-design-review-split-progress.md +0 -16
  56. package/docs/plans/completed/2026-05-25-pr5-improvements-implementation.md +0 -273
  57. package/docs/plans/completed/2026-05-25-pr5-improvements-progress.md +0 -17
  58. package/docs/plans/completed/2026-06-03-add-verify-skill-design.md +0 -51
  59. package/docs/plans/completed/2026-06-03-add-verify-skill-implementation.md +0 -111
  60. package/docs/plans/completed/2026-06-03-add-verify-skill-progress.md +0 -11
  61. package/docs/plans/completed/2026-06-03-verify-skill-design.md +0 -176
  62. package/skills/brainstorming/SKILL.md +0 -48
  63. package/skills/design-review/SKILL.md +0 -113
  64. package/skills/executing-tasks/SKILL.md +0 -350
  65. package/skills/finalizing/SKILL.md +0 -119
  66. package/skills/verify/SKILL.md +0 -170
  67. package/skills/writing-plans/SKILL.md +0 -343
@@ -1,170 +0,0 @@
1
- ---
2
- name: verify
3
- description: "Post-implementation code verification with three expert review passes — security, optimization, and traceability. Use after executing-tasks and before finalizing to catch issues that pass tests but break in production. Runs the 'last prompt' pattern: adversarial security review, dead code and duplication audit, and end-to-end contract verification across every layer. Use this skill whenever the user says 'verify', 'review the code', 'check for issues', 'security review', 'the last prompt', 'audit', or when code has been implemented and needs a quality gate before shipping."
4
- ---
5
-
6
- # Verify
7
-
8
- Three expert review passes over the implemented codebase. Read-only — you **may** write the verification report to `docs/plans/`, but you **may not** modify source code.
9
-
10
- The core insight: code that passes tests is not code that's ready. Working code can have security holes, dead branches, duplicated logic, and broken contracts between layers — especially when AI generates across many files without maintaining a single mental model of the whole system. This skill catches what tests miss.
11
-
12
- ## Process
13
-
14
- 1. **Check what's been done** — run `git log --oneline` and `git diff --stat` to understand the scope of recent changes. If nothing has been implemented, say "No code changes found. Run `/skill:executing-tasks` first." and stop.
15
-
16
- 2. **Identify the project's layers** — before reviewing, map the codebase's architecture. Look for layer boundaries: UI/handlers/routes → services/business logic → repositories/data access → database/models. Note the patterns: does the project use controllers, handlers, or routes? Services or use cases? Repositories or DAOs? This map drives the traceability pass.
17
-
18
- 3. **Run three expert review passes** — each pass adopts a distinct adversarial framing. Do them sequentially. For each pass, read the relevant code deeply — don't skim. Then write findings.
19
-
20
- 4. **Compile the report** — write all findings to `docs/plans/*-verification-report.md`. Present the report to the user and wait for feedback.
21
-
22
- 5. **Offer to create a remediation plan** — after the report, ask: "Want me to create a fix plan from these findings? Run `/skill:writing-plans` to turn the task list into executable tasks."
23
-
24
- ## Pass 1 — Security Review 🔴
25
-
26
- **Framing:** A junior developer wrote this code. Now the best security expert on the team is reviewing it — adversarial, suspicious of everything. Trust nothing.
27
-
28
- **What to look for:**
29
-
30
- - **Input validation** — every external input (HTTP params, form data, headers, query strings, environment variables) must be validated and sanitized. Unvalidated input is a critical finding.
31
- - **Authentication & authorization** — every endpoint that handles user data must have auth checks. Are there endpoints that skip auth? Can one user access another user's data by changing an ID?
32
- - **Injection** — SQL queries built by string concatenation, unsanitized shell commands, template injection, XSS in HTML output. Any raw variable interpolated into a query or command is critical.
33
- - **Secrets** — API keys, passwords, tokens hardcoded in source files. Check environment variable loading — are defaults set to empty or to actual secrets?
34
- - **Data exposure** — are sensitive fields (passwords, tokens, PII) logged, returned in API responses, or stored unencrypted?
35
- - **Dependency risks** — known-vulnerable packages (if `package.json`/`go.mod`/`requirements.txt` is present).
36
-
37
- **Severity classification:**
38
-
39
- | Severity | Definition |
40
- |----------|-----------|
41
- | Critical | Exploitable right now — auth bypass, injection, data leak |
42
- | High | Likely exploitable — missing validation on sensitive endpoint, weak auth |
43
- | Medium | Harder to exploit but real risk — verbose error messages leaking internals, missing rate limits |
44
- | Low | Best practice violations — missing CSP headers, no HSTS, long session timeouts |
45
-
46
- ## Pass 2 — Optimization Review 🟡
47
-
48
- **Framing:** A code quality expert looking for waste — things that make the codebase harder to maintain, slower to run, or more confusing than necessary.
49
-
50
- **What to look for:**
51
-
52
- - **Dead code** — functions, methods, types, or exports that are never called anywhere in the codebase. Search for definitions and verify they have callers.
53
- - **Duplication** — the same logic implemented in slightly different ways across multiple files. AI-generated code is especially prone to this — if context was lost between sessions, the AI solved the same sub-problem differently in two places. Flag each pair with file paths and line numbers.
54
- - **Over-engineering** — abstractions, interfaces, or layers that add complexity without earning their keep (only one implementation, no real variation across the seam).
55
- - **Under-engineering** — god functions, 200-line blocks, deeply nested conditionals that should be extracted.
56
- - **Performance concerns** — N+1 queries, unbounded loops, unnecessary copies of large data structures, missing pagination on list endpoints.
57
-
58
- **Priority classification:**
59
-
60
- | Priority | Definition |
61
- |----------|-----------|
62
- | P0 | Dead code in a critical path or duplicated logic that will diverge |
63
- | P1 | Significant duplication or over-engineering that increases maintenance cost |
64
- | P2 | Minor cleanups — long functions, missing pagination, style inconsistencies |
65
-
66
- ## Pass 3 — Traceability Review 🔵
67
-
68
- **Framing:** An integration expert tracing every user-facing action end-to-end — from UI to database and back. The AI generates code file-by-file, and the seams between files are where bugs hide.
69
-
70
- **What to look for:**
71
-
72
- 1. **Map every entry point** — list all handlers, routes, controllers, or event listeners that receive external input.
73
- 2. **Trace each call chain** — for each entry point, follow the call: handler → service → repository → database. At each boundary, verify:
74
- - **Function name** — does the caller use the exact function name the callee exposes?
75
- - **Argument names** — does the caller pass `userId` when the function expects `user_id`? Does `id` mean the same thing in both layers?
76
- - **Argument types** — is a string passed where an integer is expected? Is an object shape different from what the next layer destructures?
77
- - **Return shape** — does the caller expect fields that the callee actually returns? Are response DTOs consistent across layers?
78
- 3. **Check error propagation** — when a database query returns no results, does the service layer handle it? Does the handler return 404 or 500? Do errors propagate cleanly or get swallowed silently?
79
- 4. **Verify the round-trip** — if the UI calls `getUser(id)` and displays `user.name`, trace that `name` actually exists in the DB schema, gets selected by the query, mapped by the repository, passed through the service, included in the response, and rendered by the UI.
80
-
81
- **This is the pass that catches the most bugs.** AI-generated code will often have a frontend calling `getUserProfile(userId)` and a backend exposing `get_user_profile(user_id)` — both work in isolation, neither works together.
82
-
83
- **Severity classification:**
84
-
85
- | Severity | Definition |
86
- |----------|-----------|
87
- | Critical | Call chain is completely broken — function doesn't exist or signature is fundamentally wrong |
88
- | High | Signature mismatch — wrong arg names, wrong types, missing required fields |
89
- | Medium | Silent error handling — errors swallowed without logging or user feedback |
90
- | Low | Inconsistent naming conventions that could confuse future developers |
91
-
92
- ## Report Format
93
-
94
- Write findings to `docs/plans/*-verification-report.md` using this structure:
95
-
96
- ```markdown
97
- # Verification Report: <feature/topic>
98
-
99
- **Date:** <ISO date>
100
- **Scope:** <summary of what was reviewed>
101
- **Reviewer:** AI verify skill (security + optimization + traceability)
102
-
103
- ## Summary
104
-
105
- | Pass | Critical | High | Medium | Low |
106
- |------|----------|------|--------|-----|
107
- | Security | X | X | X | X |
108
- | Optimization | — | X | X | X |
109
- | Traceability | X | X | X | X |
110
- | **Total** | **X** | **X** | **X** | **X** |
111
-
112
- ## 🔴 Security Findings
113
-
114
- ### [S-001] Critical — <short title>
115
-
116
- **Location:** `path/to/file.ts:line`
117
-
118
- **Issue:** <what's wrong and why it matters>
119
-
120
- **Fix:** <concrete remediation step>
121
-
122
- ### [S-002] High — <short title>
123
- ...
124
-
125
- ## 🟡 Optimization Findings
126
-
127
- ### [O-001] P0 — <short title>
128
-
129
- **Location:** `path/to/file.ts:line` and `path/to/other.ts:line`
130
-
131
- **Issue:** <what's wrong>
132
-
133
- **Fix:** <concrete remediation step>
134
-
135
- ### [O-002] P1 — <short title>
136
- ...
137
-
138
- ## 🔵 Traceability Findings
139
-
140
- ### [T-001] Critical — <short title>
141
-
142
- **Entry point:** `path/to/handler.ts:line`
143
- **Call chain:** handler → service → repository → DB
144
- **Broken at:** <which boundary>
145
- **Issue:** <what's wrong — e.g., handler passes `userId` but service expects `user_id`>
146
-
147
- **Fix:** <concrete remediation step>
148
-
149
- ### [T-002] High — <short title>
150
- ...
151
-
152
- ## Remediation Task List
153
-
154
- Convert findings into actionable tasks:
155
-
156
- | ID | Priority | Finding | Estimated Effort |
157
- |----|----------|---------|-----------------|
158
- | S-001 | Critical | <one-liner> | <small/medium/large> |
159
- | T-001 | Critical | <one-liner> | <small/medium/large> |
160
- | O-001 | P0 | <one-liner> | <small/medium/large> |
161
- | ...
162
- ```
163
-
164
- ## Principles
165
-
166
- - **Be specific** — every finding must include a file path and line reference. "There might be security issues" is useless.
167
- - **Be adversarial** — actively look for problems. If you don't find any, say so — but don't phone it in.
168
- - **Be proportional** — a small config change doesn't need the same depth as a new API endpoint. Adjust your review depth to the scope of changes.
169
- - **Don't fix anything** — this is read-only. Find and report. The user decides what to fix and when.
170
- - **Focus on seams** — the traceability pass is where the most value lives. Code within a single file is usually coherent; the bugs hide between files.
@@ -1,343 +0,0 @@
1
- ---
2
- name: writing-plans
3
- description: "Use this to break a design into an implementation plan with bite-sized TDD tasks. Works with or without a prior brainstorm. Use this skill when the user says 'let's plan', 'break this down', 'write a plan', 'create tasks', or after a brainstorm session when they want to move to implementation. Also use when the user has a clear idea and wants to jump straight to a structured plan."
4
- ---
5
-
6
- # Writing Plans
7
-
8
- You may only create or edit files under `docs/plans/`. Do not modify source code or configuration.
9
-
10
- ## Process
11
-
12
- 1. **Check for a design doc** — look for `docs/plans/*-design.md`. If one exists, use it as the basis for the plan. If the design doc is incomplete, fill gaps by asking the human. If no design doc exists, ask the user to describe what they want to build and read relevant code. **Read `docs/lessons.md`** if it exists — incorporate known patterns into the task breakdown (e.g., if a lesson says "always run lint before commit," include that in relevant task instructions).
13
-
14
- Then evaluate whether the design — whether from the design doc or from the user's description and codebase exploration — involves any of the following:
15
-
16
- - Database schema changes or migrations
17
- - Authentication or authorization logic
18
- - External API or service integrations
19
- - Concurrency or batch processing
20
- - File uploads or large data flows
21
- - Redis, caching, or message queues
22
-
23
- If any apply AND the design doc does not already have an `## Architectural Review` section, prompt the user: "This design involves [list what you found] but hasn't been reviewed for production risks. Run `/skill:design-review` first, or type 'proceed' to skip."
24
-
25
- If the design doc explicitly notes "Simple change — no design review needed", skip this check.
26
- 2. **Write the implementation plan** — break the design into tasks. Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`. If the design is too large for ~15 tasks, flag this to the human and ask whether to reduce scope or proceed with the full plan.
27
- 3. **Present the plan** — show the complete plan to the human. Wait for approval before suggesting execution.
28
-
29
- Before presenting, run the **Plan Acceptance Audit**:
30
- - **Vertical Slices**: Is every task a complete vertical slice (not horizontal)?
31
- - **Task Sizing**: Is any single task too large or covering multiple complex behaviors? If so, split it.
32
- - **QA Coverage**: Does every task have both a Happy Path and at least one Edge Case in its Acceptance Criteria?
33
- - **Checkpoint Alignment**: Are `checkpoint: test` and `checkpoint: done` gates placed on the most critical or risky tasks?
34
- - **Risk Enforcement**: If the design doc's Architectural Review section flagged any hazards as `[TRIGGERED]`, verify the corresponding tasks have `checkpoint: done` and a `Hazard Mitigation Verification` section.
35
-
36
- If any check fails, fix the plan before presenting.
37
-
38
- ## Task format
39
-
40
- Each task should produce one testable change. The executing-tasks skill handles committing — do not include `git commit` in the task body.
41
-
42
- Each task must include:
43
- - Exact file paths to create/modify
44
- - **Acceptance Criteria (QA Engineer Hat)** — Put on your **QA Engineer Hat** to design exhaustive test coverage. Explicitly define:
45
- - **Happy Path**: Expected behavior under normal operations.
46
- - **Edge Cases & Error Paths**: What happens with empty inputs, limits exceeded, authentication failures, or error states.
47
- Ensure every criteria block specifies the expected state and returned results using `Given/When/Then` behavioral blocks.
48
- - **Concrete code** — include the actual implementation, not a summary. Write out SQL schemas, type definitions, function signatures with bodies, route handler code, and test assertions. A developer should be able to copy-paste from the plan and have working code. For tasks that depend on types or utilities from earlier tasks, reference them explicitly (e.g., `import { User } from Task 2`) and include only the new code
49
- - Exact commands with expected output (e.g., `npx vitest run src/user/model.test.ts` → shows 1 test passing)
50
-
51
- Each task must use a numbered heading with optional metadata comments:
52
-
53
- ```markdown
54
- ## Task N: <description>
55
-
56
- <!-- tdd: new-feature -->
57
- ```
58
-
59
- ...where N starts at 1 and incrementally numbers each task in the plan.
60
-
61
- The metadata comments (placed right after the heading) are optional. If omitted, the executing-tasks skill infers the TDD scenario and checkpoint from context. When in doubt, include them explicitly.
62
-
63
- Valid TDD values: `new-feature`, `modifying-tested-code`, `trivial`
64
-
65
- Valid checkpoint values: `none`, `test`, `done`
66
-
67
- ### Level of detail
68
-
69
- This is the #1 thing to get right. The plan is not a high-level outline — it's a detailed recipe that the executing-tasks skill will follow step by step. If you write "implement login handler" without showing the code, the executing agent has to guess, and that defeats the purpose of the plan.
70
-
71
- Think of it this way: the plan author (you, now) has the full design context, the domain model, and the architecture in mind. The plan executor (a future agent session) will have none of that context — just the plan file. Write accordingly.
72
-
73
- **What "concrete code" means in practice:**
74
- - SQL: `CREATE TABLE` statements with all columns, types, and constraints
75
- - Types/interfaces: full type definitions with fields
76
- - Functions: signature + body (the logic, not just the name)
77
- - Tests: concrete assertions (`expect(result.status).toBe(409)`) not descriptions ("test that it returns an error")
78
- - Routes: the actual handler code with validation, error handling, and response format
79
- - Config: exact values, not "configure appropriately"
80
-
81
- **Bad** (too vague — the executor must guess):
82
- ```
83
- 3. Implement bookmark model
84
- ```
85
-
86
- **Good** (executor can copy-paste):
87
- ```
88
- 3. Implement `src/db/bookmarks.ts`:
89
-
90
- ```ts
91
- import db from '../db.js';
92
-
93
- export function createBookmarksTable() {
94
- db.exec(`
95
- CREATE TABLE IF NOT EXISTS bookmarks (
96
- id TEXT PRIMARY KEY,
97
- userId TEXT NOT NULL,
98
- messageId TEXT NOT NULL,
99
- createdAt TEXT DEFAULT (datetime('now')),
100
- UNIQUE(userId, messageId)
101
- )
102
- `);
103
- }
104
-
105
- export function insertBookmark(userId: string, messageId: string) {
106
- const id = crypto.randomUUID();
107
- db.prepare('INSERT INTO bookmarks (id, userId, messageId) VALUES (?, ?, ?)').run(id, userId, messageId);
108
- return { id, userId, messageId };
109
- }
110
- ```
111
- ```
112
-
113
- ### Task body structure
114
-
115
- The examples below show the structure — headings, metadata comments, checkpoints, and step numbering. For the code content within steps, follow the detail level described above.
116
-
117
- **No checkpoint** — numbered steps only:
118
- ```markdown
119
- ## Task 1: Create User model
120
-
121
- <!-- tdd: new-feature -->
122
-
123
- Acceptance Criteria (QA Engineer Hat):
124
- - **Happy Path**:
125
- - Given: Valid user data with name and email
126
- - When: The User model is created
127
- - Then: The model contains the correct fields and a generated ID
128
- - **Edge Case (duplicate email)**:
129
- - Given: A user with email "test@example.com" already exists
130
- - When: Another user is created with the same email
131
- - Then: Creation fails with a unique constraint error
132
-
133
- Files:
134
- - `src/user/model.ts`
135
- - `src/user/model.test.ts`
136
-
137
- Steps:
138
- 1. Write failing test for User model creation
139
- 2. Run test — confirm it fails
140
- 3. Implement User model
141
- 4. Run test — confirm it passes
142
- ```
143
-
144
- **`checkpoint: test`** — gate after test, before implementing:
145
- ```markdown
146
- ## Task 2: Write auth tests
147
-
148
- <!-- tdd: new-feature -->
149
- <!-- checkpoint: test -->
150
-
151
- Acceptance Criteria (QA Engineer Hat):
152
- - **Happy Path**:
153
- - Given: A user with valid credentials exists
154
- - When: Login is attempted
155
- - Then: A valid session token is returned
156
- - **Edge Case (wrong password)**:
157
- - Given: A user exists but password is incorrect
158
- - When: Login is attempted
159
- - Then: An authentication error is returned
160
-
161
- Files:
162
- - `src/auth/login.test.ts`
163
-
164
- Steps:
165
- 1. Write failing test for login with valid credentials
166
- 2. Run test — confirm it fails
167
-
168
- ⏸ **CHECKPOINT: test** — present test review. Wait for human approval before implementing.
169
-
170
- 3. Implement login handler
171
- 4. Run test — confirm it passes
172
- 5. Refactor — check for shallow modules, duplication, seam discipline. Run tests after changes.
173
- 6. Lessons — caught a mistake that applies to future tasks? Add rule to `docs/lessons.md`.
174
- ```
175
-
176
- **`checkpoint: done`** — gate after all steps including refactor/lessons:
177
- ```markdown
178
- ## Task 3: Add login endpoint
179
-
180
- <!-- tdd: new-feature -->
181
- <!-- checkpoint: done -->
182
-
183
- Acceptance Criteria (QA Engineer Hat):
184
- - **Happy Path**:
185
- - Given: A user with email "user@example.com" and password "secure123" exists
186
- - When: A POST request with those credentials is sent to `/api/login`
187
- - Then: Response returns `200 OK` with a signed JWT token
188
- - **Edge Case (invalid password)**:
189
- - Given: A user exists but the password sent is "wrong-pass"
190
- - When: A POST request is sent to `/api/login`
191
- - Then: Response returns `401 Unauthorized`
192
- - **Edge Case (rate limiting)**:
193
- - Given: 5 failed login attempts from the same IP
194
- - When: A 6th attempt is sent
195
- - Then: Response returns `429 Too Many Requests`
196
-
197
- Files:
198
- - `src/auth/login.ts`
199
- - `src/auth/login.test.ts`
200
-
201
- Steps:
202
- 1. Write failing test for login with valid credentials
203
- 2. Run test — confirm it fails
204
- 3. Implement login handler
205
- 4. Run test — confirm it passes
206
- 5. Add edge case tests (invalid password, missing email)
207
- 6. Refactor — check for shallow modules, duplication, seam discipline. Run tests after changes.
208
- 7. Lessons — caught a mistake that applies to future tasks? Add rule to `docs/lessons.md`.
209
-
210
- ⏸ **CHECKPOINT: done** — present implementation review. Wait for human approval before committing.
211
- ```
212
-
213
- **Both checkpoints** — gate after test, then gate after refactor/lessons:
214
- ```markdown
215
- ## Task 4: Complex auth flow
216
-
217
- <!-- tdd: new-feature -->
218
- <!-- checkpoint: test -->
219
- <!-- checkpoint: done -->
220
-
221
- Acceptance Criteria (QA Engineer Hat):
222
- - **Happy Path**:
223
- - Given: A valid OAuth2 authorization code
224
- - When: The auth callback is invoked
225
- - Then: A user session is created and the user is redirected to the dashboard
226
- - **Edge Case (expired code)**:
227
- - Given: An expired or invalid authorization code
228
- - When: The auth callback is invoked
229
- - Then: The user is redirected to login with an error message
230
-
231
- Steps:
232
- 1. Write failing test for auth flow
233
- 2. Run test — confirm it fails
234
-
235
- ⏸ **CHECKPOINT: test** — present test review. Wait for human approval before implementing.
236
-
237
- 3. Implement auth flow
238
- 4. Run test — confirm it passes
239
- 5. Refactor — check for shallow modules, duplication, seam discipline. Run tests after changes.
240
- 6. Lessons — caught a mistake that applies to future tasks? Add rule to `docs/lessons.md`.
241
-
242
- ⏸ **CHECKPOINT: done** — present implementation review. Wait for human approval before committing.
243
- ```
244
-
245
-
246
- ## Vertical slices
247
-
248
- Each task should be a **vertical slice** — a thin path through ALL relevant layers end-to-end, delivering one complete piece of observable behavior.
249
-
250
- ```
251
- WRONG (horizontal):
252
- Task 1: Create database schema for users
253
- Task 2: Write user API endpoints
254
- Task 3: Build user UI components
255
- Task 4: Wire everything together
256
-
257
- RIGHT (vertical):
258
- Task 1: User can sign up (model + endpoint + validation + test)
259
- Task 2: User can log in (auth check + token + test)
260
- Task 3: User can view profile (query + endpoint + test)
261
- ```
262
-
263
- Order tasks so each one can be verified independently and delivers a complete vertical slice. If a task requires infrastructure (models, types) that no previous task has created, include it in that task — don't create it as a separate task.
264
-
265
- Vertical slices ensure every committed task leaves the codebase in a testable state and reduces the blast radius of a bad task.
266
-
267
- ## TDD in the plan
268
-
269
- Label each task with its TDD scenario:
270
-
271
- | Scenario | When | Instructions in the task |
272
- |---|---|---|
273
- | **New feature** | Adding new behavior | Write failing test → run it → implement → run it |
274
- | **Modifying tested code** | Changing existing behavior | Run existing tests first → modify → verify they pass |
275
- | **Trivial** | Config, docs, naming | Use judgment |
276
-
277
- ## Checkpoint labels
278
-
279
- Label each task with a `checkpoint` to require human review before proceeding. The checkpoint gate (`⏸ CHECKPOINT`) goes in the task body — the agent follows the plan step by step and pauses when it reaches the gate.
280
-
281
- | Checkpoint | When to use | What the plan should include |
282
- |---|---|---|
283
- | *(none)* | Trivial tasks, well-understood changes | Numbered steps only |
284
- | **`checkpoint: test`** | Test design matters (API contracts, edge cases, complex behavior) | Steps up to test → `⏸ CHECKPOINT: test` → implement steps (including refactor/lessons) |
285
- | **`checkpoint: done`** | Implementation review matters (complex logic, security, performance) | Steps (including refactor/lessons) → `⏸ CHECKPOINT: done` |
286
- | Both | Non-obvious tests AND complex logic | Steps up to test → `⏸ CHECKPOINT: test` → implement steps (including refactor/lessons) → `⏸ CHECKPOINT: done` |
287
-
288
- Use judgment when assigning checkpoints. Prefer `checkpoint: test` for new features with non-obvious test design. Prefer `checkpoint: done` for tasks where the implementation approach is debatable. Most tasks should not need a checkpoint. The user can adjust checkpoints when reviewing the plan.
289
-
290
- ## After the plan
291
-
292
- Ask: "Ready to execute? Run `/skill:executing-tasks`"
293
-
294
- ## Behavioral Guidelines
295
-
296
- Guidelines to reduce overcomplication and hidden assumptions in plans. Derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/2015883857489522876) on LLM coding pitfalls, adapted for the planning context.
297
-
298
- **Tradeoff:** These guidelines bias toward caution over speed. For trivial plans (1-2 tasks), use judgment.
299
-
300
- ### Surface Assumptions
301
-
302
- **When the design is ambiguous, annotate — don't silently pick.**
303
-
304
- When writing a plan, you'll encounter gaps: the design says "paginated" but doesn't specify how, says "validate input" but doesn't say which fields, or leaves the data layer unspecified. Your instinct will be to fill the gap and keep writing. Resist that.
305
-
306
- Instead, add a brief `> **Assumption:** ...` note in the plan at the point where you made the call:
307
-
308
- ```
309
- > **Assumption:** Using offset/limit pagination because the design just says
310
- > "paginated". Cursor-based would be better for large datasets.
311
- ```
312
-
313
- ```
314
- > **Assumption:** No service layer — handler calls store directly. Add one
315
- > if cross-cutting concerns (logging, auth checks) emerge later.
316
- ```
317
-
318
- This lets the reviewer see what you chose and why, without blocking progress. Common gaps worth annotating:
319
- - Pagination style, error handling strategy, concurrency model
320
- - Whether to add a service/middleware layer
321
- - Whether to add external dependencies
322
- - Naming conventions when the design doesn't specify
323
-
324
- ### Build Only What Each Task Needs
325
-
326
- **Minimum code to deliver the task's observable behavior. Nothing more.**
327
-
328
- - No interface methods that no task exercises yet. If Task 2 creates a `Store` interface, it should have only the methods Task 2 calls. Add methods in the task that first needs them.
329
- - No layers (service, middleware, repository) unless the design explicitly requires them.
330
- - No error types, helper files, or shared packages until a task actually uses them.
331
- - No external dependencies when stdlib suffices. Every `go get` or `npm install` is a choice — default to no.
332
- - No "flexible" or "configurable" code that wasn't requested.
333
-
334
- If you find yourself writing a store with 4 methods where only 1 is used in this task, stop. Write 1 method. Add the rest when the tasks that need them arrive.
335
-
336
- ### One Task, One Change
337
-
338
- **Each task should trace to exactly one user-facing behavior.**
339
-
340
- - If a task creates more than 4 new files, it's probably doing too much — split it.
341
- - If a task modifies existing files unrelated to its acceptance criteria, trim the scope.
342
- - Infrastructure (types, interfaces, module scaffolding) should live in the same task as the first code that uses it, not in a separate "setup" task — unless the infrastructure alone is complex enough to warrant its own task.
343
- - Every file listed in a task's `Files:` section should be directly necessary for that task's acceptance criteria to pass.