mindsystem-cc 3.12.0 → 3.13.1

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 (33) hide show
  1. package/agents/ms-consolidator.md +4 -4
  2. package/agents/ms-executor.md +19 -351
  3. package/agents/ms-flutter-code-quality.md +7 -6
  4. package/agents/ms-mock-generator.md +51 -138
  5. package/agents/ms-plan-checker.md +170 -175
  6. package/agents/ms-plan-writer.md +120 -115
  7. package/agents/ms-verifier.md +22 -18
  8. package/commands/ms/check-phase.md +3 -3
  9. package/commands/ms/execute-phase.md +8 -6
  10. package/commands/ms/plan-phase.md +4 -3
  11. package/commands/ms/verify-work.md +7 -7
  12. package/mindsystem/references/goal-backward.md +10 -25
  13. package/mindsystem/references/mock-patterns.md +149 -240
  14. package/mindsystem/references/plan-format.md +326 -247
  15. package/mindsystem/references/scope-estimation.md +29 -24
  16. package/mindsystem/references/tdd-execution.md +70 -0
  17. package/mindsystem/references/tdd.md +53 -194
  18. package/mindsystem/templates/UAT.md +16 -16
  19. package/mindsystem/templates/phase-prompt.md +51 -367
  20. package/mindsystem/templates/roadmap.md +1 -1
  21. package/mindsystem/templates/verification-report.md +2 -2
  22. package/mindsystem/workflows/adhoc.md +16 -21
  23. package/mindsystem/workflows/execute-phase.md +71 -49
  24. package/mindsystem/workflows/execute-plan.md +183 -1054
  25. package/mindsystem/workflows/plan-phase.md +47 -38
  26. package/mindsystem/workflows/verify-phase.md +16 -20
  27. package/mindsystem/workflows/verify-work.md +54 -67
  28. package/package.json +1 -1
  29. package/scripts/update-state.sh +59 -0
  30. package/scripts/validate-execution-order.sh +102 -0
  31. package/skills/flutter-code-quality/SKILL.md +4 -3
  32. package/mindsystem/templates/summary.md +0 -293
  33. package/mindsystem/workflows/generate-mocks.md +0 -261
@@ -1,309 +1,395 @@
1
- <overview>
2
- Claude-executable plans have a specific format that enables Claude to implement without interpretation. This reference defines what makes a plan executable vs. vague.
1
+ <plan_format>
3
2
 
4
- **Key insight:** PLAN.md IS the executable prompt. It contains everything Claude needs to execute the phase, including objective, context references, tasks, verification, success criteria, and output specification.
5
- </overview>
3
+ Plans are executable prompts for a single intelligent reader. ~90% actionable content, ~10% structure. Pure markdown no XML containers, no YAML frontmatter.
6
4
 
7
- <core_principle>
8
- A plan is Claude-executable when Claude can read the PLAN.md and immediately start implementing without asking clarifying questions.
5
+ A plan is Claude-executable when Claude can read the PLAN.md and start implementing without asking clarifying questions. If Claude has to guess, interpret, or make assumptions — the plan is too vague.
9
6
 
10
- If Claude has to guess, interpret, or make assumptions - the task is too vague.
11
- </core_principle>
7
+ ## Plan Anatomy
12
8
 
13
- <frontmatter>
14
- Every PLAN.md starts with YAML frontmatter:
9
+ Every plan follows this structure:
15
10
 
