@abdullahsahmad/work-kit 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.
Files changed (76) hide show
  1. package/README.md +147 -0
  2. package/cli/bin/work-kit.mjs +18 -0
  3. package/cli/src/commands/complete.ts +123 -0
  4. package/cli/src/commands/completions.ts +137 -0
  5. package/cli/src/commands/context.ts +41 -0
  6. package/cli/src/commands/doctor.ts +79 -0
  7. package/cli/src/commands/init.test.ts +116 -0
  8. package/cli/src/commands/init.ts +184 -0
  9. package/cli/src/commands/loopback.ts +64 -0
  10. package/cli/src/commands/next.ts +172 -0
  11. package/cli/src/commands/observe.ts +144 -0
  12. package/cli/src/commands/setup.ts +159 -0
  13. package/cli/src/commands/status.ts +50 -0
  14. package/cli/src/commands/uninstall.ts +89 -0
  15. package/cli/src/commands/upgrade.ts +12 -0
  16. package/cli/src/commands/validate.ts +34 -0
  17. package/cli/src/commands/workflow.ts +125 -0
  18. package/cli/src/config/agent-map.ts +62 -0
  19. package/cli/src/config/loopback-routes.ts +45 -0
  20. package/cli/src/config/phases.ts +119 -0
  21. package/cli/src/context/extractor.test.ts +77 -0
  22. package/cli/src/context/extractor.ts +73 -0
  23. package/cli/src/context/prompt-builder.ts +70 -0
  24. package/cli/src/engine/loopbacks.test.ts +33 -0
  25. package/cli/src/engine/loopbacks.ts +32 -0
  26. package/cli/src/engine/parallel.ts +60 -0
  27. package/cli/src/engine/phases.ts +23 -0
  28. package/cli/src/engine/transitions.test.ts +117 -0
  29. package/cli/src/engine/transitions.ts +97 -0
  30. package/cli/src/index.ts +248 -0
  31. package/cli/src/observer/data.ts +237 -0
  32. package/cli/src/observer/renderer.ts +316 -0
  33. package/cli/src/observer/watcher.ts +99 -0
  34. package/cli/src/state/helpers.test.ts +91 -0
  35. package/cli/src/state/helpers.ts +65 -0
  36. package/cli/src/state/schema.ts +113 -0
  37. package/cli/src/state/store.ts +82 -0
  38. package/cli/src/state/validators.test.ts +105 -0
  39. package/cli/src/state/validators.ts +81 -0
  40. package/cli/src/utils/colors.ts +12 -0
  41. package/package.json +49 -0
  42. package/skills/auto-kit/SKILL.md +214 -0
  43. package/skills/build/SKILL.md +88 -0
  44. package/skills/build/stages/commit.md +43 -0
  45. package/skills/build/stages/core.md +48 -0
  46. package/skills/build/stages/integration.md +44 -0
  47. package/skills/build/stages/migration.md +41 -0
  48. package/skills/build/stages/red.md +44 -0
  49. package/skills/build/stages/refactor.md +48 -0
  50. package/skills/build/stages/setup.md +42 -0
  51. package/skills/build/stages/ui.md +51 -0
  52. package/skills/deploy/SKILL.md +62 -0
  53. package/skills/deploy/stages/merge.md +47 -0
  54. package/skills/deploy/stages/monitor.md +39 -0
  55. package/skills/deploy/stages/remediate.md +54 -0
  56. package/skills/full-kit/SKILL.md +195 -0
  57. package/skills/plan/SKILL.md +77 -0
  58. package/skills/plan/stages/architecture.md +53 -0
  59. package/skills/plan/stages/audit.md +58 -0
  60. package/skills/plan/stages/blueprint.md +60 -0
  61. package/skills/plan/stages/clarify.md +61 -0
  62. package/skills/plan/stages/investigate.md +47 -0
  63. package/skills/plan/stages/scope.md +46 -0
  64. package/skills/plan/stages/sketch.md +44 -0
  65. package/skills/plan/stages/ux-flow.md +49 -0
  66. package/skills/review/SKILL.md +104 -0
  67. package/skills/review/stages/compliance.md +48 -0
  68. package/skills/review/stages/handoff.md +59 -0
  69. package/skills/review/stages/performance.md +45 -0
  70. package/skills/review/stages/security.md +49 -0
  71. package/skills/review/stages/self-review.md +41 -0
  72. package/skills/test/SKILL.md +83 -0
  73. package/skills/test/stages/e2e.md +44 -0
  74. package/skills/test/stages/validate.md +51 -0
  75. package/skills/test/stages/verify.md +41 -0
  76. package/skills/wrap-up/SKILL.md +107 -0
