@chris1807/claude-kit 2.1.4 → 2.1.8

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/bin/cli.js CHANGED
@@ -178,7 +178,7 @@ async function main() {
178
178
  choices: [
179
179
  { name: 'Project Agents (deployer, db-admin, devops-tracker)', value: 'agents', checked: true },
180
180
  { name: 'Hooks (secret blocker, auto-format, test suggestions)', value: 'hooks', checked: true },
181
- { name: 'Slash Commands (11 commands — implement, review, deploy, releases, cherry-pick, promote, rollback, status, cleanup)', value: 'commands', checked: true },
181
+ { name: 'Slash Commands (implement, review, deploy, releases, cherry-pick, promote, rollback, status, cleanup, create-work-item, …)', value: 'commands', checked: true },
182
182
  { name: 'MCP Servers (Playwright, DB, Teams, Stripe, Azure, Azure DevOps)', value: 'mcp', checked: true },
183
183
  { name: 'Settings (hook registration)', value: 'settings', checked: true },
184
184
  { name: 'CLAUDE.md Workflow Section', value: 'workflow', checked: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chris1807/claude-kit",
3
- "version": "2.1.4",
3
+ "version": "2.1.8",
4
4
  "description": "Claude Code starter kit — agents, hooks, MCP servers, slash commands, and workflow automation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,275 @@
1
+ Create a new Azure DevOps work item interactively. Usage: `/create-work-item`
2
+
3
+ This command walks the user through creating a Bug or User Story, develops an acceptance-criteria-ready plan, optionally embeds a UI mockup in the description, and creates the item in the chosen Azure DevOps project.
4
+
5
+ Treat `$ARGUMENTS` as an optional rough description that the user may have typed inline (e.g. `/create-work-item users should be able to export payments`). If provided, skip the initial "describe your requirements" prompt in Step 2 and use it as the starting requirements text — but still confirm with the user before proceeding.
6
+
7
+ ## Step 1: Choose Work Item Type
8
+
9
+ Ask the user:
10
+
11
+ ```
12
+ What type of work item do you want to create?
13
+
14
+ 1. Bug
15
+ 2. User Story
16
+
17
+ Reply with 1, 2, "bug", or "user story".
18
+ ```
19
+
20
+ **Wait for the user's response.** Map the answer to either `Bug` or `User Story`. If the user types something else, ask again — do not guess.
21
+
22
+ ## Step 2: Gather Requirements
23
+
24
+ Ask the user to describe the requirements:
25
+
26
+ ```
27
+ Describe the {bug | user story} in your own words. Include:
28
+
29
+ - What the user is trying to do (or what is broken)
30
+ - Why it matters / who is affected
31
+ - Any constraints, edge cases, or steps to reproduce (for bugs)
32
+ - Links to related work items, PRs, or docs if relevant
33
+ - You can also paste image URLs, screenshot links, or attachment URLs —
34
+ they will be preserved in the description
35
+
36
+ You can paste as much detail as you want — I'll structure it.
37
+ ```
38
+
39
+ **Wait for the user's response.** If the response is very short or vague, ask one targeted clarifying question (e.g. "Does this apply to all users or only admins?"). Don't interrogate — one round of clarification is enough.
40
+
41
+ ### Preserve user-supplied images and links
42
+
43
+ Scan the user's response for:
44
+
45
+ - Direct image URLs (`.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.svg`)
46
+ - Azure DevOps attachment URLs (e.g. `https://dev.azure.com/.../_apis/wit/attachments/...`)
47
+ - Markdown image syntax (`![alt](url)`)
48
+ - Pasted screenshot blob paths or local file paths to images
49
+
50
+ For each image found, plan to embed it in the final description as an `<img src="{url}">` tag, with the user's surrounding text preserved as context. For non-image links (docs, PRs, related work items), preserve them as `<a href="{url}">{url}</a>` in the relevant section of the draft. Do not strip these — they are often the only ground truth for the requirement.
51
+
52
+ ## Step 3: Develop the Plan
53
+
54
+ Translate the user's free-form requirements into a structured work item draft. The shape depends on the type:
55
+
56
+ ### For a User Story:
57
+
58
+ ```
59
+ ## Draft: {Prefix} - {proposed title}
60
+
61
+ **Type:** User Story
62
+
63
+ ### Description
64
+ {2–4 sentences in plain language. Explain the user-facing behavior and the
65
+ business or user value. Avoid implementation detail — that lives in tasks.}
66
+
67
+ ### Acceptance Criteria
68
+ 1. {Given/When/Then or numbered behavior — must be testable}
69
+ 2. ...
70
+ 3. ...
71
+
72
+ ### Out of Scope
73
+ - {anything the user mentioned but that shouldn't block this story}
74
+
75
+ ### Open Questions
76
+ - {anything ambiguous that you couldn't infer — list as questions, not assumptions}
77
+ ```
78
+
79
+ ### For a Bug:
80
+
81
+ ```
82
+ ## Draft: {Prefix} - {proposed title}
83
+
84
+ **Type:** Bug
85
+ **Priority:** {1 | 2 | 3 | 4}
86
+ **Severity:** {1 - Critical | 2 - High | 3 - Medium | 4 - Low}
87
+
88
+ ### Description
89
+ {1–2 sentences describing the observed problem in plain language.}
90
+
91
+ ### Steps to Reproduce
92
+ 1. ...
93
+ 2. ...
94
+ 3. ...
95
+
96
+ ### Expected Behavior
97
+ {what should happen}
98
+
99
+ ### Actual Behavior
100
+ {what does happen}
101
+
102
+ ### Acceptance Criteria
103
+ 1. {behavioral check that proves the bug is fixed — must be testable}
104
+ 2. {regression guard if applicable}
105
+
106
+ ### Environment / Scope
107
+ - {where the bug occurs — browser, environment, role, data condition}
108
+
109
+ ### Open Questions
110
+ - {anything you couldn't infer}
111
+ ```
112
+
113
+ **Inferring Priority and Severity for Bugs:**
114
+
115
+ Propose initial values based on the requirements, then let the user override during approval. Use this rubric:
116
+
117
+ | Severity | Looks like |
118
+ |----------|-----------|
119
+ | **1 - Critical** | Production is down, data loss, security breach, or blocking all users |
120
+ | **2 - High** | Major feature broken, no workaround, affects many users |
121
+ | **3 - Medium** | Feature partially broken, workaround exists, or affects some users |
122
+ | **4 - Low** | Cosmetic, minor inconvenience, or affects few users |
123
+
124
+ | Priority | Looks like |
125
+ |----------|-----------|
126
+ | **1** | Drop everything — fix immediately |
127
+ | **2** | Next sprint at the latest |
128
+ | **3** | Normal queue |
129
+ | **4** | Nice to have / fix when convenient |
130
+
131
+ Severity describes user impact; Priority describes scheduling urgency. They are independent — a Sev 2 can be Priority 3 if a workaround exists.
132
+
133
+ ### Title Prefix
134
+
135
+ The title MUST start with one of the product prefixes from the project's CLAUDE.md (e.g. `COM`, `CDA`, `PAY`, `AUD`, `SER`, `PSSF`, `TPS`). If the project CLAUDE.md does not define a prefix table, ask the user which prefix to use before drafting. Format is `PREFIX - Title Here`.
136
+
137
+ ### Approval
138
+
139
+ After presenting the draft, ask:
140
+
141
+ ```
142
+ Approve this draft? (yes / suggest changes / cancel)
143
+ ```
144
+
145
+ **Wait for the user.** If they suggest changes, revise the draft and present it again — repeat until they approve or cancel. Do NOT proceed to mockup or project selection until approved.
146
+
147
+ ## Step 4: Offer a Mockup (User Stories only — skip for Bugs)
148
+
149
+ If the work item type is **User Story** and the requirements appear to involve UI (a screen, a form, a button, a workflow), ask:
150
+
151
+ ```
152
+ Want me to generate an HTML mockup and embed it in the description? (yes / no)
153
+ ```
154
+
155
+ If the work item is clearly non-UI (background job, data migration, API-only change), skip this step and note "No mockup — non-UI work."
156
+
157
+ ### If the user says yes:
158
+
159
+ 1. Delegate to the **mockup** agent to generate an HTML mockup based on the draft. Brief the agent with the draft description and acceptance criteria.
160
+ 2. Save the mockup HTML to a temporary path, then render it to PNG using Playwright (`mcp__playwright__browser_navigate` to the file path, then `mcp__playwright__browser_take_screenshot`).
161
+ 3. Upload the PNG as a work item attachment via the Azure DevOps API. Capture the returned attachment URL.
162
+ 4. Append an `<img>` tag to the work item description pointing at the attachment URL, with a caption like `Mockup — generated {date}`.
163
+
164
+ If any step fails (mockup generation, screenshot, upload), report the failure to the user and ask whether to proceed without the mockup or abort.
165
+
166
+ ### If the user says no:
167
+
168
+ Continue without a mockup.
169
+
170
+ ## Step 5: Choose the Project
171
+
172
+ ### Detect the default project
173
+
174
+ Before prompting, attempt to detect the default Azure DevOps project from CLAUDE.md, in this order:
175
+
176
+ 1. **Project CLAUDE.md** — read `<current-repo>/CLAUDE.md`. Look for an explicit `project: <name>` declaration, a "Work items live in **<Project Name>**" sentence, or a `## Pipeline Configuration` table with project references.
177
+ 2. **Parent CLAUDE.md** — read `<parent-dir>/CLAUDE.md` (e.g. `~/Projects/CLAUDE.md`). Look for the same patterns. The CSI parent CLAUDE.md, for example, declares: "Work items for both **COMPASS** and **CSI Pay** live in the **CSI Development** Azure DevOps project."
178
+ 3. **Prefix mapping** — if the title prefix chosen in Step 3 is in a known mapping (e.g. `COM`, `CDA`, `PAY` → `CSI Development`), use that.
179
+
180
+ If a default is found, present it pre-selected:
181
+
182
+ ```
183
+ Which Azure DevOps project should this be created in?
184
+
185
+ Default: {detected project} ← press enter to accept
186
+
187
+ Or specify a different project name.
188
+ ```
189
+
190
+ If no default is found, ask without a preselection and offer to list projects via `mcp__azure-devops__core_list_projects`.
191
+
192
+ **Wait for the user's response.** Validate the project name by calling `mcp__azure-devops__core_list_projects` if the response is ambiguous or doesn't match a known project.
193
+
194
+ ## Step 6: Final Confirmation
195
+
196
+ Before creating anything in Azure DevOps, present a final summary and ask for one last confirmation:
197
+
198
+ ```
199
+ ## Ready to Create
200
+
201
+ **Title:** {Prefix} - {title}
202
+ **Type:** {Bug | User Story}
203
+ **Project:** {project}
204
+ {for Bugs:}
205
+ **Priority:** {n}
206
+ **Severity:** {n - Label}
207
+ {end for Bugs}
208
+ **Mockup:** {Embedded | Not requested | Skipped (non-UI)}
209
+ **Images:** {count} user-supplied image(s) embedded in description
210
+ **Open Questions:** {count}
211
+
212
+ Create this work item now? (yes / edit / cancel)
213
+ ```
214
+
215
+ **Wait for the user.**
216
+ - `yes` → proceed to Step 7
217
+ - `edit` → ask which field to revise (title, description, AC, priority, severity, project, mockup), revise it, then re-show this summary
218
+ - `cancel` → abort with no work item created and confirm "Cancelled — no work item created."
219
+
220
+ ## Step 7: Render to HTML and Create
221
+
222
+ ### Render Markdown sections to HTML
223
+
224
+ Azure DevOps description and acceptance criteria fields are HTML — they do not render Markdown. Before submitting, convert the draft sections:
225
+
226
+ | Markdown | HTML |
227
+ |---------------------------|-----------------------------------------------|
228
+ | `1. item\n2. item` | `<ol><li>item</li><li>item</li></ol>` |
229
+ | `- item\n- item` | `<ul><li>item</li><li>item</li></ul>` |
230
+ | `**bold**` | `<strong>bold</strong>` |
231
+ | `\n\n` (paragraph break) | `</p><p>` |
232
+ | `\n` (single newline) | `<br>` |
233
+ | `` `code` `` | `<code>code</code>` |
234
+ | `### Heading` | `<h3>Heading</h3>` |
235
+ | `[text](url)` | `<a href="url">text</a>` |
236
+ | `![alt](url)` | `<img src="url" alt="alt">` |
237
+
238
+ Wrap each top-level section in `<p>...</p>`. Preserve any user-supplied `<img>` tags from Step 2 as-is.
239
+
240
+ ### Call the create API
241
+
242
+ Call `mcp__azure-devops__wit_create_work_item` with:
243
+
244
+ - **project**: the chosen project
245
+ - **workItemType**: `Bug` or `User Story`
246
+ - **title**: the approved title (with prefix)
247
+ - **fields**: a JSON Patch document setting:
248
+ - `System.Description` — the rendered HTML description (with embedded mockup `<img>` and any user-supplied images)
249
+ - `Microsoft.VSTS.Common.AcceptanceCriteria` — the rendered HTML acceptance criteria block
250
+ - For Bugs:
251
+ - `Microsoft.VSTS.TCM.ReproSteps` — the rendered HTML repro steps (Azure DevOps puts repro steps in this field for the Bug template; if the project uses the Agile template instead, fold repro steps into Description)
252
+ - `Microsoft.VSTS.Common.Priority` — the chosen Priority (1–4)
253
+ - `Microsoft.VSTS.Common.Severity` — the chosen Severity (`1 - Critical`, `2 - High`, `3 - Medium`, `4 - Low`)
254
+
255
+ If the `Open Questions` section is non-empty, append it to the description as a clearly-labeled HTML block (`<h3>Open Questions</h3><ul>...</ul>`) so the assignee can address it later.
256
+
257
+ ## Step 8: Confirm
258
+
259
+ After creation, report:
260
+
261
+ ```
262
+ Created AB#{id}: {title}
263
+ Project: {project}
264
+ Type: {type}
265
+ URL: {work item URL}
266
+ Mockup attached: {yes / no}
267
+ Open questions: {count}
268
+
269
+ Next steps:
270
+ /explain AB#{id} — re-read the item in plain language
271
+ /quote AB#{id} — estimate story points
272
+ /implement AB#{id} — start working on it
273
+ ```
274
+
275
+ Do not assign the work item, set an iteration, or add tags unless the user explicitly asks — those are downstream decisions.
@@ -174,4 +174,69 @@ Wait for the user's response before proceeding. Do NOT create a PR until confirm
174
174
  - **title**: `AB#{id}: {work item title}`
175
175
  - **labels**: `["hotfix"]` if the work item type is Hot Fix
176
176
  3. Link the PR to the work item via `wit_link_work_item_to_pull_request`
177
- 4. Update the work item status in Azure DevOps
177
+ 4. **Close related Tasks and log hours** see "Closing Related Tasks" below.
178
+ 5. **Move the work item to `Code Review`** via `wit_update_work_item`:
179
+ - **path**: `/fields/System.State`
180
+ - **value**: `Code Review`
181
+
182
+ If the project's process template does not have a `Code Review` state (the update call returns an invalid-state error), fall back in this order: `Resolved` → `In Review` → leave the current state and warn the user that the state could not be advanced automatically. Do not silently swallow the error.
183
+
184
+ ### Closing Related Tasks
185
+
186
+ After the PR is created, find every child Task of this work item (relations of type `System.LinkTypes.Hierarchy-Forward` where the target's `System.WorkItemType` is `Task`). Skip this step if there are no child Tasks.
187
+
188
+ For each child Task, capture:
189
+ - ID, title, state
190
+ - `Microsoft.VSTS.Scheduling.OriginalEstimate`
191
+ - `Microsoft.VSTS.Scheduling.CompletedWork`
192
+ - `Microsoft.VSTS.Scheduling.RemainingWork`
193
+
194
+ Present:
195
+
196
+ ```
197
+ ## Close Related Tasks
198
+
199
+ | Task ID | Title | State | Original | Completed | Remaining |
200
+ |---------|-------|-------|----------|-----------|-----------|
201
+ | AB#xxxx | ... | Active | 4 | 0 | 4 |
202
+ | AB#yyyy | ... | Active | 2 | 1 | 1 |
203
+
204
+ Close all related tasks and log completed hours? (yes / no / select)
205
+ ```
206
+
207
+ - `yes` → walk through every child Task in sequence
208
+ - `no` → skip closing tasks entirely
209
+ - `select` → ask which task IDs to process; only those get prompted
210
+
211
+ For each task being processed, prompt for completed hours:
212
+
213
+ - **If `CompletedWork` is empty or `0`:**
214
+
215
+ ```
216
+ AB#xxxx ({title})
217
+ Original estimate: {n}h
218
+ Completed: 0h
219
+ Remaining: {n}h
220
+
221
+ Enter completed hours (suggested: {OriginalEstimate}h, press enter to accept):
222
+ ```
223
+
224
+ - **If `CompletedWork` is already set (non-zero):**
225
+
226
+ ```
227
+ AB#xxxx ({title})
228
+ Original estimate: {n}h
229
+ Completed: {current}h ← already logged
230
+ Remaining: {m}h
231
+
232
+ Update completed hours to (press enter to keep {current}, or enter new value):
233
+ ```
234
+
235
+ **Wait for the user's response on every task.** Accept the suggested/current value (enter), a new numeric value, or `skip` to leave that one untouched.
236
+
237
+ Once the user has answered, update each task via `wit_update_work_item`:
238
+ - `Microsoft.VSTS.Scheduling.CompletedWork` → the agreed value
239
+ - `Microsoft.VSTS.Scheduling.RemainingWork` → `0`
240
+ - `System.State` → `Closed` (fall back to `Done` if the project's task template uses Agile; warn if neither is valid)
241
+
242
+ Confirm with a summary line per task: `Closed AB#xxxx — {hours}h logged`.
@@ -1,4 +1,4 @@
1
- Fetch a work item and display it as a formatted quote block. Usage: `/quote <work-item-id>`
1
+ Fetch a work item and estimate the effort in story points. Usage: `/quote <work-item-id>`
2
2
 
3
3
  Parse `$ARGUMENTS` to extract the work item ID. Accept formats like `AB#1234`, `#1234`, or just `1234`.
4
4
 
@@ -8,32 +8,62 @@ Read the work item from Azure DevOps using the project from the current repo's C
8
8
 
9
9
  If the work item is not found, report the error and stop.
10
10
 
11
- ## Step 2: Display the Quote
11
+ Capture: title, type, description, acceptance criteria, attached child items, any existing `Story Points` / `Effort` field value, and any tags that hint at scope (e.g. `spike`, `research`, `infra`).
12
12
 
13
- Format the work item as a quote block:
13
+ ## Step 2: Size the Work
14
+
15
+ Use the **modified Fibonacci scale** for story points: `1, 2, 3, 5, 8, 13, 21`. Anything that feels larger than 21 should be flagged as "needs to be split" rather than given a number.
16
+
17
+ Rough sizing rubric (calibrate against what you can see in the repo, not abstract complexity):
18
+
19
+ | Points | Looks like |
20
+ |--------|-----------|
21
+ | **1** | Trivial change — copy tweak, single config value, one-line fix. No new tests needed. |
22
+ | **2** | Small, well-understood change in one file or one layer. Existing patterns cover it. |
23
+ | **3** | Touches a couple of files / one feature slice. Some new tests. No architectural questions. |
24
+ | **5** | Crosses layers (e.g. API + UI), or introduces a new component/endpoint following existing patterns. Real test coverage needed. |
25
+ | **8** | Multi-area change with meaningful new logic, migrations, or non-trivial edge cases. Some unknowns the implementer will need to resolve. |
26
+ | **13** | Large feature, several moving parts, or significant unknowns. Likely benefits from being split. |
27
+ | **21** | Very large / high uncertainty. Should almost certainly be split into multiple stories. |
28
+
29
+ Adjust upward for: unclear acceptance criteria, missing UX, data migrations, cross-team coordination, security/compliance review, or anything tagged `spike`/`research`.
30
+
31
+ Adjust downward for: pure config changes, mechanical refactors with good test coverage, or work that mirrors an existing implementation.
32
+
33
+ If the item has child items, size each child as well and present the parent's total as the sum (rounded to the nearest Fibonacci number).
34
+
35
+ ## Step 3: Display the Estimate
36
+
37
+ Output a compact estimate — not a quote block. Format:
14
38
 
15
39
  ```
16
- > **AB#{id}: {title}**
17
- > **Type:** {type} | **State:** {state} | **Assigned To:** {assignedTo}
18
- >
19
- > {description text, stripped of HTML tags, truncated to ~500 chars if long}
20
- >
21
- > **Acceptance Criteria:**
22
- > {acceptance criteria, stripped of HTML tags, truncated to ~500 chars if long}
40
+ **AB#{id}: {title}**
41
+ **Estimate:** {points} story points{ confidence: low/medium/high}
42
+
43
+ **Reasoning:**
44
+ - {bullet on scope / files / layers touched}
45
+ - {bullet on unknowns or risk}
46
+ - {bullet on test/doc burden}
47
+
48
+ **Comparable to:** {one-line analogy to a similar past story, or "no obvious comparable in recent work"}
23
49
  ```
24
50
 
25
- - Strip all HTML tags from description and acceptance criteria fields, preserving line breaks as `> ` prefixed lines
26
- - If description or acceptance criteria is empty, omit that section
27
- - If the work item has child items, append:
51
+ If child items were sized, append:
28
52
 
29
53
  ```
30
- >
31
- > **Child Items:** {count}
32
- > | ID | Title | State |
33
- > |----|-------|-------|
34
- > | AB#{id} | {title} | {state} |
54
+ **Child breakdown:**
55
+ | AB# | Title | Points |
56
+ |-----|-------|--------|
57
+ | ... | ... | ... |
58
+ | **Total** | | **{sum}** |
35
59
  ```
36
60
 
37
- - If the work item has tags, include them: `> **Tags:** {comma-separated tags}`
61
+ If an existing `Story Points` value is already set on the work item and your estimate differs, call that out explicitly: `**Existing estimate:** {n} (yours differs — {why})`.
62
+
63
+ If the work looks larger than 21 points, do not assign a number — instead report `**Estimate:** needs to be split` and suggest 2–4 candidate split points based on the acceptance criteria.
64
+
65
+ ## Step 4: Offer to Persist
66
+
67
+ After displaying the estimate, ask the user: *"Want me to set Story Points = {n} on AB#{id}?"*
38
68
 
39
- That's it just display the quote. Do not modify anything.
69
+ Only update the work item if the user explicitly says yes. Do not modify anything otherwise.
@@ -97,7 +97,69 @@ Approve this plan? (yes / no / suggest changes)
97
97
 
98
98
  **Wait for the user to approve the plan.** Do NOT start implementation until the user approves. If they suggest changes, revise the plan and present it again.
99
99
 
100
- ## Step 5: Switch to Existing Branch
100
+ ## Step 5: Create Rework Task as a Child
101
+
102
+ Every rework round gets its own Task work item, parented under the original User Story / Bug. This keeps the rework effort visible on the board and gives the team a clean record of how many rounds an item went through.
103
+
104
+ ### Suggest hours
105
+
106
+ Estimate the rework effort from the approved plan. Use this rubric — calibrate against scope, not abstract complexity:
107
+
108
+ | Hours | Looks like |
109
+ |-------|-----------|
110
+ | **0.5** | Trivial — copy tweak, single config value, one-line fix. No new tests. |
111
+ | **1** | One file, well-understood change. Maybe one new/updated test. |
112
+ | **2** | 2–3 files, one layer, follows existing patterns. Some new tests. |
113
+ | **4** | Multiple files across layers, or new logic in one area. Real test coverage. |
114
+ | **8** | Most of a day — meaningful new logic, several files, edge cases. |
115
+ | **16** | Two days — significant rework, multiple unknowns to resolve. |
116
+ | **24+** | Three days or more — flag that this rework probably should have been a fresh story. |
117
+
118
+ Adjust upward for: ambiguous feedback, missing UX, data migrations, regression risk in unrelated areas. Adjust downward for: pure config changes or mechanical fixes.
119
+
120
+ ### Prompt the user
121
+
122
+ ```
123
+ ## Rework Task
124
+
125
+ **Title:** Rework AB#{id} — round {N}
126
+ **Parent:** AB#{id} ({title})
127
+ **Description:** {1–2 sentence summary of the rework feedback addressed}
128
+
129
+ **Suggested hours:** {n}
130
+ Based on: {one line — files touched / scope / unknowns}
131
+
132
+ Enter the estimated hours for this task (press enter to accept {n}):
133
+ ```
134
+
135
+ `{N}` is the rework round — count how many existing child Tasks already exist on the parent with a title matching `Rework AB#{id}` and add 1.
136
+
137
+ **Wait for the user's response.** Accept the suggestion (enter), accept a different number, or `cancel` to skip task creation. Do not proceed to branch switch until this is resolved.
138
+
139
+ ### Create the task
140
+
141
+ If the user provided hours (suggested or overridden):
142
+
143
+ 1. Call `mcp__azure-devops__wit_create_work_item`:
144
+ - **workItemType**: `Task`
145
+ - **title**: `Rework AB#{id} — round {N}`
146
+ - **fields**: JSON Patch document setting:
147
+ - `System.Description` — short summary of the rework feedback + link to the most recent PR
148
+ - `Microsoft.VSTS.Scheduling.OriginalEstimate` — the agreed hours
149
+ - `Microsoft.VSTS.Scheduling.RemainingWork` — the agreed hours
150
+ - `System.AreaPath` — same as the parent
151
+ - `System.IterationPath` — same as the parent
152
+
153
+ 2. Link the new Task as a child of the parent work item via `wit_work_items_link`:
154
+ - **type**: `Child` (the parent → child link from the parent's perspective; equivalent to `Parent` from the task's perspective)
155
+ - **source**: parent work item ID
156
+ - **target**: new task ID
157
+
158
+ 3. Confirm to the user: `Created task AB#{taskId} (parent: AB#{id}, est: {hours}h)`.
159
+
160
+ If the user cancels, skip task creation and proceed — note "No rework task created" in the final summary.
161
+
162
+ ## Step 6: Switch to Existing Branch
101
163
 
102
164
  The work item already has a branch from the previous PR. Switch to it:
103
165
 
@@ -107,26 +169,26 @@ The work item already has a branch from the previous PR. Switch to it:
107
169
 
108
170
  If the PR was completed/merged and the branch was deleted, create a new branch from the PR's target branch following the same naming convention as `/implement` Step 4.
109
171
 
110
- ## Step 6: Implement
172
+ ## Step 7: Implement
111
173
 
112
174
  1. **Implement** the rework using backend and/or frontend agents according to the approved plan
113
175
  2. **Write the unit tests** listed in the plan's "Unit Tests" section alongside the implementation — not after. Include any regression test that would have caught the original issue
114
176
  3. **Generate mockup** if there are UI changes
115
177
 
116
- ## Step 7: Build Validation
178
+ ## Step 8: Build Validation
117
179
 
118
180
  Run a build check **before** any other quality checks. Use the `build-validator` agent to verify that all projects compile successfully.
119
181
 
120
182
  - If the build fails, **fix the errors immediately** and re-run until the build passes
121
183
  - Do NOT proceed to review, tests, or lint until the build is clean
122
184
 
123
- ## Step 8: Quality Checks
185
+ ## Step 9: Quality Checks
124
186
 
125
187
  1. **Review** code for quality, security, and Clean Architecture compliance
126
188
  2. **Run the full test suite** — every unit test in the repo, plus integration tests. Not just the tests added in this rework. A failure in an unrelated test means this rework broke something else; treat it as a regression, fix it, and re-run until the entire suite is green
127
189
  3. **Run lint** — ESLint and dotnet format
128
190
 
129
- ## Step 9: UAT Gate
191
+ ## Step 10: UAT Gate
130
192
 
131
193
  ### If Hot Fix:
132
194
  Skip manual UAT. Present an abbreviated confirmation:
@@ -158,8 +220,75 @@ Did manual testing pass?
158
220
 
159
221
  Wait for the user's response before proceeding. Do NOT push until confirmed.
160
222
 
161
- ## Step 10: Push and Update
223
+ ## Step 11: Push and Update
162
224
 
163
225
  1. Push the changes: `git push`
164
226
  2. Add a comment on the existing PR summarizing what was changed in the rework
165
- 3. Update the work item status in Azure DevOps if needed
227
+ 3. **Close related Tasks and log hours** — see "Closing Related Tasks" below. This includes the rework Task created in Step 5 as well as any other child Tasks that became `Completed` as a result of this rework round.
228
+ 4. **Move the work item back to `Code Review`** via `wit_update_work_item`:
229
+ - **path**: `/fields/System.State`
230
+ - **value**: `Code Review`
231
+
232
+ Rework is triggered by reviewer feedback, so the item was likely in `Active` / `In Progress` / `Rework` while the fixes were being made. Pushing the rework hands it back to the reviewer, so it belongs in `Code Review` again.
233
+
234
+ If the project's process template does not have a `Code Review` state (the update call returns an invalid-state error), fall back in this order: `Resolved` → `In Review` → leave the current state and warn the user. Do not silently swallow the error.
235
+
236
+ ### Closing Related Tasks
237
+
238
+ After pushing, find every child Task of this work item (relations of type `System.LinkTypes.Hierarchy-Forward` where the target's `System.WorkItemType` is `Task`). Skip this step if there are no child Tasks.
239
+
240
+ For each child Task, capture:
241
+ - ID, title, state
242
+ - `Microsoft.VSTS.Scheduling.OriginalEstimate`
243
+ - `Microsoft.VSTS.Scheduling.CompletedWork`
244
+ - `Microsoft.VSTS.Scheduling.RemainingWork`
245
+
246
+ Present:
247
+
248
+ ```
249
+ ## Close Related Tasks
250
+
251
+ | Task ID | Title | State | Original | Completed | Remaining |
252
+ |---------|-------|-------|----------|-----------|-----------|
253
+ | AB#xxxx | Rework AB#{id} — round 2 | Active | 4 | 0 | 4 |
254
+ | AB#yyyy | ... | Active | 2 | 1 | 1 |
255
+
256
+ Close all related tasks and log completed hours? (yes / no / select)
257
+ ```
258
+
259
+ - `yes` → walk through every child Task in sequence
260
+ - `no` → skip closing tasks entirely
261
+ - `select` → ask which task IDs to process; only those get prompted
262
+
263
+ For each task being processed, prompt for completed hours:
264
+
265
+ - **If `CompletedWork` is empty or `0`:**
266
+
267
+ ```
268
+ AB#xxxx ({title})
269
+ Original estimate: {n}h
270
+ Completed: 0h
271
+ Remaining: {n}h
272
+
273
+ Enter completed hours (suggested: {OriginalEstimate}h, press enter to accept):
274
+ ```
275
+
276
+ - **If `CompletedWork` is already set (non-zero):**
277
+
278
+ ```
279
+ AB#xxxx ({title})
280
+ Original estimate: {n}h
281
+ Completed: {current}h ← already logged
282
+ Remaining: {m}h
283
+
284
+ Update completed hours to (press enter to keep {current}, or enter new value):
285
+ ```
286
+
287
+ **Wait for the user's response on every task.** Accept the suggested/current value (enter), a new numeric value, or `skip` to leave that one untouched.
288
+
289
+ Once the user has answered, update each task via `wit_update_work_item`:
290
+ - `Microsoft.VSTS.Scheduling.CompletedWork` → the agreed value
291
+ - `Microsoft.VSTS.Scheduling.RemainingWork` → `0`
292
+ - `System.State` → `Closed` (fall back to `Done` if the project's task template uses Agile; warn if neither is valid)
293
+
294
+ Confirm with a summary line per task: `Closed AB#xxxx — {hours}h logged`.