16
- ```yaml
17
- ---
18
- phase: XX-name
19
- plan: NN
20
- type: execute
21
- wave: N # Execution wave (1, 2, 3...). Pre-computed at plan time.
22
- depends_on: [] # Plan IDs this plan requires (e.g., ["01-01"])
23
- files_modified: [] # Files this plan modifies
24
- ---
11
+ ```markdown
12
+ # Plan NN: Descriptive Title
13
+
14
+ **Subsystem:** auth | **Type:** tdd
15
+
16
+ ## Context
17
+ Why this work exists. Approach chosen and why.
18
+
19
+ ## Changes
20
+
21
+ ### 1. Change title
22
+ **Files:** `src/path/to/file.ts`
23
+
24
+ Implementation details with inline code blocks where needed.
25
+
26
+ ### 2. Another change
27
+ **Files:** `src/path/to/other.ts`, `src/path/to/related.ts`
28
+
29
+ Details referencing existing utilities: "Use `comparePassword` in `src/lib/crypto.ts`".
30
+
31
+ ## Verification
32
+ - `npm test -- --grep auth` passes
33
+ - `curl -X POST localhost:3000/api/auth/login` returns 200 with Set-Cookie
34
+
35
+ ## Must-Haves
36
+ - [ ] Valid credentials return 200 with Set-Cookie header
37
+ - [ ] Invalid credentials return 401
38
+ - [ ] Passwords compared with bcrypt, never plaintext
25
39
  ```
26
40
 
27
- | Field | Required | Purpose |
28
- |-------|----------|---------|
29
- | `phase` | Yes | Phase identifier (e.g., `01-foundation`) |
30
- | `plan` | Yes | Plan number within phase (e.g., `01`, `02`) |
31
- | `type` | Yes | `execute` for standard plans, `tdd` for TDD plans |
32
- | `wave` | Yes | Execution wave number (1, 2, 3...). Pre-computed during planning. |
33
- | `depends_on` | Yes | Array of plan IDs this plan requires. |
34
- | `files_modified` | Yes | Files this plan touches. |
35
- | `subsystem_hint` | No | Subsystem from config.json, assigned by planner for executor to use in SUMMARY.md |
41
+ ### Section Reference
42
+
43
+ | Section | Purpose | Required |
44
+ |---------|---------|----------|
45
+ | `# Plan NN: Title` | H1 with plan number and descriptive title | Yes |
46
+ | `**Subsystem:** X \| **Type:** Y` | Inline metadata (replaces YAML frontmatter) | Yes (type defaults to `execute`) |
47
+ | `## Context` | Why this work exists, why this approach | Yes |
48
+ | `## Changes` | Numbered subsections with files and implementation details | Yes |
49
+ | `## Verification` | Bash commands and observable checks | Yes |
50
+ | `## Must-Haves` | Markdown checklist of user-observable truths | Yes |
51
+
52
+ ---
53
+
54
+ ## Context Section Guidance
55
+
56
+ The `## Context` section bridges the gap between plan-writer and executor. The executor starts with zero context beyond the plan — approach rationale compensates for this boundary.
36
57
 
37
- **Wave is pre-computed:** `/ms:plan-phase` assigns wave numbers based on `depends_on`. `/ms:execute-phase` reads `wave` directly from frontmatter and groups plans by wave number. No runtime dependency analysis needed.
38
- </frontmatter>
58
+ **Include:**
59
+ - Problem being solved
60
+ - Approach chosen and WHY (constraints, trade-offs, rejected alternatives)
61
+ - Key dependencies or prior work referenced
62
+ - Technical context the executor needs to make correct decisions
39
63
 
40
- <prompt_structure>
41
- Every PLAN.md follows this XML structure:
64
+ **Exclude:**
65
+ - Rehash of the roadmap or project vision
66
+ - Generic background information
67
+ - Anything not specific to this plan's implementation decisions
68
+
69
+ **Example:**
42
70
 
43
71
  ```markdown
44
- ---
45
- phase: XX-name
46
- plan: NN
47
- type: execute
48
- wave: N
49
- depends_on: []
50
- files_modified: [path/to/file.ts]
72
+ ## Context
73
+ User authentication requires JWT tokens for the API layer. Using jose library
74
+ (not jsonwebtoken) because jsonwebtoken uses CommonJS which causes issues with
75
+ Next.js Edge runtime. Refresh token rotation prevents token theft — a single-use
76
+ refresh token invalidates on use and issues a new pair.
77
+
78
+ Prior plan 01 created the User model with `passwordHash` field in Prisma schema.
79
+ ```
80
+
51
81
  ---
52
82
 
