Use when you have a design or requirements for a multi-step task, before writing code. Creates bite-sized TDD task plans with exact file paths, complete code, and verification steps.
Write comprehensive implementation plans assuming the executor has zero context. Document everything: which files to touch, complete code, how to test. Bite-sized tasks. DRY. YAGNI. TDD.
NO IMPLEMENTATION WITHOUT A PLAN FIRST
For multi-step tasks, write the plan before writing code.
Each step is ONE action (2-5 minutes):
1. Write the failing test - step
2. Run it to verify it fails - step
3. Implement minimal code to pass - step
4. Run tests to verify they pass - step
5. Commit - step
# [Feature Name] Implementation Plan
**Goal:** [One sentence describing what this builds]
**Architecture:** [2-3 sentences about approach]
**Tech Stack:** [Key technologies/libraries]
---
### Task N: [Component Name]
**Files:**
- Create: `exact/path/to/file.ts`
- Modify: `exact/path/to/existing.ts:123-145`
- Test: `tests/exact/path/to/test.ts`
**Step 1: Write the failing test**
\`\`\`typescript
import { describe, it, expect } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { getUser, type GetUserDeps } from './get-user';
describe('getUser', () => {
it('returns NOT_FOUND when user does not exist', async () => {
const deps = mock<GetUserDeps>();
deps.db.findUser.mockResolvedValue(null);
const result = await getUser({ userId: '123' }, deps);
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error).toBe('NOT_FOUND');
}
});
});
\`\`\`
**Step 2: Run test to verify it fails**
Run: `npm test src/domain/get-user.test.ts`
Expected: FAIL with "Cannot find module './get-user'"
**Step 3: Write minimal implementation**
\`\`\`typescript
import { err, type Result } from '@/result';
export type GetUserDeps = {
db: { findUser: (id: string) => Promise<User | null> };
};
export async function getUser(
args: { userId: string },
deps: GetUserDeps
): Promise<Result<User, 'NOT_FOUND'>> {
return err('NOT_FOUND');
}
\`\`\`
**Step 4: Run test to verify it passes**
Run: `npm test src/domain/get-user.test.ts`
Expected: PASS
**Step 5: Commit**
\`\`\`bash
git add src/domain/get-user.ts src/domain/get-user.test.ts
git commit -m "feat(user): add getUser with NOT_FOUND handling"
\`\`\`
docs/plans/YYYY-MM-DD-<feature-name>.mdBefore finalizing:
After saving the plan:
Plan complete and saved to `docs/plans/<filename>.md`.
Ready to execute? I'll follow TDD workflow for each task.
| Skill | Relationship |
|---|---|
design-exploration |
Design must be approved before planning |
tdd-workflow |
Tasks follow strict TDD cycle |
fn-args-deps |
New functions use fn(args, deps) pattern |
result-types |
Error handling uses Result types |