5-phase-workflow 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agents/feature-planner.md +4 -1
- package/src/commands/5/configure.md +0 -4
- package/src/commands/5/discuss-feature.md +0 -6
- package/src/commands/5/implement-feature.md +160 -34
- package/src/commands/5/plan-feature.md +34 -1
- package/src/commands/5/quick-implement.md +150 -22
- package/src/templates/workflow/STATE.json +8 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: feature-planner
|
|
3
3
|
description: Creates feature specifications from requirements through structured Q&A. Planning-only agent — never implements.
|
|
4
|
-
tools: Read, Write, Task, AskUserQuestion
|
|
4
|
+
tools: Read, Write, Task, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, TaskGet
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
<role>
|
|
@@ -21,12 +21,15 @@ HARD CONSTRAINTS — violations waste tokens and get blocked by plan-guard:
|
|
|
21
21
|
- The feature spec describes WHAT and WHY, never HOW
|
|
22
22
|
- If you feel the urge to implement, STOP and ask a clarifying question instead
|
|
23
23
|
- Your output is a SPECIFICATION, not a design document. No code. No file layouts. No API shapes.
|
|
24
|
+
- ALWAYS track progress using TaskCreate/TaskUpdate/TaskList. Mark each task `in_progress` before starting and `completed` when done. NEVER skip tasks. NEVER work on a later task while an earlier task is still pending.
|
|
25
|
+
- Before writing feature.md, call TaskList and verify tasks 1-6 are all `completed`. If any are not, go back and complete them.
|
|
24
26
|
</constraints>
|
|
25
27
|
|
|
26
28
|
<write-rules>
|
|
27
29
|
You have access to the Write tool for exactly these files:
|
|
28
30
|
1. `.5/.planning-active` — Step 0 only
|
|
29
31
|
2. `.5/features/{name}/feature.md` — Step 5 only
|
|
32
|
+
3. Task tracking tools (TaskCreate, TaskUpdate, TaskList, TaskGet) — used throughout to track progress
|
|
30
33
|
Any other Write target WILL be blocked by the plan-guard hook. Do not attempt it.
|
|
31
34
|
</write-rules>
|
|
32
35
|
|
|
@@ -421,8 +421,4 @@ Tell the user:
|
|
|
421
421
|
4. "After that: Continue with `/5:implement-feature CONFIGURE` -> `/5:verify-implementation` -> `/5:review-code` (clearing context between each phase)"
|
|
422
422
|
|
|
423
423
|
## Related Documentation
|
|
424
|
-
|
|
425
|
-
- [5-Phase Workflow Guide](../../docs/workflow-guide.md)
|
|
426
424
|
- [configure-project skill](../../skills/configure-project/SKILL.md)
|
|
427
|
-
- [/5:plan-feature command](./plan-feature.md)
|
|
428
|
-
- [/5:plan-implementation command](./plan-implementation.md)
|
|
@@ -251,9 +251,3 @@ Skill: "Feature spec updated. Changes:
|
|
|
251
251
|
- Added: Full CRUD operations
|
|
252
252
|
Next: /clear then /5:plan-implementation PROJ-1234-add-feature"
|
|
253
253
|
```
|
|
254
|
-
|
|
255
|
-
## Related Documentation
|
|
256
|
-
|
|
257
|
-
- [5-Phase Workflow Guide](../docs/workflow-guide.md)
|
|
258
|
-
- [plan-feature command](./plan-feature.md)
|
|
259
|
-
- [plan-implementation command](./plan-implementation.md)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: 5:implement-feature
|
|
3
3
|
description: Executes an implementation plan by delegating to agents. Phase 3 of the 5-phase workflow.
|
|
4
|
-
allowed-tools: Task, Read, Write, Glob, Grep, Bash
|
|
4
|
+
allowed-tools: Task, Read, Write, Glob, Grep, Bash, TaskCreate, TaskUpdate, TaskList
|
|
5
5
|
context: fork
|
|
6
6
|
user-invocable: true
|
|
7
7
|
---
|
|
@@ -21,7 +21,18 @@ You are a thin orchestrator:
|
|
|
21
21
|
- Track progress
|
|
22
22
|
- Report completion
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
**DO NOT:**
|
|
25
|
+
- Write code directly — spawn agents
|
|
26
|
+
- Skip state file updates between steps
|
|
27
|
+
- Mark a step complete before writing state
|
|
28
|
+
- Proceed to next step if state write fails
|
|
29
|
+
- Use `git add .` at any point
|
|
30
|
+
|
|
31
|
+
**Key Principles:**
|
|
32
|
+
- Thin orchestrator: read, delegate, track, report
|
|
33
|
+
- State is the source of truth: write it before moving on
|
|
34
|
+
- Forward progress: failed components are logged, not blocking
|
|
35
|
+
- Resumable: state enables restart from any interrupted step
|
|
25
36
|
|
|
26
37
|
## Process
|
|
27
38
|
|
|
@@ -43,9 +54,17 @@ Also read `.5/config.json` and extract:
|
|
|
43
54
|
- `git.autoCommit` (boolean, default `false`)
|
|
44
55
|
- `git.commitMessage.pattern` (string, default `{ticket-id} {short-description}`)
|
|
45
56
|
|
|
57
|
+
**Check for existing state.json** at `.5/features/{feature-name}/state.json`:
|
|
58
|
+
|
|
59
|
+
- **`status: "completed"`** → Tell the user "This feature is already implemented." Suggest `/5:verify-implementation {feature-name}`. Stop.
|
|
60
|
+
- **`status: "in-progress"`** → Tell the user "Resuming from step {currentStep}." Skip Step 2 initialization; go directly to Step 2b (recreate TaskCreate tasks) and Step 3 (resume from `currentStep`).
|
|
61
|
+
- **`status: "failed"`** → Use AskUserQuestion: "Implementation previously failed at step {currentStep}. How would you like to proceed?" with options: "Resume from step {currentStep}" / "Restart from the beginning"
|
|
62
|
+
- If Resume: proceed as in-progress case above
|
|
63
|
+
- If Restart: delete state.json, proceed normally from Step 2
|
|
64
|
+
|
|
46
65
|
### Step 2: Initialize State
|
|
47
66
|
|
|
48
|
-
Create `.5/features/{feature-name}/state.json
|
|
67
|
+
Create `.5/features/{feature-name}/state.json` with the full components table parsed from the plan:
|
|
49
68
|
|
|
50
69
|
```json
|
|
51
70
|
{
|
|
@@ -53,21 +72,45 @@ Create `.5/features/{feature-name}/state.json`:
|
|
|
53
72
|
"feature": "{feature-name}",
|
|
54
73
|
"status": "in-progress",
|
|
55
74
|
"currentStep": 1,
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
75
|
+
"totalSteps": "{N from plan}",
|
|
76
|
+
"pendingComponents": [
|
|
77
|
+
{ "name": "{component-name}", "step": 1, "file": "{file-path}" }
|
|
78
|
+
],
|
|
79
|
+
"completedComponents": [],
|
|
80
|
+
"failedAttempts": [],
|
|
81
|
+
"verificationResults": {},
|
|
82
|
+
"commitResults": [],
|
|
83
|
+
"startedAt": "{ISO-timestamp}",
|
|
84
|
+
"lastUpdated": "{ISO-timestamp}"
|
|
59
85
|
}
|
|
60
86
|
```
|
|
61
87
|
|
|
88
|
+
`pendingComponents` is populated by parsing the full components table from plan.md at startup — one entry per row.
|
|
89
|
+
|
|
90
|
+
**MANDATORY VERIFICATION:** Read state.json back immediately after writing. Confirm `status` is `"in-progress"` and `pendingComponents` is non-empty.
|
|
91
|
+
If the read fails or content is wrong, stop: "Failed to initialize state file. Cannot proceed safely."
|
|
92
|
+
|
|
62
93
|
Then remove the planning guard marker (planning is over, implementation is starting):
|
|
63
94
|
|
|
64
95
|
```bash
|
|
65
96
|
rm -f .5/.planning-active
|
|
66
97
|
```
|
|
67
98
|
|
|
99
|
+
### Step 2b: Create Progress Checklist
|
|
100
|
+
|
|
101
|
+
Before executing any steps, create one TaskCreate entry per step:
|
|
102
|
+
- Subject: `"Step {N}: {comma-separated component names}"`
|
|
103
|
+
- activeForm: `"Executing step {N}"`
|
|
104
|
+
|
|
105
|
+
Plus one final task:
|
|
106
|
+
- Subject: `"Run verification"`
|
|
107
|
+
- activeForm: `"Running build and tests"`
|
|
108
|
+
|
|
109
|
+
Then mark the task for Step 1 as `in_progress`.
|
|
110
|
+
|
|
68
111
|
### Step 3: Execute Steps
|
|
69
112
|
|
|
70
|
-
Group components by step number from the plan. For each step:
|
|
113
|
+
Group components by step number from the plan. For each step (starting from `currentStep` in state.json):
|
|
71
114
|
|
|
72
115
|
**3a. Analyze step for parallel execution**
|
|
73
116
|
|
|
@@ -110,32 +153,69 @@ The agent file defines the implementation process, output format, and deviation
|
|
|
110
153
|
**3d. Process results**
|
|
111
154
|
|
|
112
155
|
Collect results from all agents (parallel or sequential). Parse the `---RESULT---` block from each agent's response. For each:
|
|
113
|
-
- If `STATUS: success` →
|
|
114
|
-
- If `STATUS: failed` →
|
|
115
|
-
- If no `---RESULT---` block found → treat
|
|
156
|
+
- If `STATUS: success` → component succeeded; note files from `FILES_CREATED`/`FILES_MODIFIED`
|
|
157
|
+
- If `STATUS: failed` → component failed; log the `ERROR` message
|
|
158
|
+
- If no `---RESULT---` block found → treat as success if the agent reported creating/modifying files, otherwise treat as failed
|
|
116
159
|
|
|
117
160
|
Update state.json:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
161
|
+
- Move succeeded components: remove from `pendingComponents`, append to `completedComponents` as:
|
|
162
|
+
```json
|
|
163
|
+
{ "name": "{name}", "step": {N}, "timestamp": "{ISO}", "filesCreated": [...], "filesModified": [...] }
|
|
164
|
+
```
|
|
165
|
+
- Move failed components: append to `failedAttempts` as:
|
|
166
|
+
```json
|
|
167
|
+
{ "component": "{name}", "step": {N}, "error": "{message}", "timestamp": "{ISO}", "retryCount": 0 }
|
|
168
|
+
```
|
|
169
|
+
- Increment `currentStep`
|
|
170
|
+
- Update `lastUpdated`
|
|
171
|
+
|
|
172
|
+
**MANDATORY VERIFICATION:** Read state.json back and confirm `lastUpdated` changed.
|
|
173
|
+
If verify fails, stop: "State write failed after step {N}. Cannot proceed safely."
|
|
174
|
+
|
|
175
|
+
Mark the current step's TaskCreate task as `completed`. Mark the next step's task as `in_progress`.
|
|
176
|
+
|
|
177
|
+
**3d2. Retry failed components (max 2 retries)**
|
|
178
|
+
|
|
179
|
+
For each component that returned `STATUS: failed`:
|
|
180
|
+
|
|
181
|
+
1. **Assess the error:**
|
|
182
|
+
- **Small fix** (missing import, wrong path, syntax error): Fix with Edit tool directly in main context. Mark as completed. This counts as retry 1.
|
|
183
|
+
- **Large fix** (logic error, wrong pattern, missing context): Re-spawn the component-executor agent with the same prompt plus an `## Error Context` block describing the previous failure. This counts as retry 1.
|
|
184
|
+
|
|
185
|
+
2. If the retry also fails:
|
|
186
|
+
- Update `retryCount: 2` in the component's `failedAttempts` entry
|
|
187
|
+
- Use AskUserQuestion: "Component '{name}' failed twice. Error: {error}. How would you like to proceed?"
|
|
188
|
+
Options: "Skip and continue" / "I'll fix manually — pause"
|
|
189
|
+
- If "Skip": log the skip, move on
|
|
190
|
+
- If "Pause": update state.json with current progress, stop and wait for user
|
|
191
|
+
|
|
192
|
+
Never retry more than 2 times per component.
|
|
193
|
+
|
|
194
|
+
**3d3. Per-step file existence check**
|
|
195
|
+
|
|
196
|
+
For each file listed in `FILES_CREATED` from successful agents: use Glob to verify the file exists on disk.
|
|
197
|
+
|
|
198
|
+
If a reported file is missing:
|
|
199
|
+
- Remove the component from `completedComponents`
|
|
200
|
+
- Return it to `pendingComponents`
|
|
201
|
+
- Add a `failedAttempts` entry: `{ "component": "{name}", "step": {N}, "error": "File not found after creation: {path}", "timestamp": "{ISO}", "retryCount": 0 }`
|
|
202
|
+
- Apply retry logic from 3d2
|
|
125
203
|
|
|
126
204
|
**3e. Auto-Commit Step (if enabled)**
|
|
127
205
|
|
|
128
|
-
Only fires if `git.autoCommit: true` AND at least one component succeeded. Stage only the step's specific files (never `git add .`), commit with configured `git.commitMessage.pattern` (body: one bullet per component). If commit fails,
|
|
206
|
+
Only fires if `git.autoCommit: true` AND at least one component succeeded in this step. Stage only the step's specific files (from `FILES_CREATED`/`FILES_MODIFIED`; never `git add .`), commit with configured `git.commitMessage.pattern` (body: one bullet per component). If commit fails, append a warning entry to `commitResults` in state.json and continue.
|
|
129
207
|
|
|
130
208
|
**3f. Handle failures**
|
|
131
209
|
|
|
132
|
-
If any component failed:
|
|
133
|
-
-
|
|
210
|
+
If any component failed after retries exhausted:
|
|
211
|
+
- Entry remains in `failedAttempts` with `retryCount: 2`
|
|
134
212
|
- Continue to next step (don't block on failures)
|
|
135
|
-
-
|
|
213
|
+
- Failures are reported in the completion report
|
|
136
214
|
|
|
137
215
|
### Step 4: Run Verification
|
|
138
216
|
|
|
217
|
+
Mark the "Run verification" TaskCreate task as `in_progress`.
|
|
218
|
+
|
|
139
219
|
After all steps complete, run build and test:
|
|
140
220
|
|
|
141
221
|
```bash
|
|
@@ -146,10 +226,24 @@ After all steps complete, run build and test:
|
|
|
146
226
|
{test-command}
|
|
147
227
|
```
|
|
148
228
|
|
|
229
|
+
Update `verificationResults` in state.json:
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"buildStatus": "success|failed",
|
|
233
|
+
"testStatus": "success|skipped|failed",
|
|
234
|
+
"builtAt": "{ISO-timestamp}"
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
Also update `lastUpdated`.
|
|
238
|
+
|
|
239
|
+
**MANDATORY VERIFICATION:** Read state.json back and confirm `verificationResults.builtAt` is set.
|
|
240
|
+
|
|
149
241
|
If build or tests fail:
|
|
150
242
|
- Record in state.json
|
|
151
243
|
- Report to user with error details
|
|
152
244
|
|
|
245
|
+
Mark the "Run verification" TaskCreate task as `completed`.
|
|
246
|
+
|
|
153
247
|
### Step 5: Update State and Report
|
|
154
248
|
|
|
155
249
|
Update state.json:
|
|
@@ -157,22 +251,25 @@ Update state.json:
|
|
|
157
251
|
{
|
|
158
252
|
"status": "completed",
|
|
159
253
|
"completedAt": "{ISO-timestamp}",
|
|
160
|
-
"
|
|
161
|
-
"testStatus": "success|failed"
|
|
254
|
+
"lastUpdated": "{ISO-timestamp}"
|
|
162
255
|
}
|
|
163
256
|
```
|
|
164
257
|
|
|
258
|
+
**MANDATORY VERIFICATION:** Read state.json back and confirm `status` is `"completed"`.
|
|
259
|
+
If read fails, warn the user but do not re-attempt — the implementation work is done; only tracking failed.
|
|
260
|
+
|
|
165
261
|
Tell the user:
|
|
166
262
|
```
|
|
167
263
|
Implementation complete!
|
|
168
264
|
|
|
169
265
|
{ticket}: {feature-name}
|
|
170
266
|
- {N} components created/modified
|
|
267
|
+
- {M} components skipped (failures that exhausted retries)
|
|
171
268
|
- Build: {status}
|
|
172
269
|
- Tests: {status}
|
|
173
270
|
{If git.autoCommit was true: "- Commits: {N} atomic commits created"}
|
|
174
271
|
|
|
175
|
-
{If any failures: list them}
|
|
272
|
+
{If any failures: list them with errors}
|
|
176
273
|
|
|
177
274
|
Next steps:
|
|
178
275
|
1. Run `/clear` to reset context (recommended between phases)
|
|
@@ -181,18 +278,47 @@ Next steps:
|
|
|
181
278
|
|
|
182
279
|
## Handling Interruptions
|
|
183
280
|
|
|
184
|
-
If implementation is interrupted, the state file
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
281
|
+
If implementation is interrupted, the state file enables resuming:
|
|
282
|
+
|
|
283
|
+
1. Read state.json; note `currentStep`, `pendingComponents`, `completedComponents`, `lastUpdated`
|
|
284
|
+
2. For each component in `completedComponents`: use Glob to verify its files still exist on disk
|
|
285
|
+
3. If any file is missing: move the component back to `pendingComponents`, remove from `completedComponents`, adjust `currentStep` if all components for that step are now pending
|
|
286
|
+
4. Skip steps where ALL components are in `completedComponents` AND their files are verified present on disk
|
|
287
|
+
5. Write reconciled state (update `lastUpdated`) before re-executing any steps
|
|
190
288
|
|
|
191
289
|
## Example Flow
|
|
192
290
|
|
|
193
291
|
```
|
|
194
|
-
Step 1: 2 simple components → 2 parallel haiku agents → update state
|
|
195
|
-
Step 2: 2 moderate components → 2 parallel agents → update state
|
|
196
|
-
Step 3: 1 complex component → 1 sonnet agent → update state
|
|
197
|
-
Step 4: Verify (build + test) → update
|
|
292
|
+
Step 1: 2 simple components → 2 parallel haiku agents → update state → verify write
|
|
293
|
+
Step 2: 2 moderate components → 2 parallel agents → update state → verify write
|
|
294
|
+
Step 3: 1 complex component → 1 sonnet agent → update state → verify write
|
|
295
|
+
Step 4: Verify (build + test) → update verificationResults → verify write → report
|
|
198
296
|
```
|
|
297
|
+
|
|
298
|
+
## Instructions Summary
|
|
299
|
+
|
|
300
|
+
### Before starting:
|
|
301
|
+
1. Check for existing state.json → handle resume / restart / completed cases
|
|
302
|
+
2. Read plan.md → parse components table, implementation notes, verification commands
|
|
303
|
+
3. Read config.json → extract `git.autoCommit`, `git.commitMessage.pattern`
|
|
304
|
+
4. Initialize state.json with richer schema → **MANDATORY: verify write**
|
|
305
|
+
5. Create TaskCreate tasks for all steps + verification → mark step 1 `in_progress`
|
|
306
|
+
|
|
307
|
+
### For each step:
|
|
308
|
+
1. Determine parallelism (same-step components = parallel)
|
|
309
|
+
2. Determine model per component (simple→haiku, complex→sonnet)
|
|
310
|
+
3. Spawn agents (one per component, parallel when possible)
|
|
311
|
+
4. Collect results, parse `---RESULT---` blocks
|
|
312
|
+
5. Run per-step file existence check (Glob) on `FILES_CREATED`
|
|
313
|
+
6. Run retry logic for failures (max 2 retries per component)
|
|
314
|
+
7. Update state.json → **MANDATORY: verify write**
|
|
315
|
+
8. Run auto-commit if enabled and step had successes (stage specific files only)
|
|
316
|
+
9. Mark step task `completed`, mark next step task `in_progress`
|
|
317
|
+
|
|
318
|
+
### After all steps:
|
|
319
|
+
1. Run build command
|
|
320
|
+
2. Run test command
|
|
321
|
+
3. Update `verificationResults` in state.json → **verify write**
|
|
322
|
+
4. Update `status: "completed"` in state.json → **MANDATORY: verify write**
|
|
323
|
+
5. Mark verification task `completed`
|
|
324
|
+
6. Report to user
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: 5:plan-feature
|
|
3
3
|
description: Plans feature implementation by analyzing requirements, identifying affected modules, and creating a structured feature specification. Use at the start of any new feature to ensure systematic implementation. This is Phase 1 of the 5-phase workflow.
|
|
4
4
|
agent: feature-planner
|
|
5
|
-
allowed-tools: Read, Write, Task, AskUserQuestion
|
|
5
|
+
allowed-tools: Read, Write, Task, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, TaskGet
|
|
6
6
|
context: fork
|
|
7
7
|
user-invocable: true
|
|
8
8
|
---
|
|
@@ -43,8 +43,29 @@ Write the planning guard marker to `.5/.planning-active` using the Write tool:
|
|
|
43
43
|
|
|
44
44
|
This activates the plan-guard hook which prevents accidental source file edits during planning. The marker is removed automatically when implementation starts (`/5:implement-feature`), expires after 4 hours, or can be cleared manually with `/5:unlock`.
|
|
45
45
|
|
|
46
|
+
### Step 0b: Create Progress Checklist
|
|
47
|
+
|
|
48
|
+
Create a progress checklist using TaskCreate. Create all 8 tasks in order:
|
|
49
|
+
|
|
50
|
+
| # | Subject | activeForm | Description |
|
|
51
|
+
|---|---------|------------|-------------|
|
|
52
|
+
| 1 | Activate planning guard | Activating planning guard | Write `.5/.planning-active` marker |
|
|
53
|
+
| 2 | Gather feature description | Gathering feature description | Ask developer for feature description via AskUserQuestion |
|
|
54
|
+
| 3 | Extract ticket ID from branch | Extracting ticket ID | Extract from git branch, sanitize, confirm with developer |
|
|
55
|
+
| 4 | Explore codebase for patterns | Exploring codebase | Spawn Explore sub-agent for project analysis |
|
|
56
|
+
| 5 | Ask 5+ clarifying questions (one at a time) | Asking clarifying questions | Min. 5 questions, one at a time, via AskUserQuestion |
|
|
57
|
+
| 6 | Pre-write checkpoint | Running pre-write checkpoint | Verify 5+ Q&A, no code, spec contains only WHAT/WHY |
|
|
58
|
+
| 7 | Write feature specification | Writing feature specification | Create `.5/features/{ID}-{desc}/feature.md` |
|
|
59
|
+
| 8 | Output completion message and STOP | Completing planning phase | Output message, then STOP |
|
|
60
|
+
|
|
61
|
+
After creating all 8 tasks: Mark task 1 as `completed` (Step 0 is already done). Mark task 2 as `in_progress`.
|
|
62
|
+
|
|
63
|
+
> **MANDATORY:** Before starting ANY step, mark the corresponding task as `in_progress`. After completing, mark as `completed`. Never skip a task.
|
|
64
|
+
|
|
46
65
|
### Step 1: Gather Feature Description
|
|
47
66
|
|
|
67
|
+
> Task tracking: Mark "Gather feature description" → `in_progress` before, `completed` after.
|
|
68
|
+
|
|
48
69
|
Ask the developer for the feature description using AskUserQuestion:
|
|
49
70
|
|
|
50
71
|
"Please describe the feature you want to develop. Paste the full ticket description or explain it in your own words."
|
|
@@ -54,6 +75,8 @@ Ask the developer for the feature description using AskUserQuestion:
|
|
|
54
75
|
|
|
55
76
|
### Step 2: Extract Ticket ID
|
|
56
77
|
|
|
78
|
+
> Task tracking: Mark "Extract ticket ID" → `in_progress`/`completed`.
|
|
79
|
+
|
|
57
80
|
Extract the ticket ID from the current git branch:
|
|
58
81
|
- Use `git branch --show-current` via a Bash-free approach: spawn a quick Explore agent if needed
|
|
59
82
|
- Branch format: `{TICKET-ID}-description`
|
|
@@ -65,6 +88,8 @@ Extract the ticket ID from the current git branch:
|
|
|
65
88
|
|
|
66
89
|
### Step 3: Spawn Explore Agent for Codebase Analysis
|
|
67
90
|
|
|
91
|
+
> Task tracking: Mark "Explore codebase for patterns" → `in_progress`/`completed` when sub-agent returns.
|
|
92
|
+
|
|
68
93
|
Spawn a Task with `subagent_type=Explore`:
|
|
69
94
|
|
|
70
95
|
```
|
|
@@ -96,6 +121,8 @@ Wait for the sub-agent to return before proceeding.
|
|
|
96
121
|
|
|
97
122
|
### Step 4: Intensive Q&A (5-10 Questions, One at a Time)
|
|
98
123
|
|
|
124
|
+
> Task tracking: Mark "Ask 5+ clarifying questions" → `in_progress`. Do NOT mark `completed` until 5+ answers received.
|
|
125
|
+
|
|
99
126
|
Follow the `<question-strategy>` defined in your agent file.
|
|
100
127
|
|
|
101
128
|
**Optional re-exploration:** If the user mentions components not covered in the initial report, spawn a targeted Explore agent:
|
|
@@ -109,6 +136,8 @@ Targeted exploration for feature planning.
|
|
|
109
136
|
|
|
110
137
|
### Step 4b: Pre-Write Checkpoint
|
|
111
138
|
|
|
139
|
+
> Task tracking: Mark "Pre-write checkpoint" → `in_progress`. If fails (< 5 Q&A), mark questions task back to `in_progress` and return to Step 4.
|
|
140
|
+
|
|
112
141
|
Before writing the feature spec, verify:
|
|
113
142
|
1. You asked at least 5 questions and received answers
|
|
114
143
|
2. You have NOT written any code or implementation details
|
|
@@ -119,6 +148,8 @@ If you have fewer than 5 Q&A pairs, go back to Step 4 and ask more questions.
|
|
|
119
148
|
|
|
120
149
|
### Step 5: Create Feature Specification
|
|
121
150
|
|
|
151
|
+
> Task tracking: Mark "Write feature specification" → `in_progress`/`completed`.
|
|
152
|
+
|
|
122
153
|
Determine a feature name: short, kebab-case (e.g., "add-emergency-schedule").
|
|
123
154
|
|
|
124
155
|
Write to `.5/features/{TICKET-ID}-{description}/feature.md` using Write tool.
|
|
@@ -137,6 +168,8 @@ Populate all sections:
|
|
|
137
168
|
|
|
138
169
|
## PLANNING COMPLETE
|
|
139
170
|
|
|
171
|
+
> Task tracking: Mark "Output completion message and STOP" → `in_progress`. Before stopping, call TaskList to verify ALL 8 tasks are `completed`.
|
|
172
|
+
|
|
140
173
|
After writing feature.md, output exactly:
|
|
141
174
|
|
|
142
175
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: 5:quick-implement
|
|
3
3
|
description: Execute small, focused implementations quickly with state tracking and atomic commits. Skips extensive planning phases and verification agents - use for tasks where you know exactly what to do.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion, Skill, mcp__jetbrains__*
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, Task, AskUserQuestion, Skill, TaskCreate, TaskUpdate, TaskList, mcp__jetbrains__*
|
|
5
5
|
context: fork
|
|
6
6
|
user-invocable: true
|
|
7
7
|
---
|
|
@@ -30,6 +30,18 @@ Your job is NOT:
|
|
|
30
30
|
❌ Create feature spec files
|
|
31
31
|
❌ Commit without config (only if git.autoCommit is enabled)
|
|
32
32
|
|
|
33
|
+
**DO NOT:**
|
|
34
|
+
- Write code directly without using a Skill or spawning an agent
|
|
35
|
+
- Skip state file updates after each component
|
|
36
|
+
- Mark a component complete before writing state
|
|
37
|
+
- Proceed if a state write fails
|
|
38
|
+
- Use `git add .` at any point
|
|
39
|
+
|
|
40
|
+
**Key Principles:**
|
|
41
|
+
- Small scope: 1-5 files, treated as a single logical step
|
|
42
|
+
- State is the source of truth: write it after every component
|
|
43
|
+
- Resumable: state enables restart from the last completed component
|
|
44
|
+
|
|
33
45
|
## Process
|
|
34
46
|
|
|
35
47
|
### Step 1: Get Task Description
|
|
@@ -66,6 +78,15 @@ Generate a slug from `$DESCRIPTION` using string manipulation (do NOT use bash f
|
|
|
66
78
|
|
|
67
79
|
Set `feature_name` to `${TICKET_ID}-${slug}`.
|
|
68
80
|
|
|
81
|
+
### Step 3b: Check for Existing State
|
|
82
|
+
|
|
83
|
+
Check if `.5/features/${feature_name}/state.json` already exists:
|
|
84
|
+
|
|
85
|
+
- **`status: "completed"`** → Tell the user "This task is already implemented." Suggest `/clear` before starting a new task. Stop.
|
|
86
|
+
- **`status: "in-progress"`** → Use AskUserQuestion: "A previous run was interrupted at component '{last completed}'. How would you like to proceed?" Options: "Resume from where I left off" / "Restart from the beginning"
|
|
87
|
+
- If Resume: skip Steps 4–7 initialization; go directly to Step 7b (recreate TaskCreate tasks) and Step 8 (resume remaining `pendingComponents`)
|
|
88
|
+
- If Restart: delete state.json, proceed normally from Step 4
|
|
89
|
+
|
|
69
90
|
### Step 4: Analyze and Plan
|
|
70
91
|
|
|
71
92
|
1. **Identify affected files** using Glob and Grep
|
|
@@ -124,9 +145,32 @@ Use AskUserQuestion:
|
|
|
124
145
|
|
|
125
146
|
**CRITICAL**: You MUST create the state file before starting implementation. This enables resumability if work is interrupted.
|
|
126
147
|
|
|
127
|
-
Create state file at `.5/features/${feature_name}/state.json
|
|
148
|
+
Create state file at `.5/features/${feature_name}/state.json`:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"ticket": "{ticket-id}",
|
|
153
|
+
"feature": "{feature_name}",
|
|
154
|
+
"phase": "quick-implementation",
|
|
155
|
+
"status": "in-progress",
|
|
156
|
+
"currentStep": 1,
|
|
157
|
+
"totalSteps": 1,
|
|
158
|
+
"pendingComponents": [
|
|
159
|
+
{ "name": "{component-name}", "step": 1, "file": "{file-path}" }
|
|
160
|
+
],
|
|
161
|
+
"completedComponents": [],
|
|
162
|
+
"failedAttempts": [],
|
|
163
|
+
"verificationResults": {},
|
|
164
|
+
"commitResults": [],
|
|
165
|
+
"startedAt": "{ISO-timestamp}",
|
|
166
|
+
"lastUpdated": "{ISO-timestamp}"
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`pendingComponents` is populated from the approved plan's components table — one entry per row.
|
|
128
171
|
|
|
129
|
-
|
|
172
|
+
**MANDATORY VERIFICATION:** Read state.json back immediately after writing. Confirm `status` is `"in-progress"` and `pendingComponents` is non-empty.
|
|
173
|
+
If the read fails or content is wrong, stop: "Failed to initialize state file. Cannot proceed safely."
|
|
130
174
|
|
|
131
175
|
Then remove the planning guard marker (implementation is starting):
|
|
132
176
|
|
|
@@ -134,26 +178,51 @@ Then remove the planning guard marker (implementation is starting):
|
|
|
134
178
|
rm -f .5/.planning-active
|
|
135
179
|
```
|
|
136
180
|
|
|
181
|
+
### Step 7b: Create Progress Checklist
|
|
182
|
+
|
|
183
|
+
Create one TaskCreate entry per component:
|
|
184
|
+
- Subject: `"Implement {component-name}"`
|
|
185
|
+
- activeForm: `"Implementing {component-name}"`
|
|
186
|
+
|
|
187
|
+
Plus one final task:
|
|
188
|
+
- Subject: `"Run verification"`
|
|
189
|
+
- activeForm: `"Running build and tests"`
|
|
190
|
+
|
|
191
|
+
Mark the first component's task as `in_progress`.
|
|
192
|
+
|
|
137
193
|
### Step 8: Execute Implementation
|
|
138
194
|
|
|
139
195
|
**Decision criteria for execution approach:**
|
|
140
196
|
|
|
141
197
|
- **Direct execution** (1-2 components, simple edits): Execute skills directly in current context
|
|
142
|
-
- **
|
|
198
|
+
- **Agent delegation** (3+ components or complex work): Spawn a general-purpose agent
|
|
143
199
|
|
|
144
200
|
#### Direct Execution
|
|
145
201
|
|
|
146
|
-
For each component
|
|
202
|
+
For each component in `pendingComponents`:
|
|
147
203
|
1. Invoke appropriate skill using Skill tool
|
|
148
|
-
2.
|
|
204
|
+
2. Use Glob to verify `FILES_CREATED` exist on disk
|
|
205
|
+
3. **Update state file after each component** (MANDATORY):
|
|
149
206
|
- Read current state file
|
|
150
|
-
- Move component from `
|
|
207
|
+
- Move component from `pendingComponents` to `completedComponents`:
|
|
208
|
+
```json
|
|
209
|
+
{ "name": "{name}", "step": 1, "timestamp": "{ISO}", "filesCreated": [...], "filesModified": [...] }
|
|
210
|
+
```
|
|
151
211
|
- Update `lastUpdated` timestamp
|
|
152
212
|
- Write back to state file
|
|
153
|
-
- Verify write
|
|
154
|
-
|
|
213
|
+
- **Verify write:** Read state.json back and confirm `lastUpdated` changed. If verify fails, stop.
|
|
214
|
+
4. Mark component's TaskCreate task as `completed`. Mark next component's task as `in_progress`.
|
|
215
|
+
|
|
216
|
+
**If a component fails:**
|
|
217
|
+
- **Small fix** (syntax, import, path): Apply fix with Edit tool directly, retry the skill. Count as retry 1.
|
|
218
|
+
- **Large fix** (logic error, wrong pattern): Re-invoke skill with additional context. Count as retry 1.
|
|
219
|
+
- If retry also fails: Use AskUserQuestion: "Component '{name}' failed twice. Error: {error}. How to proceed?" Options: "Skip and continue" / "I'll fix manually — pause"
|
|
220
|
+
- Never retry more than 2 times. Record failures in `failedAttempts`:
|
|
221
|
+
```json
|
|
222
|
+
{ "component": "{name}", "step": 1, "error": "{message}", "timestamp": "{ISO}", "retryCount": {0|1|2} }
|
|
223
|
+
```
|
|
155
224
|
|
|
156
|
-
####
|
|
225
|
+
#### Agent Delegation
|
|
157
226
|
|
|
158
227
|
Determine the model based on the highest complexity in the plan's components:
|
|
159
228
|
- All components `simple` → `haiku`
|
|
@@ -191,8 +260,12 @@ Task tool call:
|
|
|
191
260
|
3. Verify the change
|
|
192
261
|
|
|
193
262
|
## Output
|
|
194
|
-
|
|
195
|
-
|
|
263
|
+
End your response with a ---RESULT--- block:
|
|
264
|
+
---RESULT---
|
|
265
|
+
STATUS: success|failed
|
|
266
|
+
FILES_CREATED: path/to/file1, path/to/file2
|
|
267
|
+
FILES_MODIFIED: path/to/file3
|
|
268
|
+
ERROR: {error message if failed}
|
|
196
269
|
|
|
197
270
|
## Rules
|
|
198
271
|
- Find patterns from existing code, don't invent conventions
|
|
@@ -200,16 +273,22 @@ Task tool call:
|
|
|
200
273
|
- Don't interact with user - just execute and report
|
|
201
274
|
```
|
|
202
275
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
-
|
|
209
|
-
-
|
|
276
|
+
After the agent returns:
|
|
277
|
+
1. Parse the `---RESULT---` block. If missing, treat as success if files were mentioned, otherwise failed.
|
|
278
|
+
2. **File existence check:** Use Glob to verify each file in `FILES_CREATED` exists on disk. If a file is missing, treat that component as failed.
|
|
279
|
+
3. **Retry logic:** For any `STATUS: failed` component or missing file, re-spawn the agent with an `## Error Context` block (counts as retry 1). If retry fails again, use AskUserQuestion as in direct execution.
|
|
280
|
+
4. **Update state file** (MANDATORY):
|
|
281
|
+
- Move succeeded components: remove from `pendingComponents`, append to `completedComponents` with structured object
|
|
282
|
+
- Move failed components: append to `failedAttempts` with `retryCount`
|
|
283
|
+
- Update `lastUpdated`
|
|
284
|
+
- Write back to state file
|
|
285
|
+
- **Verify write:** Read state.json back and confirm `lastUpdated` changed. If verify fails, stop.
|
|
286
|
+
5. Mark TaskCreate tasks: completed components → `completed`, remaining → adjust `in_progress`.
|
|
210
287
|
|
|
211
288
|
### Step 9: Verification
|
|
212
289
|
|
|
290
|
+
Mark the "Run verification" TaskCreate task as `in_progress`.
|
|
291
|
+
|
|
213
292
|
Run build verification if a build skill is configured:
|
|
214
293
|
|
|
215
294
|
**If build skill is available:**
|
|
@@ -232,17 +311,39 @@ Skill tool call:
|
|
|
232
311
|
args: "{affected test modules}"
|
|
233
312
|
```
|
|
234
313
|
|
|
314
|
+
Update `verificationResults` in state.json:
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"buildStatus": "success|failed",
|
|
318
|
+
"testStatus": "success|skipped|failed",
|
|
319
|
+
"builtAt": "{ISO-timestamp}"
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
Also update `lastUpdated`. **Verify write:** Read state.json back and confirm `verificationResults.builtAt` is set.
|
|
323
|
+
|
|
324
|
+
Mark the "Run verification" TaskCreate task as `completed`.
|
|
325
|
+
|
|
235
326
|
### Step 9b: Auto-Commit (if enabled)
|
|
236
327
|
|
|
237
|
-
Only fires if `git.autoCommit: true` AND build passed.
|
|
328
|
+
Only fires if `git.autoCommit: true` AND build passed. Stage only the component files (from `FILES_CREATED`/`FILES_MODIFIED`; never `git add .`), commit with configured `git.commitMessage.pattern` (body: one bullet per component). If commit fails, append a warning entry to `commitResults` in state.json and continue.
|
|
238
329
|
|
|
239
330
|
### Step 10: Update State and Report (MANDATORY)
|
|
240
331
|
|
|
241
332
|
**CRITICAL**: You MUST update the state file to mark completion.
|
|
242
333
|
|
|
243
|
-
Update state file
|
|
334
|
+
Update state file:
|
|
335
|
+
```json
|
|
336
|
+
{
|
|
337
|
+
"status": "completed",
|
|
338
|
+
"completedAt": "{ISO-timestamp}",
|
|
339
|
+
"lastUpdated": "{ISO-timestamp}"
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**MANDATORY VERIFICATION:** Read state.json back and confirm `status` is `"completed"`.
|
|
344
|
+
If read fails, warn the user but do not re-attempt — the implementation work is done; only tracking failed.
|
|
244
345
|
|
|
245
|
-
Report: ticket, description, files created/modified, build/test status, commit status (if auto-commit), and next steps (commit if needed, `/clear` before new task).
|
|
346
|
+
Report: ticket, description, files created/modified, build/test status, commit status (if auto-commit), skipped components (if any), and next steps (manual commit if needed, `/clear` before new task).
|
|
246
347
|
|
|
247
348
|
**🛑 YOUR JOB IS COMPLETE. DO NOT START NEW TASKS.**
|
|
248
349
|
|
|
@@ -260,3 +361,30 @@ Skills are project-specific and should be configured in your project's `.claude/
|
|
|
260
361
|
| Tests | Project-specific test skill |
|
|
261
362
|
| Simple edits | Edit tool directly |
|
|
262
363
|
|
|
364
|
+
## Instructions Summary
|
|
365
|
+
|
|
366
|
+
### Before starting:
|
|
367
|
+
1. Get task description from user
|
|
368
|
+
2. Extract and sanitize ticket ID from branch name
|
|
369
|
+
3. Generate `feature_name` slug
|
|
370
|
+
4. Check for existing state.json → handle resume / restart / completed cases
|
|
371
|
+
5. Analyze codebase, identify components (max 5)
|
|
372
|
+
6. Create plan.md → get user approval (iterate if needed)
|
|
373
|
+
7. Initialize state.json with richer schema → **MANDATORY: verify write**
|
|
374
|
+
8. Create TaskCreate tasks for all components + verification → mark first component `in_progress`
|
|
375
|
+
|
|
376
|
+
### For each component:
|
|
377
|
+
1. Invoke skill or spawn agent
|
|
378
|
+
2. Verify files exist on disk (Glob)
|
|
379
|
+
3. Apply retry logic if failed (max 2 retries per component)
|
|
380
|
+
4. Update state.json → **MANDATORY: verify write**
|
|
381
|
+
5. Mark component task `completed`, mark next task `in_progress`
|
|
382
|
+
|
|
383
|
+
### After all components:
|
|
384
|
+
1. Run build skill (if configured)
|
|
385
|
+
2. Run test skill (if affected)
|
|
386
|
+
3. Update `verificationResults` in state.json → **verify write**
|
|
387
|
+
4. Auto-commit if enabled (stage specific files only)
|
|
388
|
+
5. Update `status: "completed"` in state.json → **MANDATORY: verify write**
|
|
389
|
+
6. Mark verification task `completed`
|
|
390
|
+
7. Report to user
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
"feature": "{feature-name}",
|
|
4
4
|
"status": "in-progress",
|
|
5
5
|
"currentStep": 1,
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
6
|
+
"totalSteps": 0,
|
|
7
|
+
"pendingComponents": [],
|
|
8
|
+
"completedComponents": [],
|
|
9
|
+
"failedAttempts": [],
|
|
10
|
+
"verificationResults": {},
|
|
11
|
+
"commitResults": [],
|
|
12
|
+
"startedAt": "{ISO-timestamp}",
|
|
13
|
+
"lastUpdated": "{ISO-timestamp}"
|
|
9
14
|
}
|