53
- <objective>
54
- [What and why]
55
- Purpose: [...]
56
- Output: [...]
57
- </objective>
58
-
59
- <execution_context>
60
- @~/.claude/mindsystem/workflows/execute-plan.md
61
- @~/.claude/mindsystem/templates/summary.md
62
- </execution_context>
63
-
64
- <context>
65
- @.planning/PROJECT.md
66
- @.planning/ROADMAP.md
67
- @.planning/STATE.md
68
- [Only if genuinely needed:]
69
- @.planning/phases/XX-name/XX-YY-SUMMARY.md
70
- @relevant/source/files.ts
71
- </context>
72
-
73
- <tasks>
74
- <task type="auto">
75
- <name>Task N: [Name]</name>
76
- <files>[paths]</files>
77
- <action>[what to do, what to avoid and WHY]</action>
78
- <verify>[command/check]</verify>
79
- <done>[criteria]</done>
80
- </task>
81
-
82
- </tasks>
83
-
84
- <verification>
85
- [Overall phase checks]
86
- </verification>
87
-
88
- <success_criteria>
89
- [Measurable completion]
90
- </success_criteria>
91
-
92
- <output>
93
- [SUMMARY.md specification]
94
- </output>
83
+ ## Changes Section Guidance
84
+
85
+ Each `### N. Title` subsection is a coherent unit of work — a file group, a logical change, or a feature slice.
86
+
87
+ **Structure each subsection with:**
88
+ - `**Files:**` line listing exact paths
89
+ - Implementation details in prose with inline code blocks for critical snippets
90
+ - References to existing utilities with file paths: "Use `hashPassword` in `src/lib/crypto.ts`"
91
+ - Tables for configuration, mappings, or data structures
92
+ - Line number references when modifying existing files: "After the import block (~line 15)"
93
+
94
+ **Sizing:** Each subsection represents 15-60 minutes of Claude work. If a subsection takes multiple sessions, split it. If it's trivial, combine with a related subsection.
95
+
96
+ **Example:**
97
+
98
+ ```markdown
99
+ ### 2. Add password comparison utility
100
+ **Files:** `src/lib/crypto.ts`
101
+
102
+ Export `comparePassword(plain: string, hash: string): Promise<boolean>` using
103
+ bcrypt.compare. Import `bcrypt` from the existing dependency in package.json.
104
+
105
+ Follow the pattern of `hashPassword` already in this file (~line 8).
95
106
  ```
96
107
 
97
- </prompt_structure>
108
+ ---
98
109
 
99
- <task_anatomy>
100
- Every task has four required fields:
110
+ ## Inline Metadata Specification
101
111
 
102
- <field name="files">
103
- **What it is**: Exact file paths that will be created or modified.
112
+ The metadata line sits directly below the H1 title:
104
113
 
105
- **Good**: `src/app/api/auth/login/route.ts`, `prisma/schema.prisma`
106
- **Bad**: "the auth files", "relevant components"
114
+ ```markdown
115
+ # Plan 03: Create login endpoint with JWT
107
116
 
108
- Be specific. If you don't know the file path, figure it out first.
109
- </field>
117
+ **Subsystem:** auth | **Type:** tdd
118
+ ```
110
119
 
111
- <field name="action">
112
- **What it is**: Specific implementation instructions, including what to avoid and WHY.
120
+ ### Subsystem
113
121
 
114
- **Good**: "Create POST endpoint that accepts {email, password}, validates using bcrypt against User table, returns JWT in httpOnly cookie with 15-min expiry. Use jose library (not jsonwebtoken - CommonJS issues with Next.js Edge runtime)."
122
+ Matches vocabulary from the project's `config.json`. Used by the executor when generating SUMMARY.md after plan completion.
115
123
 
116
- **Bad**: "Add authentication", "Make login work"
124
+ ### Type
117
125
 
118
- Include: technology choices, data structures, behavior details, pitfalls to avoid.
119
- </field>
126
+ | Value | Behavior |
127
+ |-------|----------|
128
+ | `execute` | Default. Standard plan execution. Can be omitted. |
129
+ | `tdd` | Triggers lazy-load of `tdd-execution.md` reference during execution. Plan uses RED/GREEN/REFACTOR structure. |
120
130
 