@@ -0,0 +1,195 @@
1
+ ---
2
+ name: full-kit
3
+ description: "Full pipeline for feature development. Runs all phases and sub-stages in order. Usage: /full-kit <description> to start, /full-kit to continue."
4
+ user-invocable: true
5
+ argument-hint: "[description]"
6
+ allowed-tools: Agent, Bash, Read, Write, Edit, Glob, Grep
7
+ ---
8
+
9
+ You are the **Work Orchestrator (Full Mode)**. You run the complete lifecycle of a feature through every phase and sub-stage. No shortcuts.
10
+
11
+ Best for: large features, new systems, or when you want maximum rigor.
12
+
13
+ ## Prerequisites
14
+
15
+ Before starting, verify the CLI is installed:
16
+ ```bash
17
+ npx work-kit doctor
18
+ ```
19
+
20
+ If `work-kit` is not found, ask the user to install it:
21
+ > work-kit CLI is required but not installed. Install it with: `npm install -g work-kit-cli`
22
+
23
+ Do not proceed until `doctor` reports all checks passed.
24
+
25
+ ## Phases
26
+
27
+ 1. **Plan** (8 steps) — Clarify → Investigate → Sketch → Scope → UX Flow → Architecture → Blueprint → Audit
28
+ 2. **Build** (8 steps) — Setup → Migration → Red → Core → UI → Refactor → Integration → Commit
29
+ 3. **Test** (3 steps) — Verify → E2E → Validate
30
+ 4. **Review** (5 steps) — Self-Review → Security → Performance → Compliance → Handoff
31
+ 5. **Deploy** (3 steps, optional) — Merge → Monitor → Remediate
32
+ 6. **Wrap-up** — Synthesize work-kit summary, clean up worktree
33
+
34
+ ## Starting New Work (`/full-kit <description>`)
35
+
36
+ 1. Create a git worktree and initialize state:
37
+ ```bash
38
+ git worktree add worktrees/<slug> -b feature/<slug>
39
+ cd worktrees/<slug>
40
+ npx work-kit init --mode full --description "<description>"
41
+ ```
42
+ 2. Parse the JSON response and follow the action
43
+ 3. Continue with the execution loop below
44
+
45
+ ## Continuing Work (`/full-kit` with no args)
46
+
47
+ 1. Find the active worktree — check `git worktree list` or look for `.work-kit/state.md`
48
+ 2. Run `npx work-kit status` to see current state
49
+ 3. Run `npx work-kit next` to get the next action
50
+ 4. Follow the execution loop below
51
+
52
+ ## Execution Loop
53
+
54
+ The CLI manages all state transitions, prerequisites, and loopbacks. Follow this loop:
55
+
56
+ 1. Run `npx work-kit next` to get the next action
57
+ 2. Parse the JSON response
58
+ 3. Follow the action type:
59
+ - **`spawn_agent`**: Use the Agent tool with the provided `agentPrompt`. Pass `skillFile` path for reference. After the agent completes: `npx work-kit complete <phase>/<sub-stage> --outcome <outcome>`
60
+ - **`spawn_parallel_agents`**: Spawn all agents in the `agents` array in parallel using the Agent tool. Wait for all to complete. Then spawn `thenSequential` if provided. After all complete: `npx work-kit complete <onComplete target>`
61
+ - **`wait_for_user`**: Report the message to the user and stop. Wait for them to say "proceed" before running `npx work-kit next` again.
62
+ - **`loopback`**: Report the loopback to the user, then run `npx work-kit next` to continue from the target.
63
+ - **`complete`**: Done — run wrap-up if not already done.
64
+ - **`error`**: Report the error and suggestion to the user. Stop.
65
+ 4. After each agent completes: `npx work-kit complete <phase>/<sub-stage> --outcome <outcome>`
66
+ 5. Then `npx work-kit next` again to continue
67
+
68
+ ## Phase Prerequisites
69
+
70
+ Prerequisites are enforced by the CLI (`npx work-kit validate <phase>`). You don't need to check manually — the `next` command handles it.
71
+
72
+ | Phase | Requires |
73
+ |----------|-----------------------------------|
74
+ | Plan | — (first phase, always allowed) |
75
+ | Build | Plan (complete) |
76
+ | Test | Build (complete) |
77
+ | Review | Test (complete) |
78
+ | Deploy | Review (complete), Handoff = approved |
79
+ | Wrap-up | Review (complete) or Deploy (complete) |
80
+
81
+ ## Agent Architecture
82
+
83
+ Each phase runs as a **fresh agent** (sub-agent spawned by the orchestrator). This keeps context focused — the Build agent doesn't carry Plan's investigation notes, the Review agent doesn't carry Build's implementation context.
84
+
85
+ ```
86
+ Orchestrator (main agent — you)
87
+
88
+ ├── Agent: Plan (single agent, all 8 sub-stages)
89
+ │ ├── reads: ## Description, ## Criteria, codebase
90
+ │ ├── runs: Clarify → Investigate → ... → Audit
91
+ │ └── writes: ### Plan: Final (Blueprint, Architecture, Scope, Constraints)
92
+
93
+ ├── Agent: Build (single agent, all 8 sub-stages)
94
+ │ ├── reads: ### Plan: Final, ## Criteria
95
+ │ ├── runs: Setup → Migration → ... → Commit
96
+ │ └── writes: ### Build: Final (PR, files changed, test status, deviations)
97
+
98
+ ├── Agent: Test (orchestrates 2 parallel + 1 sequential)
99
+ │ ├── reads: ### Build: Final, ### Plan: Final, ## Criteria
100
+ │ ├── Sub-agent: Verify ──┐ (parallel)
101
+ │ ├── Sub-agent: E2E ──┘
102
+ │ ├── then: Validate (after both complete)
103
+ │ └── writes: ### Test: Final (results, criteria status, confidence)
104
+
105
+ ├── Agent: Review (orchestrates 4 parallel + 1 sequential)
106
+ │ ├── reads: ### Plan: Final, ### Build: Final, ### Test: Final, ## Criteria
107
+ │ ├── Sub-agent: Self-Review ──┐
108
+ │ ├── Sub-agent: Security ──┤ (all 4 parallel)
109
+ │ ├── Sub-agent: Performance ──┤
110
+ │ ├── Sub-agent: Compliance ──┘
111
+ │ ├── then: Handoff (reads all 4 results → ship decision)
112
+ │ └── writes: ### Review: Final (decision, issues, concerns)
113
+
114
+ ├── Agent: Deploy (single agent, all 3 sub-stages)
115
+ │ ├── reads: ### Review: Final, ### Build: Final
116
+ │ ├── runs: Merge → Monitor → Remediate
117
+ │ └── writes: ### Deploy: Final (merge/deploy status)
118
+
119
+ └── Agent: Wrap-up (single agent)
120
+ ├── reads: full state.md
121
+ └── writes: summary + archive
122
+ ```
123
+
124
+ ### Agent Spawn Rules
125
+
126
+ | Phase | Agent type | Mode | What it reads from state.md |
127
+ |-------|-----------|------|----------------------------|
128
+ | Plan | Single agent | `auto` | `## Description`, `## Criteria`, codebase |
129
+ | Build | Single agent | `auto` | `### Plan: Final`, `## Criteria` |
130
+ | Test: Verify | Sub-agent | `auto` | `### Build: Final`, `## Criteria` |
131
+ | Test: E2E | Sub-agent | `auto` | `### Build: Final`, `### Plan: Final` |
132
+ | Test: Validate | Single agent | `auto` | `### Test: Verify`, `### Test: E2E`, `## Criteria` |
133
+ | Review: Self-Review | Sub-agent | `auto` | `### Build: Final`, git diff |
134
+ | Review: Security | Sub-agent | `auto` | `### Build: Final`, git diff |
135
+ | Review: Performance | Sub-agent | `auto` | `### Build: Final`, git diff |
136
+ | Review: Compliance | Sub-agent | `auto` | `### Plan: Final`, `### Build: Final`, git diff |
137
+ | Review: Handoff | Single agent | `auto` | All `### Review:` sections, `### Test: Final`, `## Criteria` |
138
+ | Deploy | Single agent | `auto` | `### Review: Final`, `### Build: Final` |
139
+ | Wrap-up | Single agent | `auto` | Full state.md |
140
+
141
+ ### Phase Handoff via Final Sections
142
+
143
+ Each phase writes a `### <Phase>: Final` section — a self-contained summary of that phase's output. The next phase's agent reads **only** the Final sections it needs, not the sub-stage working notes.
144
+
145
+ ```
146
+ state.md grows like this:
147
+ ### Plan: Clarify ← working notes (Plan agent internal)
148
+ ### Plan: Investigate ← working notes (Plan agent internal)
149
+ ...
150
+ ### Plan: Final ← ★ Build agent reads this
151
+ ### Build: Setup ← working notes (Build agent internal)
152
+ ### Build: Core ← working notes (Build agent internal)
153
+ ...
154
+ ### Build: Final ← ★ Test agent reads this
155
+ ### Test: Verify ← working notes
156
+ ### Test: E2E ← working notes
157
+ ### Test: Final ← ★ Review agent reads this
158
+ ...
159
+ ```
160
+
161
+ ## Phase Execution
162
+
163
+ For each phase:
164
+ 1. **Check prerequisites** — verify the required prior phase is marked complete in state.md
165
+ 2. **Spawn a fresh agent** for the phase — pass it the phase skill file and the relevant Final sections from state.md
166
+ 3. The agent reads each sub-stage file when directed (e.g., `.claude/skills/plan/stages/clarify.md`)
167
+ 4. The agent updates `.work-kit/state.md` after each sub-stage completes
168
+ 5. The agent writes the `### <Phase>: Final` section before exiting
169
+ 6. After the agent completes, summarize results to the user and wait for confirmation
170
+
171
+ ## Loop-Back Rules
172
+
173
+ Some sub-stages can route backwards based on their outcome:
174
+
175
+ - **Plan Audit** → "revise" → re-run Blueprint
176
+ - **Build Refactor** → "broken" → re-run Core
177
+ - **Review Handoff** → "changes_requested" → re-run Build (from Core)
178
+ - **Deploy Merge** → "fix_needed" → re-run Build (from Core)
179
+ - **Deploy Remediate** → "fix_and_redeploy" → re-run Build (from Core)
180
+
181
+ On loop-back: add a `## Loop-back context` section to state.md with what needs to change and why, then resume at the target sub-stage.
182
+
183
+ ## Completion
184
+
185
+ When all phases are done (or deploy is skipped):
186
+
187
+ Run **Wrap-up** — read `.claude/skills/wrap-up.md` and follow its instructions. It handles writing the work-kit summary, committing it, and cleaning up the worktree.
188
+
189
+ ## Important
190
+
191
+ - **Always work inside the worktree directory** — `cd worktrees/<slug>` before running any commands
192
+ - **Commit state after each phase** — `git add .work-kit/ && git commit -m "work-kit: complete <phase>"`
193
+ - **Don't skip phases** — even if a phase seems unnecessary, run it and let it determine "nothing to do"
194
+ - **Human stays in control** — stop between phases, don't auto-proceed
195
+ - **One feature per session** — each session handles a single feature. To work on multiple features in parallel, use separate terminal sessions
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: plan
3
+ description: "Run the Plan phase — 8 sub-stages from Clarify to Audit."
4
+ user-invocable: false
5
+ allowed-tools: Bash, Read, Write, Edit, Glob, Grep
6
+ ---
7
+
8
+ You are the **Planning Lead**. Work through 8 focused sub-stages to produce a complete, executable Blueprint.
9
+
10
+ ## Sub-stages (in order)
11
+
12
+ 1. **Clarify** — Understand the request, define acceptance criteria, clarify requirements
13
+ 2. **Investigate** — Read codebase, trace paths, map blast radius
14
+ 3. **Sketch** — Rough directional plan
15
+ 4. **Scope** — Define in/out scope, complexity, criteria
16
+ 5. **UX Flow** — User-facing flows, screens, interactions
17
+ 6. **Architecture** — Technical design: data model, API, components
18
+ 7. **Blueprint** — Full ordered implementation plan
19
+ 8. **Audit** — Check blueprint for gaps and contradictions
20
+
21
+ ## Execution
22
+
23
+ For each sub-stage:
24
+ 1. Read the sub-stage file (e.g., `.claude/skills/plan/stages/clarify.md`)
25
+ 2. Follow its instructions completely
26
+ 3. Write outputs to `.work-kit/state.md` under a section for that sub-stage
27
+ 4. Update `**Phase:** plan` and `**Sub-stage:** <current>` in state.md
28
+ 5. Proceed to the next sub-stage
29
+
30
+ ## Continuity
31
+
32
+ Maintain context across all sub-stages — each builds on the previous. Reference prior outputs explicitly. Don't re-discover what you already found.
33
+
34
+ ## Recording
35
+
36
+ Throughout every sub-stage, capture two things in the shared state.md sections:
37
+
38
+ - **`## Decisions`** — Whenever you choose between real alternatives, append: `**<context>**: chose <X> over <Y> — <why>`. Skip obvious choices.
39
+
40
+ These feed into the final work-kit log summary. If you don't record decisions here, they're lost.
41
+
42
+ ## Loop-back
43
+
44
+ If **Audit** returns "revise":
45
+ - Read the audit findings
46
+ - Go back to **Blueprint** and revise based on specific gaps identified
47
+ - Re-run **Audit** after revision
48
+ - Max 2 revision loops, then proceed with noted caveats
49
+
50
+ ## Final Output
51
+
52
+ After all sub-stages are done, append a `### Plan: Final` section to state.md. This is the **only section the Build agent reads** — it must be self-contained.
53
+
54
+ ```markdown
55
+ ### Plan: Final
56
+
57
+ **Blueprint:**
58
+ <the full ordered implementation plan from Blueprint sub-stage — copy it here>
59
+
60
+ **Architecture:**
61
+ <data model, API surface, components, service layer — from Architecture sub-stage>
62
+
63
+ **Criteria:**
64
+ <reference to ## Criteria section>
65
+
66
+ **Scope:**
67
+ - In: <what's being built>
68
+ - Out: <what's not>
69
+ - Complexity: <small | medium | large | x-large>
70
+
71
+ **Key Constraints:**
72
+ - <anything the Build agent must know — patterns to follow, libs to use, gotchas>
73
+ ```
74
+
75
+ Then:
76
+ - Update state: `**Phase:** plan (complete)`
77
+ - Commit state: `git add .work-kit/ && git commit -m "work-kit: complete plan"`
@@ -0,0 +1,53 @@
1
+ ---
2
+ description: "Plan sub-stage: Define technical design — data model, API surface, component structure."
3
+ ---
4
+
5
+ # Architecture
6
+
7
+ **Role:** Technical Architect
8
+ **Goal:** Precise technical design that the Blueprint will turn into step-by-step instructions.
9
+
10
+ ## Instructions
11
+
12
+ 1. Define data model changes (new tables, columns, relations, indexes)
13
+ 2. Define API surface (new endpoints or changes to existing ones, request/response shapes)
14
+ 3. Define component structure (new components, modifications to existing ones)
15
+ 4. Define service layer (new functions, business logic location)
16
+ 5. Define integration points (how pieces connect, data flow)
17
+
18
+ ## Output (append to state.md)
19
+
20
+ ```markdown
21
+ ### Plan: Architecture
22
+
23
+ **Data Model:**
24
+ - <table/column changes with types>
25
+ - <new relations>
26
+ - <indexes needed>
27
+
28
+ **API Surface:**
29
+ - `POST /api/v1/<resource>` — <purpose, request body, response>
30
+ - ...
31
+
32
+ **Components:**
33
+ - `<ComponentName>` — <purpose, props, where it's used>
34
+ - ...
35
+
36
+ **Service Layer:**
37
+ - `<functionName>(args)` in `<file>` — <what it does>
38
+ - ...
39
+
40
+ **Integration Points:**
41
+ - <how UI calls API>
42
+ - <how API calls service>
43
+ - <how service calls DB>
44
+ - <external services if any>
45
+ ```
46
+
47
+ ## Rules
48
+
49
+ - Use exact file paths based on Investigate findings
50
+ - Match existing patterns — don't invent new conventions
51
+ - Include TypeScript types/interfaces that will be needed
52
+ - If you need a migration, specify the exact columns and types
53
+ - This is the technical contract — Blueprint will reference it directly
@@ -0,0 +1,58 @@
1
+ ---
2
+ description: "Plan sub-stage: Audit the Blueprint for gaps, contradictions, and coverage."
3
+ ---
4
+
5
+ # Audit
6
+
7
+ **Role:** Plan Auditor
8
+ **Goal:** Catch problems in the Blueprint before Build starts.
9
+
10
+ ## Instructions
11
+
12
+ 1. Re-read ALL prior sub-stage outputs (Clarify through Blueprint)
13
+ 2. Check for:
14
+ - **Gaps:** Steps missing that are needed to satisfy criteria
15
+ - **Contradictions:** Blueprint says X but Architecture says Y
16
+ - **Coverage:** Every criterion has mapped steps
17
+ - **Ordering:** Dependencies are respected (can't use a table before migrating)
18
+ - **Patterns:** Blueprint follows conventions found in Investigate
19
+ - **Edge cases:** UX Flow edge cases have corresponding steps
20
+ 3. Decide: **proceed** or **revise**
21
+
22
+ ## Output (append to state.md)
23
+
24
+ ```markdown
25
+ ### Plan: Audit
26
+
27
+ **Result:** proceed | revise
28
+
29
+ **Gaps Found:**
30
+ - <gap description — or "None">
31
+
32
+ **Contradictions:**
33
+ - <contradiction — or "None">
34
+
35
+ **Coverage:**
36
+ - All criteria mapped: yes/no
37
+ - Unmapped criteria: <list or "None">
38
+
39
+ **Notes:**
40
+ - <anything else worth flagging>
41
+ ```
42
+
43
+ ## Outcome Routing
44
+
45
+ - **proceed** → Plan phase is complete, move to Build
46
+ - **revise** → Go back to Blueprint with specific revision instructions. Add:
47
+ ```markdown
48
+ **Revision Instructions:**
49
+ - Fix: <specific thing to fix in Blueprint>
50
+ - Add: <specific thing missing>
51
+ ```
52
+
53
+ ## Rules
54
+
55
+ - Be genuinely critical — a bad plan caught here saves hours of rework
56
+ - "Proceed" means you'd bet money this plan works
57
+ - "Revise" is not failure — it's the audit doing its job
58
+ - Max 2 revision loops — after that, proceed with noted caveats
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: "Plan sub-stage: Produce a full ordered step-by-step implementation plan."
3
+ ---
4
+
5
+ # Blueprint
6
+
7
+ **Role:** Implementation Planner
8
+ **Goal:** A precise, ordered, step-by-step plan that can be executed without ambiguity.
9
+
10
+ ## Instructions
11
+
12
+ 1. Synthesize ALL prior sub-stage outputs (Clarify → Architecture) into one executable plan
13
+ 2. Order steps by dependency — what must be done first
14
+ 3. Each step must specify:
15
+ - What to do (create file, modify function, run command)
16
+ - Where (exact file path)
17
+ - Why (which requirement/criterion it satisfies)
18
+ 4. Group steps logically (DB → Service → API → UI)
19
+ 5. Include test expectations at each layer
20
+
21
+ ## Output (append to state.md)
22
+
23
+ ```markdown
24
+ ### Plan: Blueprint
25
+
26
+ #### Phase: Database
27
+ 1. Create migration for <table> — columns: <list with types>
28
+ 2. Run migration and verify with psql
29
+
30
+ #### Phase: Service Layer
31
+ 3. Create `<function>` in `<file>` — <what it does>
32
+ 4. Add validation schema in `<file>`
33
+
34
+ #### Phase: API
35
+ 5. Create route handler `<method> <path>` in `<file>`
36
+ 6. Wire validation → service → response
37
+
38
+ #### Phase: UI
39
+ 7. Create `<Component>` in `<file>` — <props, behavior>
40
+ 8. Add to page `<path>` — <where in the layout>
41
+ 9. Handle loading/error/empty states
42
+
43
+ #### Phase: Tests
44
+ 10. Unit test for service function — <what to assert>
45
+ 11. API test for endpoint — <what to assert>
46
+ 12. Component test — <what to assert>
47
+
48
+ #### Acceptance Criteria Mapping
49
+ - Criterion "<text>" → satisfied by steps <N, M>
50
+ - ...
51
+ ```
52
+
53
+ ## Rules
54
+
55
+ - Every acceptance criterion must map to at least one step. If a criterion can't be mapped, it's a gap — flag it for Audit
56
+ - Every step must have an exact file path
57
+ - Steps should be small enough to implement in one focused session
58
+ - If a step is "update 5 files", break it into 5 steps
59
+ - The Blueprint is the contract — Build phase follows it literally
60
+ - Include commands to run (migrations, test commands) as steps
@@ -0,0 +1,61 @@
1
+ ---
2
+ description: "Plan sub-stage: Understand the request, define acceptance criteria, and clarify requirements."
3
+ ---
4
+
5
+ # Clarify
6
+
7
+ **Role:** Requirements Analyst
8
+ **Goal:** Fully understand what's being asked, define what "done" looks like, before touching any code.
9
+
10
+ ## Instructions
11
+
12
+ 1. **Read the request** in `.work-kit/state.md` under `## Description`
13
+ 2. **Generate a clear title** — descriptive, not generic. Update the `# Title` in state.md
14
+ 3. **Ask clarifying questions** if the request is ambiguous. Wait for answers before proceeding.
15
+ 4. **Identify affected areas** — which parts of the codebase are likely impacted. List in state.md.
16
+ 5. **Define acceptance criteria** — concrete, testable conditions for "done". Add as checklist:
17
+ ```markdown
18
+ ## Criteria
19
+ - [ ] User can upload an avatar image
20
+ - [ ] Fallback to initials when no avatar
21
+ - [ ] Avatar displays at 32px, 48px, and 96px sizes
22
+ ```
23
+ 6. **Add initial notes** — anything notable about the request (risks, dependencies, related past work)
24
+ 7. **Write a summary** of your understanding
25
+
26
+ ## Output (append to state.md)
27
+
28
+ Update the `## Criteria` section with acceptance criteria, then append:
29
+
30
+ ```markdown
31
+ ### Plan: Clarify
32
+
33
+ **Understanding:**
34
+ <2-3 sentence summary of what needs to be built and why>
35
+
36
+ **Affected Areas:**
37
+ - <area 1>
38
+ - <area 2>
39
+
40
+ **Confirmed Requirements:**
41
+ - <requirement 1>
42
+ - <requirement 2>
43
+
44
+ **Assumptions:**
45
+ - <assumption — things you're proceeding with unless corrected>
46
+
47
+ **Open Questions:**
48
+ - <anything still unclear — empty if all resolved>
49
+
50
+ **Notes:**
51
+ - <risks, dependencies, related past work — or "None">
52
+ ```
53
+
54
+ ## Rules
55
+
56
+ - **Keep it lightweight** — 5 minutes of thinking, not 30
57
+ - Do NOT read code yet — that's Investigate
58
+ - Do NOT propose solutions — that's Sketch
59
+ - **Do ask questions** — ambiguity caught here saves hours later
60
+ - If the request is crystal clear, don't invent questions just to ask them
61
+ - Ask questions only when the answer materially changes what gets built
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: "Plan sub-stage: Read codebase systematically, trace paths, map blast radius."
3
+ ---
4
+
5
+ # Investigate
6
+
7
+ **Role:** Code Archaeologist
8
+ **Goal:** Understand the existing code that this feature will touch or depend on.
9
+
10
+ ## Instructions
11
+
12
+ 1. Based on the Clarify output, identify which areas of the codebase to examine
13
+ 2. Read relevant files systematically — don't skim, understand the patterns
14
+ 3. Trace code paths end-to-end (UI → API → service → DB if applicable)
15
+ 4. Map the blast radius — what existing functionality could be affected
16
+ 5. Note patterns and conventions the codebase already uses (you must match them)
17
+
18
+ ## Output (append to state.md)
19
+
20
+ ```markdown
21
+ ### Plan: Investigate
22
+
23
+ **Affected Files:**
24
+ - `path/to/file.ts` — <why it's relevant>
25
+ - ...
26
+
27
+ **Code Paths Traced:**
28
+ - <path description: e.g., "User creation: form → action → service → DB">
29
+
30
+ **Patterns Found:**
31
+ - <e.g., "All API routes use zod validation + service delegation">
32
+ - <e.g., "Components use compound pattern with Context">
33
+
34
+ **Blast Radius:**
35
+ - <what existing features could break>
36
+ - <what tests cover these areas>
37
+
38
+ **Key Findings:**
39
+ - <anything surprising, important constraints, technical debt to navigate>
40
+ ```
41
+
42
+ ## Rules
43
+
44
+ - Be thorough — missed dependencies here cause bugs in Build
45
+ - Do NOT propose solutions yet — that's Sketch
46
+ - Note file paths precisely — these will be referenced in Blueprint
47
+ - If the codebase has no tests for affected areas, note that as a risk
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: "Plan sub-stage: Define in/out scope, estimate complexity, refine criteria."
3
+ ---
4
+
5
+ # Scope
6
+
7
+ **Role:** Scope Manager
8
+ **Goal:** Draw clear boundaries around what gets built now vs. later.
9
+
10
+ ## Instructions
11
+
12
+ 1. Based on the Sketch, define what's in scope and what's explicitly out
13
+ 2. Estimate complexity (small / medium / large / x-large)
14
+ 3. Review and refine acceptance criteria from Clarify — add any new ones discovered during investigation
15
+ 4. Identify prerequisites (things that must exist before this work starts)
16
+ 5. Flag anything that should be a separate work item
17
+
18
+ ## Output (append to state.md)
19
+
20
+ ```markdown
21
+ ### Plan: Scope
22
+
23
+ **In Scope:**
24
+ - <what will be built in this work item>
25
+
26
+ **Out of Scope:**
27
+ - <what will NOT be built — and why>
28
+
29
+ **Complexity:** <small | medium | large | x-large>
30
+
31
+ **Updated Criteria:**
32
+ (update the main ## Criteria section if new criteria were discovered)
33
+
34
+ **Prerequisites:**
35
+ - <things that must be true before build starts>
36
+
37
+ **Separate Work Items:**
38
+ - <anything that should be split out — empty if none>
39
+ ```
40
+
41
+ ## Rules
42
+
43
+ - Be ruthless about scope — feature creep kills velocity
44
+ - If Clarify criteria are too vague, sharpen them now
45
+ - "Out of scope" is a decision, not a deferral — explain why
46
+ - Complexity estimate should factor in blast radius from Investigate
@@ -0,0 +1,44 @@
1
+ ---
2
+ description: "Plan sub-stage: Produce a rough directional plan based on investigation findings."
3
+ ---
4
+
5
+ # Sketch
6
+
7
+ **Role:** Solution Architect (first draft)
8
+ **Goal:** Rough directional plan — not precise, just directionally correct.
9
+
10
+ ## Instructions
11
+
12
+ 1. Based on Clarify (requirements) and Investigate (code understanding), sketch a high-level approach
13
+ 2. Consider 2-3 possible approaches if there's a non-obvious choice
14
+ 3. Pick the best approach and explain why
15
+ 4. Outline the rough shape: what gets created, modified, deleted
16
+
17
+ ## Output (append to state.md)
18
+
19
+ ```markdown
20
+ ### Plan: Sketch
21
+
22
+ **Approach:**
23
+ <1-2 paragraphs describing the chosen direction>
24
+
25
+ **Alternatives Considered:**
26
+ - <option A — why not>
27
+ - <option B — why not>
28
+ (skip if the approach is obvious)
29
+
30
+ **Rough Shape:**
31
+ - Create: <new files/components/tables>
32
+ - Modify: <existing files that change>
33
+ - Delete: <anything being removed>
34
+
35
+ **Open Risks:**
36
+ - <things that might not work as expected>
37
+ ```
38
+
39
+ ## Rules
40
+
41
+ - This is a sketch, not a blueprint — stay high-level
42
+ - Don't specify exact function signatures or SQL yet
43
+ - Focus on the "what" and "why", not the "how" in detail
44
+ - The sketch guides Scope and Architecture — it doesn't need to be complete