121
- <field name="verify">
122
- **What it is**: How to prove the task is complete.
131
+ When `**Type:**` is omitted, the plan defaults to `execute`.
123
132
 
124
- **Good**:
133
+ ---
134
+
135
+ ## Must-Haves Specification
125
136
 
126
- - `npm test` passes
127
- - `curl -X POST /api/auth/login` returns 200 with Set-Cookie header
128
- - Build completes without errors
137
+ The `## Must-Haves` section is a markdown checklist consumed by ms-verifier. Each item is a user-observable truth — not an implementation detail.
129
138
 
130
- **Bad**: "It works", "Looks good", "User can log in"
139
+ **Good (observable truths):**
140
+ - `- [ ] Valid credentials return 200 with Set-Cookie header`
141
+ - `- [ ] Passwords are hashed, never stored plaintext`
142
+ - `- [ ] Unauthenticated requests to /api/protected return 401`
131
143
 
132
- Must be executable - a command, a test, an observable behavior.
133
- </field>
144
+ **Bad (implementation details):**
145
+ - `- [ ] bcrypt library installed`
146
+ - `- [ ] JWT_SECRET in .env file`
147
+ - `- [ ] Auth middleware created`
134
148
 
135
- <field name="done">
136
- **What it is**: Acceptance criteria - the measurable state of completion.
149
+ The verifier derives artifacts and key_links from the `## Changes` section. Must-haves focus on what the user can observe or verify.
137
150
 
138
- **Good**: "Valid credentials return 200 + JWT cookie, invalid credentials return 401"
151
+ ---
139
152
 
140
- **Bad**: "Authentication is complete"
153
+ ## EXECUTION-ORDER.md Specification
141
154
 
142
- Should be testable without subjective judgment.
143
- </field>
144
- </task_anatomy>
155
+ Execution order lives in a single `EXECUTION-ORDER.md` file alongside the plans. Individual plans carry no wave numbers or dependency declarations.
145
156
 
146
- <task_types>
147
- Tasks have a `type` attribute that determines how they execute:
157
+ **Format:**
158
+
159
+ ```markdown
160
+ # Execution Order
148
161
 
149
- <type name="auto">
150
- **Default task type** - Claude executes autonomously.
162
+ ## Wave 1 (parallel)
163
+ - 01-PLAN.md Database schema and Prisma client
164
+ - 02-PLAN.md — Environment configuration
151
165
 
152
- **Structure:**
166
+ ## Wave 2 (parallel)
167
+ - 03-PLAN.md — Auth endpoints (depends on schema from 01)
168
+ - 04-PLAN.md — User profile CRUD (depends on schema from 01)
153
169
 
154
- ```xml
155
- <task type="auto">
156
- <name>Task 3: Create login endpoint with JWT</name>
157
- <files>src/app/api/auth/login/route.ts</files>
158
- <action>POST endpoint accepting {email, password}. Query User by email, compare password with bcrypt. On match, create JWT with jose library, set as httpOnly cookie (15-min expiry). Return 200. On mismatch, return 401.</action>
159
- <verify>curl -X POST localhost:3000/api/auth/login returns 200 with Set-Cookie header</verify>
160
- <done>Valid credentials → 200 + cookie. Invalid → 401.</done>
161
- </task>
170
+ ## Wave 3
171
+ - 05-PLAN.md — Protected route middleware (depends on auth from 03)
162
172
  ```
163
173
 
164
- Use for: Everything Claude can do independently (code, tests, builds, file operations).
165
- </type>
174
+ **Rules:**
175
+ - Generated by plan-writer alongside plans
176
+ - Read by execute-phase orchestrator for wave grouping
177
+ - Plans within a wave execute in parallel
178
+ - Single source of truth for execution structure
179
+ - Human-readable, easy to override by editing directly
166
180
 
167
- **Golden rule:** If Claude CAN automate it, Claude MUST automate it. All tasks use `type="auto"`.
181
+ ---
168
182
 
169
- **Decisions:** Resolve during planning via AskUserQuestion, not during execution. For purely technical choices, make the decision and document it in the plan's objective.
170
- </task_types>
183
+ ## Cross-Reference Table
171
184
 
172
- <tdd_plans>
173
- **TDD work uses dedicated plans.**
185
+ | Question | Answer |
186
+ |----------|--------|
187
+ | How does the verifier find must-haves? | Reads `## Must-Haves` section |
188
+ | How does the executor know the subsystem? | Reads inline metadata (`**Subsystem:**`) |
189
+ | How does the plan-checker validate plans? | Reads EXECUTION-ORDER.md + plan structure |
190
+ | What triggers TDD lazy-loading? | `**Type:** tdd` in inline metadata |
191
+ | How does the executor know why an approach was chosen? | Reads `## Context` section |
192
+ | How does the executor find existing utilities? | Reads `**Files:**` lines and inline references in `## Changes` |
174
193
 
175
- TDD features require 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. This is fundamentally heavier than standard tasks and would consume 50-60% of context if embedded in a multi-task plan.
194
+ ---
176
195
 
177
- **When to create a TDD plan:**
178
- - Business logic with defined inputs/outputs
179
- - API endpoints with request/response contracts
180
- - Data transformations and parsing
181
- - Validation rules
182
- - Algorithms with testable behavior
196
+ ## What Plans Do NOT Contain
183
197
 
184
- **When to use standard plans (skip TDD):**
185
- - UI layout and styling
186
- - Configuration changes
187
- - Glue code connecting existing components
188
- - One-off scripts
198
+ - **No YAML frontmatter** metadata is inline markdown
199
+ - **No XML containers** — pure markdown throughout
200
+ - **No wave numbers or dependency declarations** — centralized in EXECUTION-ORDER.md
201
+ - **No file ownership lists** — centralized in EXECUTION-ORDER.md
202
+ - **No `<output>` or `<execution_context>` sections** — executor handles these inline
203
+ - **No summary template references** — executor loads templates as needed
189
204
 
190
- **Heuristic:** Can you write `expect(fn(input)).toBe(output)` before writing `fn`?
191
- → Yes: Create a TDD plan (one feature per plan)
192
- → No: Use standard plan, add tests after if needed
205
+ ---
193
206
 
194
- See `./tdd.md` for TDD plan structure and execution guidance.
195
- </tdd_plans>
207
+ ## Examples
196
208
 
197
- <context_references>
198
- Use @file references to load context for the prompt:
209
+ ### Simple Plan: CRUD Endpoint
199
210
 
200
211
  ```markdown
201
- <context>
202
- @.planning/PROJECT.md # Project vision
203
- @.planning/ROADMAP.md # Phase structure
204
- @.planning/STATE.md # Current position
205
-
206
- # Only include prior SUMMARY if genuinely needed:
207
- # - This plan imports types from prior plan
208
- # - Prior plan made decision affecting this plan
209
- # Independent plans need NO prior SUMMARY references.
210
-
211
- @src/lib/db.ts # Existing database setup
212
- @src/types/user.ts # Existing type definitions
213
- </context>
214
- ```
212
+ # Plan 01: Create user profile CRUD endpoints
215
213
 
216
- Reference files that Claude needs to understand before implementing.
214
+ **Subsystem:** api
217
215
 
218
- **Anti-pattern:** Reflexive chaining (02 refs 01, 03 refs 02). Only reference what you actually need.
219
- </context_references>
216
+ ## Context
217
+ The API needs basic user profile management. Using Next.js route handlers with
218
+ Prisma ORM. The User model already exists in the schema (created during project
219
+ init).
220
220
 
221
- <verification_section>
222
- Overall phase verification (beyond individual task verification):
221
+ ## Changes
223
222
 
224
- ```markdown
225
- <verification>
226
- Before declaring phase complete:
227
- - [ ] `npm run build` succeeds without errors
228
- - [ ] `npm test` passes all tests
229
- - [ ] No TypeScript errors
230
- - [ ] Feature works end-to-end manually
231
- </verification>
232
- ```
223
+ ### 1. Create GET /api/users/[id] endpoint
224
+ **Files:** `src/app/api/users/[id]/route.ts`
233
225
 
234
- </verification_section>
226
+ Route handler accepting `id` param. Query User by ID with Prisma. Return 200
227
+ with user JSON (exclude passwordHash). Return 404 if not found.
235
228
 
236
- <success_criteria_section>
237
- Measurable criteria for phase completion:
229
+ ### 2. Create PATCH /api/users/[id] endpoint
230
+ **Files:** `src/app/api/users/[id]/route.ts`
238
231
 
239
- ```markdown
240
- <success_criteria>
241
-
242
- - All tasks completed
243
- - All verification checks pass
244
- - No errors or warnings introduced
245
- - JWT auth flow works end-to-end
246
- - Protected routes redirect unauthenticated users
247
- </success_criteria>
232
+ Accept JSON body with optional `name` and `email` fields. Validate email format
233
+ with regex. Update User with Prisma. Return 200 with updated user. Return 404
234
+ if not found, 400 if validation fails.
235
+
236
+ ## Verification
237
+ - `curl localhost:3000/api/users/1` returns 200 with user JSON
238
+ - `curl -X PATCH localhost:3000/api/users/1 -d '{"name":"New"}' -H 'Content-Type: application/json'` returns 200
239
+ - `curl localhost:3000/api/users/999` returns 404
240
+
241
+ ## Must-Haves
242
+ - [ ] GET /api/users/:id returns user profile without password hash
243
+ - [ ] PATCH /api/users/:id updates name and email
244
+ - [ ] Invalid user ID returns 404
245
+ - [ ] Invalid email format returns 400
248
246
  ```
249
247
 
250
- </success_criteria_section>
248
+ ### Complex Plan: Auth with Approach Rationale
249
+
250
+ ```markdown
251
+ # Plan 03: Create login endpoint with JWT
252
+
253
+ **Subsystem:** auth | **Type:** execute
254
+
255
+ ## Context
256
+ User authentication for the API layer. Using jose library instead of
257
+ jsonwebtoken — jsonwebtoken uses CommonJS which causes issues with Next.js Edge
258
+ runtime. Tokens use httpOnly cookies (not Authorization headers) to prevent XSS
259
+ token theft.
260
+
261
+ Refresh token rotation: each refresh token is single-use. On refresh, the old
262
+ token is invalidated and a new access/refresh pair is issued. This limits the
263
+ window of a stolen refresh token.
264
+
265
+ Prior plan 01 created the User model with `passwordHash` field in Prisma schema.
266
+
267
+ ## Changes
251
268
 
252
- <output_section>
253
- Specify the SUMMARY.md structure:
269
+ ### 1. Create POST /api/auth/login endpoint
270
+ **Files:** `src/app/api/auth/login/route.ts`
271
+
272
+ POST endpoint accepting `{email, password}`. Query User by email with Prisma.
273
+ Compare password using `comparePassword` in `src/lib/crypto.ts` (created in
274
+ plan 02). On match, create access JWT (15-min expiry) and refresh JWT (7-day
275
+ expiry) with jose. Set both as httpOnly cookies. Return 200 with user profile.
276
+ On mismatch, return 401 with generic "Invalid credentials" message.
277
+
278
+ ### 2. Create POST /api/auth/refresh endpoint
279
+ **Files:** `src/app/api/auth/refresh/route.ts`
280
+
281
+ Read refresh token from cookie. Verify with jose. Look up token in
282
+ RefreshToken table — if not found or already used, return 401. Mark current
283
+ token as used. Issue new access + refresh pair. Set cookies. Return 200.
284
+
285
+ ### 3. Add RefreshToken model to schema
286
+ **Files:** `prisma/schema.prisma`
287
+
288
+ Add RefreshToken model with fields: `id`, `token` (unique), `userId` (relation
289
+ to User), `used` (boolean, default false), `expiresAt` (DateTime), `createdAt`.
290
+ Run `npx prisma db push` after schema change.
291
+
292
+ ## Verification
293
+ - `curl -X POST localhost:3000/api/auth/login -H 'Content-Type: application/json' -d '{"email":"test@test.com","password":"test123"}'` returns 200 with Set-Cookie headers
294
+ - Login with wrong password returns 401
295
+ - Refresh endpoint with valid cookie returns new tokens
296
+ - Refresh endpoint with used token returns 401
297
+
298
+ ## Must-Haves
299
+ - [ ] Valid credentials return 200 with httpOnly cookie containing JWT
300
+ - [ ] Invalid credentials return 401 with generic error message
301
+ - [ ] Refresh token rotation invalidates used tokens
302
+ - [ ] Passwords compared with bcrypt, never plaintext
303
+ ```
304
+
305
+ ### TDD Plan: Pure Markdown RED/GREEN/REFACTOR
254
306
 
255
307
  ```markdown
256
- <output>
257
- After completion, create `.planning/phases/XX-name/{phase}-{plan}-SUMMARY.md`
258
- </output>
308
+ # Plan 04: Email validation utility
309
+
310
+ **Subsystem:** validation | **Type:** tdd
311
+
312
+ ## Context
313
+ Multiple endpoints need email validation (registration, profile update, invite).
314
+ Centralizing in a utility prevents inconsistent validation rules. Using TDD
315
+ because the function has clear inputs/outputs and edge cases that benefit from
316
+ test-first design.
317
+
318
+ ## Changes
319
+
320
+ ### 1. RED — Write failing tests
321
+ **Files:** `src/lib/__tests__/validate-email.test.ts`
322
+
323
+ Test cases:
324
+ - Valid: `user@example.com`, `name+tag@domain.co.uk` → returns true
325
+ - Invalid: `@domain.com`, `user@`, `user@.com`, empty string, `null` → returns false
326
+ - Edge: very long local part (>64 chars), very long domain (>255 chars) → returns false
327
+
328
+ Import `validateEmail` from `src/lib/validate-email.ts` (does not exist yet).
329
+ Run tests — all must fail with import/function error.
330
+
331
+ ### 2. GREEN — Implement minimal validation
332
+ **Files:** `src/lib/validate-email.ts`
333
+
334
+ Export `validateEmail(email: string): boolean`. Use regex matching RFC 5322
335
+ simplified pattern. Handle null/undefined input by returning false. No
336
+ optimization — just make tests pass.
337
+
338
+ ### 3. REFACTOR — Extract regex constant
339
+ **Files:** `src/lib/validate-email.ts`
340
+
341
+ Extract regex to `EMAIL_REGEX` constant at module level. Add JSDoc with
342
+ examples. Run tests — all must still pass. Only commit if changes improve
343
+ readability.
344
+
345
+ ## Verification
346
+ - `npm test -- --grep "validate-email"` passes all cases
347
+ - Import works from other modules without errors
348
+
349
+ ## Must-Haves
350
+ - [ ] Valid email addresses return true
351
+ - [ ] Invalid email addresses return false
352
+ - [ ] Edge cases (length limits, null input) handled correctly
259
353
  ```
260
354
 
261
- </output_section>
355
+ ---
356
+
357
+ ## Specificity Guidelines
262
358
 
263
- <specificity_levels>
264
- <too_vague>
359
+ ### Too Vague
265
360
 
266
- ```xml
267
- <task type="auto">
268
- <name>Task 1: Add authentication</name>
269
- <files>???</files>
270
- <action>Implement auth</action>
271
- <verify>???</verify>
272
- <done>Users can authenticate</done>
273
- </task>
361
+ ```markdown
362
+ ### 1. Add authentication
363
+ **Files:** ???
364
+
365
+ Implement auth.
274
366
  ```
275
367
 
276
368
  Claude: "How? What type? What library? Where?"
277
- </too_vague>
278
-
279
- <just_right>
280
-
281
- ```xml
282
- <task type="auto">
283
- <name>Task 1: Create login endpoint with JWT</name>
284
- <files>src/app/api/auth/login/route.ts</files>
285
- <action>POST endpoint accepting {email, password}. Query User by email, compare password with bcrypt. On match, create JWT with jose library, set as httpOnly cookie (15-min expiry). Return 200. On mismatch, return 401. Use jose instead of jsonwebtoken (CommonJS issues with Edge).</action>
286
- <verify>curl -X POST localhost:3000/api/auth/login -H "Content-Type: application/json" -d '{"email":"test@test.com","password":"test123"}' returns 200 with Set-Cookie header containing JWT</verify>
287
- <done>Valid credentials 200 + cookie. Invalid → 401. Missing fields → 400.</done>
288
- </task>
369
+
370
+ ### Just Right
371
+
372
+ ```markdown
373
+ ### 1. Create login endpoint with JWT
374
+ **Files:** `src/app/api/auth/login/route.ts`
375
+
376
+ POST endpoint accepting {email, password}. Query User by email, compare
377
+ password with bcrypt. On match, create JWT with jose library, set as httpOnly
378
+ cookie (15-min expiry). Return 200. On mismatch, return 401. Use jose instead
379
+ of jsonwebtoken (CommonJS issues with Edge).
289
380
  ```
290
381
 
291
382
  Claude can implement this immediately.
292
- </just_right>
293
383
 
294
- <note_on_tdd>
295
- **TDD candidates get dedicated plans.**
384
+ ### Too Detailed
296
385
 
297
- If email validation warrants TDD, create a TDD plan for it. See `./tdd.md` for TDD plan structure.
298
- </note_on_tdd>
386
+ Writing the actual code in the plan. Trust Claude to implement from clear instructions specify WHAT and WHY, not the exact lines of code.
387
+
388
+ ---
299
389
 
300
- <too_detailed>
301
- Writing the actual code in the plan. Trust Claude to implement from clear instructions.
302
- </too_detailed>
303
- </specificity_levels>
390
+ ## Anti-Patterns
304
391
 
305
- <anti_patterns>
306
- <vague_actions>
392
+ ### Vague Actions
307
393
 
308
394
  - "Set up the infrastructure"
309
395
  - "Handle edge cases"
@@ -311,9 +397,8 @@ Writing the actual code in the plan. Trust Claude to implement from clear instru
311
397
  - "Add proper error handling"
312
398
 
313
399
  These require Claude to decide WHAT to do. Specify it.
314
- </vague_actions>
315
400
 
316
- <unverifiable_completion>
401
+ ### Unverifiable Completion
317
402
 
318
403
  - "It works correctly"
319
404
  - "User experience is good"
@@ -321,27 +406,21 @@ These require Claude to decide WHAT to do. Specify it.
321
406
  - "Tests pass" (which tests? do they exist?)
322
407
 
323
408
  These require subjective judgment. Make it objective.
324
- </unverifiable_completion>
325
409
 
326
- <missing_context>
410
+ ### Missing Context
327
411
 
328
412
  - "Use the standard approach"
329
413
  - "Follow best practices"
330
414
  - "Like the other endpoints"
331
415
 
332
- Claude doesn't know your standards. Be explicit.
333
- </missing_context>
334
- </anti_patterns>
416
+ Claude has no memory of your standards across contexts. Be explicit.
335
417
 
336
- <sizing_tasks>
337
- Good task size: 15-60 minutes of Claude work.
418
+ ### Implementation-Detail Must-Haves
338
419
 
339
- **Too small**: "Add import statement for bcrypt" (combine with related task)
340
- **Just right**: "Create login endpoint with JWT validation" (focused, specific)
341
- **Too big**: "Implement full authentication system" (split into multiple plans)
420
+ - "bcrypt library installed"
421
+ - "Middleware file created"
422
+ - "ENV variable added"
342
423
 
343
- If a task takes multiple sessions, break it down.
344
- If a task is trivial, combine with related tasks.
424
+ Must-haves are user-observable truths. The verifier checks outcomes, not internals.
345
425
 
346
- **Note on scope:** If a phase has >3 tasks or spans multiple subsystems, split into multiple plans using the naming convention `{phase}-{plan}-PLAN.md`. See `./scope-estimation.md` for guidance.
347
- </sizing_tasks>
426
+ </plan_format>