@chris1807/claude-kit 2.1.54 → 2.1.56

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.
@@ -1,31 +1,48 @@
1
1
  Promote all code from one environment to the next. Usage: `/promote [source] [target]`
2
2
 
3
3
  Parse `$ARGUMENTS` to extract:
4
- - **Source environment**: optional (e.g., "develop", "staging"). If omitted, auto-detect.
5
- - **Target environment**: optional. If omitted, use the next environment in the promotion flow.
4
+ - **Source**: optional — an environment or branch name (`main`, `dev`, `test`, `staging`). If omitted, auto-detect from the current branch.
5
+ - **Target**: optional — the environment to promote into. If omitted, use the next row in the promotion flow.
6
+
7
+ ## Environment ↔ State Reference
8
+
9
+ Resolve branch names from the project's `CLAUDE.md` **Pipeline Configuration** table — never hardcode them. The first row is the compare branch (`main`; feature PRs target it, **merging into it deploys nothing**); the rows below are the environment branches in promotion order, and a PR merging into one of them is what triggers its pipeline:
10
+
11
+ | Branch | Environment | Gate — items should already be in… | State set after the PR merges |
12
+ |---|---|---|---|
13
+ | `main` | — (compare branch) | — | — |
14
+ | `dev` | Dev | `Code Review` (merged to `main`) | `Ready for Testing` |
15
+ | `test` | Test | `Ready for Testing` | `Testing` |
16
+ | `staging` | Staging | `Ready for Staging` | `Staging` |
17
+ | `prod` | Production | `Ready to Deploy` | `Deployed` |
18
+
19
+ `Ready for Staging` and `Ready to Deploy` are set by QA and stakeholders — **never by this command**.
6
20
 
7
21
  ## Step 1: Determine Source and Target
8
22
 
9
- If not specified, auto-detect based on the current branch:
23
+ Read the Pipeline Configuration table. If it is missing, fall back to `git branch -r` and ask the user to confirm the pair. If not specified, auto-detect based on the current branch:
10
24
 
11
25
  | Current Branch | Source | Target |
12
26
  |---|---|---|
13
- | `develop` | develop | staging |
14
- | `staging` | staging | production branch |
27
+ | `main` | main | dev |
28
+ | `dev` | dev | test |
29
+ | `test` | test | staging |
30
+ | `staging` | staging | prod |
31
+ | `prod` | — | Nothing above production — report and stop |
32
+ | a feature/work branch | — | Ask which pair to promote |
15
33
 
16
- If both are specified (e.g., `/promote staging production`), use those directly.
34
+ If both are specified (e.g., `/promote staging prod`), use those directly. Accept environment names (`production`, `Dev`) as well as branch names and map them through the table. Refuse to promote **backward** (e.g. `prod → staging`) — that is `/rollback`'s job.
17
35
 
18
- Determine the actual branch names — do NOT hardcode. Check the project's CLAUDE.md or use `git branch -r` to find matching environment branches.
36
+ `main → dev` is the usual first hop: it carries every feature PR that has merged into `main` and gives it its first deployment.
19
37
 
20
38
  ## Step 2: Show What Will Be Promoted
21
39
 
22
- Compare the source and target branches to show what's new:
23
-
24
40
  ```bash
25
- git log <target-branch>..<source-branch> --oneline
41
+ git fetch origin <source-branch> <target-branch>
42
+ git log origin/<target-branch>..origin/<source-branch> --oneline
26
43
  ```
27
44
 
28
- Present the changes:
45
+ Present the changes, resolving work items from `AB#` references in commit messages (or `repo_search_commits` with `includeWorkItems: true`):
29
46
 
30
47
  ```
31
48
  ## Promote {source} → {target}
@@ -38,14 +55,33 @@ Commits to promote:
38
55
  | ghi9012 | Update dashboard | AB#1236 |
39
56
 
40
57
  {count} commits will be promoted from {source} to {target}.
41
- Promote? (yes/no)
42
58
  ```
43
59
 
44
- If there are no new commits, report that the environments are already in sync.
60
+ If there are no new commits, report that the environments are already in sync and stop.
61
+
62
+ ## Step 3: Gate Check
63
+
64
+ Fetch each referenced work item and compare its `System.State` with the target's gate. Promotion carries **everything** on the source branch, so an item behind the gate can't be dropped — the choice is to proceed, or to stop and use `/deploy-release` / `/cherry-pick` for a subset:
65
+
66
+ ```
67
+ ⚠ Gate check for {target} (expects `{gate state}`):
68
+
69
+ | ID | State | Note |
70
+ |----|-------|------|
71
+ | AB#1236 | Testing | behind — QA hasn't marked it Ready for Staging |
72
+
73
+ /promote carries the whole branch. Options:
74
+ 1. Promote anyway (AB#1236 goes to {target} too)
75
+ 2. Stop — use /deploy-release or /cherry-pick for just the ready items
76
+
77
+ Which? (1 / 2)
78
+ ```
79
+
80
+ For `main → dev` the gate is `Code Review`: an item still at `Code Review` whose commits are on `main` has had its PR merged, which is exactly right — not a warning. Features and Tasks are skipped. Items *ahead* of the gate are reported and left alone.
45
81
 
46
- Wait for confirmation.
82
+ Then confirm: `Promote {count} commits from {source} to {target}? (yes/no)` — and wait.
47
83
 
48
- ## Step 3: Create PR
84
+ ## Step 4: Create PR
49
85
 
50
86
  Create a PR directly from the source branch to the target branch via Azure DevOps MCP:
51
87
 
@@ -54,18 +90,141 @@ Create a PR directly from the source branch to the target branch via Azure DevOp
54
90
  - **title**: `Promote {source} → {target}`
55
91
  - **description**: List all commits and associated work items being promoted
56
92
 
57
- Link any associated work items to the PR.
93
+ Link the associated work items to the PR.
94
+
95
+ ## Step 5: Pick Who Verifies Each Group (before the merge)
96
+
97
+ The items are about to land in {target environment} for **someone** to verify. Decide who now, while the PR is still in review — nothing is written yet; the assignment is applied in Step 7 together with the state change, once the pipeline is green.
58
98
 
59
- ## Step 4: Present Summary
99
+ ### 5a. Group by title prefix
100
+
101
+ Work item titles in the CSI Development project are `PREFIX - Title` (`COM`, `PAY`, `CDA`, `AUD`, `SER`, `PSSF`, `TPS`, `ILP`, `RBWO`, `MTG`, `CSI`). Group the carried **User Stories, Bugs, and Hot Fixes** by that prefix. Titles with a missing or unrecognized prefix go in a `(no prefix)` group. Features and Tasks are never assigned by this command — leave them out of the grouping.
102
+
103
+ One question per group. Different products usually have different verifiers, but the same person may take several groups — that is the normal case, not an error.
104
+
105
+ ### 5b. Build each group's candidate list from the items themselves
106
+
107
+ For every item in the group, collect the distinct identities already on it:
108
+
109
+ - **whoever set the gate state** — `wit_work_item` `action: list_revisions`, then the `System.ChangedBy` on the revision where `System.State` became the target's gate state (`Ready for Staging`, `Ready to Deploy`, …). That is the QA person or stakeholder who signed the item off, and it is usually the right verifier.
110
+ - `System.CreatedBy` — who asked for the work
111
+ - comment authors — `wit_work_item` `action: list_comments`
112
+ - `System.ChangedBy` — the most recent editor
113
+
114
+ Then **drop the developers**, so what remains is the non-developer names on the item:
115
+
116
+ - each item's current `System.AssignedTo` (the dev who implemented it)
117
+ - the PR author
118
+ - the authors of the promoted commits — `git log origin/<target>..origin/<source> --format='%an <%ae>' | sort -u`
119
+
120
+ Rank the survivors by how many items in the group they appear on — the gate-state signer first, then creators. **Do not invent names**, do not pull from the org directory or a team list, and do not carry a name over from another group's items — every candidate must come from the items in that group.
121
+
122
+ If the developer filter empties a group's list, say so and show the unfiltered names marked `(also a developer here)`, plus the option to type a name.
123
+
124
+ ### 5c. Ask
125
+
126
+ ```
127
+ ## Who verifies on {environment}?
128
+
129
+ **COM** — 2 items (AB#1234, AB#1236)
130
+ 1. Jane Doe (jane@caresolutions.com) — created both
131
+ 2. Sam Lee (sam@caresolutions.com) — commented on AB#1234
132
+ 3. Someone else — give me a name or email
133
+ 4. Leave the current assignee alone
134
+
135
+ **PAY** — 2 items (AB#1240, AB#1241)
136
+ 1. Jane Doe (jane@caresolutions.com) — created AB#1240
137
+ 2. Pat Ruiz (pat@caresolutions.com) — commented on both
138
+ 3. Someone else
139
+ 4. Leave the current assignee alone
140
+
141
+ Reply per group — `COM 1, PAY 2` — or `all 1` to give every group to the same person.
142
+ ```
143
+
144
+ ### 5d. Confirm the mapping
145
+
146
+ Echo the resolved plan and wait for an explicit `yes`:
147
+
148
+ ```
149
+ When the {environment} pipeline goes green I will apply:
150
+
151
+ | ID | Title | Prefix | Assign to | State |
152
+ |----|-------|--------|-----------|-------|
153
+ | AB#1234 | COM - Add payment export | COM | Jane Doe | Staging |
154
+ | AB#1236 | COM - View history | COM | Jane Doe | Staging |
155
+ | AB#1240 | PAY - Fix login redirect | PAY | Pat Ruiz | Staging |
156
+
157
+ Approve? (yes / change)
158
+ ```
159
+
160
+ `change` re-asks 5c. Only after `yes` do you move on — if the PR merges before the user answers, keep waiting for the answer, then run Step 7.
161
+
162
+ ## Step 6: Watch the Merge, Then the Pipeline
163
+
164
+ Do NOT merge the PR yourself — a reviewer approves and completes it. Report the PR, then watch for the deployment:
60
165
 
61
166
  ```
62
167
  Promotion PR created: {source} → {target}
63
168
 
64
169
  PR: {pr-url}
65
170
 
66
- {count} commits included.
67
- Merge the PR to trigger the CD pipeline for {target}.
68
- Remember to update work item states in Azure DevOps after merge.
171
+ {count} commits, {n} work items included.
172
+ Merging the PR triggers the CD pipeline for {target}. I'm watching the PR and
173
+ that pipeline — when it comes back green I'll set the {n} work items to
174
+ `{state after merge}` and assign them as approved above. Nothing is written
175
+ until then. Say `stop watching` to leave the states alone.
176
+ ```
177
+
178
+ 1. **Wait for the PR to complete.** Poll `repo_pull_request` until `status` is `completed`; note the merge commit and the completion time. `abandoned` → stop, change nothing, report it.
179
+ 2. **Find the CD run.** Look up the target branch's pipeline ID(s) in the Pipeline Configuration table, then poll `pipelines_build` for runs on `refs/heads/<target-branch>` queued at or after the merge time — match the merge commit when the run exposes it — and **capture each run's id**. A run that was already completed before the merge is not this deployment; ignore it. A branch with more than one pipeline (API + Client) must have **all** of them green.
180
+ 3. **Wait for a terminal result** on each run: `succeeded`, `partiallySucceeded`, `failed`, or `canceled`.
181
+
182
+ **How to wait.** Never block on a foreground `sleep`. If the Azure CLI with the `azure-devops` extension is available, arm a background watch that notifies you on a terminal state:
183
+
184
+ ```bash
185
+ # <run-id> is the run identified in step 2 — never "the latest run on the branch",
186
+ # which can be a run queued before the merge and already completed.
187
+ until az pipelines runs show --org <org-url> --project <project> \
188
+ --id <run-id> --query status -o tsv | grep -qx completed; do
189
+ sleep 60
190
+ done
191
+ az pipelines runs show --org <org-url> --project <project> \
192
+ --id <run-id> --query "[buildNumber,status,result]" -o tsv
193
+ ```
194
+
195
+ Run it with `Monitor` (or Bash `run_in_background`) so the session stays usable. Watch the **run id**, and print `result` when it exits — a guard that only greps for success is silent through a failed or canceled deploy, which looks identical to one still running. One watch per pipeline when the branch has more than one.
196
+
197
+ Without the CLI, re-poll through the Azure DevOps MCP on roughly a 60-second cadence and report progress as you go. If the deploy outlasts the session's attention, say where it stands and that `check` will re-poll immediately — never claim a pipeline succeeded that you have not seen succeed.
198
+
199
+ ## Step 7: Assign and Advance States (automatic, on a green pipeline)
200
+
201
+ This step runs **by itself** the moment the pipeline reports success — do not ask again; the approval in Step 5d covers it. All three preconditions must hold: the PR is `completed`, **every** CD run for {target} is `succeeded`, and a Step 5d mapping was approved.
202
+
203
+ - `partiallySucceeded` → not green. Report which stage failed and ask `proceed` / `hold`.
204
+ - `failed` / `canceled` → change nothing. Report the run, the failing stage, and the log link (`pipelines_build_log`), and offer `/rollback` if the environment is broken.
205
+ - No Step 5d approval yet (user hasn't answered) → do the state changes only when they answer; don't guess an assignee.
206
+
207
+ For every carried work item of type **User Story**, **Bug**, or **Hot Fix**, one `wit_work_item_write` update per item setting both fields:
208
+
209
+ 1. `System.State` → the target's state (`Ready for Testing` / `Testing` / `Staging` / `Deployed`).
210
+ - **Never move backward** — an item already past the target state keeps it; note it.
211
+ - An invalid-state error means this project's template differs — confirm with `get_type`, report the item, continue with the rest. Don't silently swallow it.
212
+ 2. `System.AssignedTo` → the person approved for that item's prefix group. Pass the identity's `uniqueName` / email, not the display name; if the update rejects it, resolve with `core_get_identity_ids` and retry once. A `Leave the current assignee alone` group keeps its assignee — never clear a field the user didn't ask you to clear.
213
+
214
+ **Never touch a Feature or Task** — neither state nor assignee.
215
+
216
+ Report both fields, so a wrong assignment is easy to put back:
217
+
218
+ ```
219
+ {source} → {target} is deployed (pipeline {build-number}, succeeded).
220
+
221
+ | ID | State: was → now | Assignee: was → now |
222
+ |----|------------------|---------------------|
223
+ | AB#1234 | Ready for Staging → Staging | Chris Waters → Jane Doe |
224
+ | AB#1240 | Ready for Staging → Staging | Chris Waters → Pat Ruiz |
225
+ | AB#1250 | Deployed (unchanged — already ahead) | unchanged |
226
+
227
+ Next: {the human step — "QA tests on Test and sets Ready for Staging" / "stakeholders verify on Staging and set Ready to Deploy" / "verify in production, then Close"}.
69
228
  ```
70
229
 
71
- Do NOT merge the PR automatically — the user or a reviewer must approve and merge.
230
+ If the user said `stop watching`, or an update fails, leave the rest alone, say exactly which items were and were not updated, and note that `/status` will flag the lag later.
@@ -372,7 +372,7 @@ Only for approved items, in batch order:
372
372
  2. **Send unquotable User Stories back to Design Review** (approved `User Story` items with **no** proposed points, where the blocker is missing information): set `System.State` = `Design Review` via `mcp__azure-devops__wit_update_work_item`. Do this **before** posting the comment in step 4, so the creator's notification arrives with the item already back in their queue. Rules:
373
373
 
374
374
  - **`User Story` only.** Do not attempt this on a `Bug` or a `Hot Fix` — those types have no `Design Review` state, so the update fails at runtime in the middle of the batch. They take step 3 instead.
375
- - Only from `Design Approved` — **never move an item backward past the design stage.** An item at `Dev Ready`, or anything at `Active` or later (`Active`, `Code Review`, `Ready for Testing`, `Testing`, `Ready to Deploy`, …), keeps its state; note it in the summary instead.
375
+ - Only from `Design Approved` — **never move an item backward past the design stage.** An item at `Dev Ready`, or anything at `Active` or later (`Active`, `Code Review`, `Ready for Testing`, `Testing`, `Ready for Staging`, `Staging`, `Ready to Deploy`, …), keeps its state; note it in the summary instead.
376
376
  - Skip items whose only finding is **needs to be split** — the work is understood, so nothing is missing; leave those in `Design Approved`.
377
377
  - If the item is already in `Design Review`, this is a no-op — post the comment and move on.
378
378
  - If this project's `User Story` type has no `Design Review` state either (the update returns an invalid-state error), fall back in this order: `In Design` → the `needs-info` tag from step 3 → leave the item alone and **warn the user** that it will be picked up again by the next sweep. Do not silently swallow the error.
@@ -114,7 +114,7 @@ Only update the work item if the user explicitly says yes. Do not modify anythin
114
114
  When the user agrees, in the **same** `wit_update_work_item` call:
115
115
 
116
116
  1. Set `Microsoft.VSTS.Scheduling.StoryPoints` to the agreed value (the user's number wins if they adjusted it).
117
- 2. Set `System.State` to `Dev Ready` — **but only if** the work item type is `User Story`, `Bug`, or `Hot Fix` **and** the item is not already past Dev Ready in the workflow (e.g. `Active`, `Code Review`, `Ready to Deploy`). Never move an item backward — if it's already past Dev Ready, set the points only and mention the state was left alone.
117
+ 2. Set `System.State` to `Dev Ready` — **but only if** the work item type is `User Story`, `Bug`, or `Hot Fix` **and** the item is not already past Dev Ready in the workflow (e.g. `Active`, `Code Review`, `Testing`, `Staging`, `Ready to Deploy`). Never move an item backward — if it's already past Dev Ready, set the points only and mention the state was left alone.
118
118
 
119
119
  **Never change the state of a Feature or a Task** — if the sized item is a Feature, persist points only (or per-child points on the children, each of which does get Dev Ready if it qualifies).
120
120
 
@@ -128,7 +128,7 @@ When the item came out of Step 2 as **needs more information**, offer to drop it
128
128
  | `Bug`, `Hot Fix` | Add a **`needs-info` tag**; leave the state at `New` | 5b |
129
129
  | `Feature`, `Task` | Neither — report the gap and stop | — |
130
130
 
131
- In the CSI Development process template, `Bug` and `Hot Fix` have **no design states at all** — the workflow is `New` → `Dev Ready` → `Active` → `Code Review` → …, with neither `Design Review` nor `Design Approved`. `New` is the bottom of that workflow, so there is nowhere to send a bug back to; the tag is what keeps `/quote-backlog` from re-analyzing it. On an unfamiliar project, confirm the type's real states with `mcp__azure-devops__wit_work_item` (`action: get_type`, `workItemType: Bug`) and read the `states` array — don't infer a state name from what the workflow "should" have. A bad state name is accepted by a query (zero rows, no error) and rejected only at write time.
131
+ In the CSI Development process template, `Bug` and `Hot Fix` have **no design states at all** — the workflow is `New` → `Dev Ready` → `Active` → `Code Review` → `Ready for Testing` → `Testing` → `Ready for Staging` → `Staging` → `Ready to Deploy` → `Deployed` → `Closed`, with neither `Design Review` nor `Design Approved`. `New` is the bottom of that workflow, so there is nowhere to send a bug back to; the tag is what keeps `/quote-backlog` from re-analyzing it. On an unfamiliar project, confirm the type's real states with `mcp__azure-devops__wit_work_item` (`action: get_type`, `workItemType: Bug`) and read the `states` array — don't infer a state name from what the workflow "should" have. A bad state name is accepted by a query (zero rows, no error) and rejected only at write time.
132
132
 
133
133
  ### 5a. User Story → Design Review
134
134
 
@@ -137,7 +137,7 @@ In the CSI Development process template, `Bug` and `Hot Fix` have **no design st
137
137
  **Wait for the user.** Only update the work item if they say yes. Then set `System.State` = `Design Review` with `mcp__azure-devops__wit_update_work_item`. Rules:
138
138
 
139
139
  - **`User Story` only** — never a Bug, Hot Fix, Feature, or Task. A Bug takes 5b; the update would fail on it anyway.
140
- - **Never move an item backward past the design stage.** Only from `Design Approved`; if it's already `Dev Ready` or anything at `Active` or later (`Active`, `Code Review`, `Ready for Testing`, `Testing`, `Ready to Deploy`, …), leave the state alone and say so — someone is already working on it, and a state bounce there does real damage.
140
+ - **Never move an item backward past the design stage.** Only from `Design Approved`; if it's already `Dev Ready` or anything at `Active` or later (`Active`, `Code Review`, `Ready for Testing`, `Testing`, `Ready for Staging`, `Staging`, `Ready to Deploy`, …), leave the state alone and say so — someone is already working on it, and a state bounce there does real damage.
141
141
  - Already in `Design Review` → no-op; say it's already there.
142
142
  - No `Design Review` state for `User Story` in this process template (the update returns an invalid-state error) → fall back in this order: `In Design` → the `needs-info` tag from 5b → leave the state alone and **warn** that the item will keep surfacing in backlog sweeps. Don't swallow the error.
143
143
  - Set **no** story points and touch no other field — assignee, iteration, and tags stay as they are.
@@ -52,7 +52,7 @@ Review PR #$ARGUMENTS in the current project. Automatically:
52
52
  - Error handling (are exceptions caught appropriately?)
53
53
  - Naming conventions and code style consistency
54
54
  - Breaking changes or backwards compatibility issues
55
- - **Environment configuration parity** — if the diff adds or changes any key in `appsettings.*.json` or `.env*`, every parallel environment file (Development/Staging/QA/Production for backend; `.env.development`/`.env.staging`/`.env.production`/`.env.example` for React) must have a corresponding entry, or the omission must be called out in the PR description. Build a table of (key × environment) and flag any missing cell as **critical**. Pipeline variable groups, Key Vault, or App Configuration wiring counts as a valid source for a given environment — verify it exists rather than assume it.
55
+ - **Environment configuration parity** — if the diff adds or changes any key in `appsettings.*.json` or `.env*`, every parallel environment file (Development/Test/QA/Staging/Production for backend; `.env.development`/`.env.test`/`.env.staging`/`.env.production`/`.env.example` for React) must have a corresponding entry, or the omission must be called out in the PR description. Build a table of (key × environment) and flag any missing cell as **critical**. Pipeline variable groups, Key Vault, or App Configuration wiring counts as a valid source for a given environment — verify it exists rather than assume it.
56
56
  - **Rework-specific (if applicable):** does this diff fully address every item in the rework feedback? Does it regress anything that prior merged PRs delivered?
57
57
 
58
58
  6. **Draft (do not post yet) the inline comments** for every finding. For each, capture: file path, line number, severity, and the exact comment body you intend to post.
@@ -264,7 +264,7 @@ Run a build check **before** any other quality checks. Use the `build-validator`
264
264
 
265
265
  1. **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
266
266
  2. **Run lint** — ESLint and dotnet format
267
- 3. **Environment configuration parity** — if the rework added or changed any key in `appsettings.*.json` or `.env*`, verify every parallel environment file (Development/Staging/QA/Production for backend; `.env.development`/`.env.staging`/`.env.production`/`.env.example` for React — whichever exist in the repo) has a corresponding entry. Present a (key × environment) table. Prompt the user to fill in any missing values (real, placeholder, or empty) **before pushing**, or to explicitly confirm the omission is intentional (e.g., supplied via a pipeline variable group, Key Vault, or App Configuration).
267
+ 3. **Environment configuration parity** — if the rework added or changed any key in `appsettings.*.json` or `.env*`, verify every parallel environment file (Development/Test/QA/Staging/Production for backend; `.env.development`/`.env.test`/`.env.staging`/`.env.production`/`.env.example` for React — whichever exist in the repo) has a corresponding entry. Present a (key × environment) table. Prompt the user to fill in any missing values (real, placeholder, or empty) **before pushing**, or to explicitly confirm the omission is intentional (e.g., supplied via a pipeline variable group, Key Vault, or App Configuration).
268
268
  4. **Acceptance Criteria check** — re-read the work item's full Acceptance Criteria (the same list captured in Step 3). For each AC, identify the test or piece of code that proves it's met. If any AC has no covering test or visible code path, flag it before moving on.
269
269
 
270
270
  > **Ultracode (if opted in):** Fan out this check with `Workflow` — one read-only agent per acceptance criterion, each returning `{ac, covered: bool, evidence, gap?}`. Collect the results in the main loop and act on any `covered: false`.
@@ -350,7 +350,7 @@ Wait for the user's response before proceeding. Do NOT push until confirmed.
350
350
 
351
351
  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.
352
352
 
353
- > **PR completion closes the Task only.** When the PR is later completed/merged, only the child **Task** may be closed — never the parent User Story or Bug. Azure DevOps's "Complete associated work items" option transitions *every* linked work item (including the parent the PR is linked to), so do **not** enable it when completing the PR. Close the child Task explicitly instead; the parent stays in `Code Review` until QA/UAT and any sibling Tasks are done.
353
+ > **PR completion closes the Task only.** When the PR is later completed/merged, only the child **Task** may be closed — never the parent User Story or Bug. Azure DevOps's "Complete associated work items" option transitions *every* linked work item (including the parent the PR is linked to), so do **not** enable it when completing the PR. Close the child Task explicitly instead; the parent stays in `Code Review` until it is promoted through `dev → test → staging → prod` (see **Work Item States ↔ Environments** in CLAUDE.md).
354
354
 
355
355
  ### Closing Related Tasks
356
356
 
@@ -2,11 +2,11 @@ Roll back a deployment in an environment. Usage: `/rollback <work-item-ids-or-co
2
2
 
3
3
  Parse `$ARGUMENTS` to extract:
4
4
  - **What to revert**: work item IDs (e.g., "AB#1234") or commit hashes, or "last" for the most recent deployment
5
- - **Target environment**: the environment to roll back (e.g., "staging", "production")
5
+ - **Target environment**: the environment to roll back (`dev`, `test`, `staging`, `prod`/`production`)
6
6
 
7
7
  ## Step 1: Identify What to Revert
8
8
 
9
- Determine the target environment branch. Do NOT hardcode branch names.
9
+ Determine the target environment branch from the project's `CLAUDE.md` **Pipeline Configuration** table (`dev`, `test`, `staging`, `prod`). Do NOT hardcode branch names. `main` is the compare branch, not an environment — reverting there deploys nothing; if the user asks to roll back `main`, explain that and ask which environment they actually mean (or confirm they want the code removed from `main` too, so it doesn't come back on the next promotion).
10
10
 
11
11
  If the user specified:
12
12
  - **Work item IDs**: Find the associated commits on the environment branch using `repo_search_commits` with `includeWorkItems: true`
@@ -86,9 +86,13 @@ Reverted:
86
86
  - AB#1235: Fix login redirect
87
87
 
88
88
  Merge the PR to trigger the CD pipeline and deploy the rollback.
89
+
90
+ Work items reverted from {environment}: AB#1234, AB#1235 — their state still says `{current state}`.
91
+ The fix will need to go through main → dev → test → staging → prod again, so move them back to `Active`
92
+ (or leave them and open a new Bug) — your call; I won't change states on a rollback.
89
93
  ```
90
94
 
91
- For production rollbacks, flag urgency to the user.
95
+ For production rollbacks, flag urgency to the user. If the reverted commits are also on `main` (they usually are), remind the user that the next `/promote` will bring them back unless the revert is also applied to `main` — offer `/cherry-pick` of the revert commit to `main`.
92
96
 
93
97
  ## Step 7: Notify Team (if Teams MCP is configured)
94
98
 
@@ -1,63 +1,96 @@
1
- Check the status of a release, pipeline, or work item. Usage: `/status <target>`
1
+ Check the status of a release, pipeline, environment, or work item. Usage: `/status <target>`
2
2
 
3
3
  Parse `$ARGUMENTS` to determine what to check:
4
4
  - **Release**: "release 24" or "r24" → show release status
5
5
  - **Pipeline**: "pipeline" or "build" → show recent pipeline runs
6
6
  - **Work item**: "AB#1234" or "1234" → show work item status
7
- - **Environment**: "staging" or "production" → show what's deployed
7
+ - **Environment**: "dev", "test", "staging", or "prod" → show what's deployed
8
8
  - **No argument**: show an overview of everything
9
9
 
10
+ Read the project's `CLAUDE.md` **Pipeline Configuration** table for the branch chain. The first row is the compare branch (`main` — feature PRs merge there; **nothing deploys from it**); the rows below are environment branches in promotion order (`dev → test → staging → prod`). Do not hardcode branch names.
11
+
12
+ ## Environment ↔ State Reference
13
+
14
+ Work item states track environments. Use this to spot **state lag** — an item whose commits are on a branch but whose state hasn't caught up:
15
+
16
+ | Commits are on… | State should be at least… |
17
+ |---|---|
18
+ | `main` | `Code Review` |
19
+ | `dev` | `Ready for Testing` |
20
+ | `test` | `Testing` |
21
+ | `staging` | `Staging` |
22
+ | `prod` | `Deployed` |
23
+
24
+ `Ready for Staging` and `Ready to Deploy` are human sign-offs and are never "lag". Only User Stories, Bugs, and Hot Fixes are checked — Features and Tasks have no environment state.
25
+
10
26
  ## If Release (e.g., `/status release 24`):
11
27
 
12
- Query all work items tagged `release-{N}` or in the `Release #{N}` iteration.
28
+ Query all work items tagged `release-{N}` or in the `Release #{N}` iteration. For each, find which environment branches contain its commits (`repo_search_commits` with `includeWorkItems: true`, or `git merge-base --is-ancestor`).
13
29
 
14
30
  ```
15
31
  ## Release #24 Status
16
32
 
17
- | ID | Type | Title | State | Environment |
18
- |----|------|-------|-------|-------------|
19
- | AB#4521 | User Story | Add payment export | Closed | Production |
20
- | AB#4522 | User Story | Bulk approval workflow | Ready for Testing | Staging |
21
- | AB#4530 | User Story | Dashboard trends | Ready for Testing | Staging |
33
+ | ID | Type | Title | State | Furthest Environment |
34
+ |----|------|-------|-------|----------------------|
35
+ | AB#4521 | User Story | Add payment export | Deployed | Production |
36
+ | AB#4522 | User Story | Bulk approval workflow | Staging | Staging |
37
+ | AB#4530 | User Story | Dashboard trends | Testing | Staging ⚠ |
22
38
  | AB#4589 | Bug | Login plus sign fix | Closed | Production |
23
39
 
24
40
  Deployed to:
25
41
  - Dev: All 4 items
42
+ - Test: All 4 items
26
43
  - Staging: All 4 items
27
44
  - Production: 2 of 4 items (AB#4521, AB#4589)
45
+
46
+ ⚠ State lag:
47
+ - AB#4530 is on `staging` but still in `Testing` — expected at least `Staging`.
48
+
49
+ Catch these up? (yes/no)
28
50
  ```
29
51
 
52
+ If the user says yes, set `System.State` on each lagging item to the expected state via `wit_update_work_item` — never backward, never on a Feature or Task — and report `Was → Now`.
53
+
30
54
  ## If Pipeline (e.g., `/status pipeline` or `/status build`):
31
55
 
32
- Check the project's CLAUDE.md for pipeline configuration. Query recent builds for each pipeline.
56
+ Query recent builds for each pipeline in the Pipeline Configuration table.
33
57
 
34
58
  ```
35
59
  ## Recent Pipeline Runs
36
60
 
37
61
  | Pipeline | Branch | Status | Time | Build # |
38
62
  |----------|--------|--------|------|---------|
39
- | Compass API | main | Succeeded | 2026-03-22 14:26 | 20260322.1 |
40
- | Compass Client | main | Succeeded | 2026-03-22 14:27 | 20260322.1 |
41
- | Compass API | develop | Succeeded | 2026-03-21 10:15 | 20260321.3 |
63
+ | Compass API (YAML) | prod | Succeeded | 2026-09-06 14:26 | 20260906.1 |
64
+ | Compass Client (YAML) | prod | Succeeded | 2026-09-06 14:27 | 20260906.1 |
65
+ | Compass API (YAML) | test | Succeeded | 2026-09-05 10:15 | 20260905.3 |
42
66
  ```
43
67
 
68
+ A run on `main` would be unexpected — `main` has no pipeline. If one appears, say so.
69
+
44
70
  ## If Work Item (e.g., `/status AB#4521`):
45
71
 
46
- Read the work item from Azure DevOps and show its full status.
72
+ Read the work item from Azure DevOps and show its full status, including which environment branches contain its commits.
47
73
 
48
74
  ```
49
75
  ## AB#4521: Admin Can Export Payment History to CSV
50
76
 
51
77
  **Type:** User Story
52
- **State:** Ready for Testing
78
+ **State:** Staging
53
79
  **Assigned To:** Chris Waters
54
80
  **Release:** Release #24
55
81
  **Branch:** story/AB#4521-admin-can-export-payment-history
56
- **PR:** #287 (merged to develop)
82
+ **PR:** #287 (merged to main)
57
83
 
58
- ### Linked PRs
59
- - PR #287 → develop (merged 2026-03-20)
60
- - PR #291 → staging (merged 2026-03-21)
84
+ ### Environments
85
+ | Environment | Branch | Present |
86
+ |-------------|--------|---------|
87
+ | — (compare) | main | Yes — PR #287 merged 2026-09-01 |
88
+ | Dev | dev | Yes — PR #290 merged 2026-09-02 |
89
+ | Test | test | Yes — PR #291 merged 2026-09-03 |
90
+ | Staging | staging | Yes — PR #295 merged 2026-09-05 |
91
+ | Production | prod | No |
92
+
93
+ State `Staging` matches the furthest environment. ✓
61
94
 
62
95
  ### Child Tasks
63
96
  | ID | Title | State |
@@ -67,24 +100,31 @@ Read the work item from Azure DevOps and show its full status.
67
100
  | AB#4527 | Add export button UI | Closed |
68
101
  ```
69
102
 
103
+ If the state lags the furthest environment, flag it and offer to catch it up as in the release view.
104
+
70
105
  ## If Environment (e.g., `/status staging`):
71
106
 
72
- Check the project's CLAUDE.md for the environment branch mapping. Show the last deployment and what's currently deployed.
107
+ Map the name to its branch through the Pipeline Configuration table. Show the last deployment and what's currently there.
73
108
 
74
109
  ```
75
110
  ## Staging Environment
76
111
 
77
112
  **Branch:** staging
78
- **Last deployment:** 2026-03-21 15:30 (Build #20260321.2)
79
- **Pipeline:** Compass API — Succeeded
113
+ **Last deployment:** 2026-09-05 15:30 (Build #20260905.2)
114
+ **Pipeline:** Compass API (YAML) — Succeeded
80
115
 
81
116
  ### Recent merges to staging:
82
117
  | Commit | Message | Date |
83
118
  |--------|---------|------|
84
- | a1b2c3d | Release #24 → Staging | 2026-03-21 |
85
- | d4e5f6a | Cherry-pick AB#4601 | 2026-03-22 |
119
+ | a1b2c3d | Release #24 → Staging | 2026-09-05 |
120
+ | d4e5f6a | Cherry-pick AB#4601 → Staging | 2026-09-06 |
121
+
122
+ ### Not yet promoted from test:
123
+ {count} commits on `test` are not on `staging` — run `/promote test staging` or `/deploy-release <N> staging`.
86
124
  ```
87
125
 
126
+ `/status main` is allowed but reports "compare branch — nothing deploys from main" and lists what's on `main` that hasn't been promoted to `dev`.
127
+
88
128
  ## If No Argument (e.g., `/status`):
89
129
 
90
130
  Show a high-level overview.
@@ -93,19 +133,29 @@ Show a high-level overview.
93
133
  ## Project Status
94
134
 
95
135
  ### Active Releases
96
- | Release | Work Items | Latest Environment |
97
- |---------|-----------|-------------------|
136
+ | Release | Work Items | Furthest Environment |
137
+ |---------|-----------|----------------------|
98
138
  | Release #24 | 6 items | Staging |
99
139
  | Release #23 | 4 items | Production |
100
140
 
141
+ ### Environment Chain
142
+ | Branch | Environment | Behind previous by |
143
+ |--------|-------------|--------------------|
144
+ | main | — (compare) | — |
145
+ | dev | Dev | 0 commits |
146
+ | test | Test | 3 commits |
147
+ | staging | Staging | 3 commits |
148
+ | prod | Production | 9 commits |
149
+
101
150
  ### Recent Pipelines
102
- | Pipeline | Last Run | Status |
103
- |----------|----------|--------|
104
- | Compass API | 20260322.1 | Succeeded |
105
- | Compass Client | 20260322.1 | Succeeded |
151
+ | Pipeline | Last Run | Branch | Status |
152
+ |----------|----------|--------|--------|
153
+ | Compass API (YAML) | 20260906.1 | prod | Succeeded |
154
+ | Compass Client (YAML) | 20260906.1 | prod | Succeeded |
106
155
 
107
156
  ### Open PRs
108
157
  | PR # | Title | Target |
109
158
  |------|-------|--------|
110
- | #292 | AB#4601: Fix bulk approval | develop |
159
+ | #292 | AB#4601: Fix bulk approval | main |
160
+ | #296 | Promote test → staging | staging |
111
161
  ```
@@ -12,14 +12,16 @@ Capture: id, title, type, state, and any linked Pull Request artifacts from `rel
12
12
 
13
13
  ## Step 2: Resolve the Environment Chain
14
14
 
15
- Read the **Pipeline Configuration** table from the current repo's `CLAUDE.md`. The table rows define the environment branches in promotion order (top → bottom). Example:
15
+ Read the **Pipeline Configuration** table from the current repo's `CLAUDE.md`. The table rows define the branches in promotion order (top → bottom). The **first row is the compare branch** (`main`) — feature PRs merge there, but nothing deploys from it; the rows below are the environment branches. Example:
16
16
 
17
17
  ```
18
18
  | Branch | Environment | Pipeline(s) |
19
19
  |--------|------------|-------------|
20
- | develop | Dev | ... |
20
+ | main | — (compare branch, no deployment) | — |
21
+ | dev | Dev | ... |
22
+ | test | Test | ... |
21
23
  | staging | Staging | ... |
22
- | main | Production | ... |
24
+ | prod | Production | ... |
23
25
  ```
24
26
 
25
27
  If the table is missing, report that the project has no pipeline configuration in `CLAUDE.md` and stop.
@@ -62,19 +64,21 @@ AB#<id>: <title>
62
64
  This work item is in <env list joined with " and ">.
63
65
  ```
64
66
 
65
- Where `<env list>` is the environments where the work item is present, in promotion order. If none, say "not deployed to any environment yet."
67
+ Where `<env list>` is the environments where the work item is present, in promotion order. The compare branch is not an environment: if the commits are on `main` only, say "merged to main, not deployed to any environment yet." If not even on `main`, say "not merged yet."
66
68
 
67
69
  Then a details table:
68
70
 
69
71
  ```
70
- | Environment | Branch | Deployed | Commits |
71
- |-------------|---------|----------|---------|
72
- | Dev | develop | Yes | 2 of 2 |
73
- | Staging | staging | Yes | 2 of 2 |
74
- | Production | main | No | 0 of 2 |
72
+ | Environment | Branch | Present | Commits |
73
+ |-------------|---------|---------|---------|
74
+ | — (compare) | main | Yes | 2 of 2 |
75
+ | Dev | dev | Yes | 2 of 2 |
76
+ | Test | test | Yes | 2 of 2 |
77
+ | Staging | staging | Yes | 1 of 2 |
78
+ | Production | prod | No | 0 of 2 |
75
79
  ```
76
80
 
77
- - **Deployed**: Yes if at least one commit is reachable from the branch tip; No otherwise.
81
+ - **Present**: Yes if at least one commit is reachable from the branch tip; No otherwise. For the compare branch this means "merged", not "deployed".
78
82
  - **Commits**: how many of the work item's commits are present on that branch (e.g. `1 of 2` flags a partial cherry-pick).
79
83
 
80
84
  If any linked PRs are still open (not merged), append:
@@ -84,4 +88,6 @@ Open PRs:
84
88
  - PR #<n> → <target branch> (<status>)
85
89
  ```
86
90
 
87
- That's it — read-only. Do not modify branches, push, or create PRs.
91
+ Finally, compare the work item's state with its furthest environment (`dev` → `Ready for Testing`, `test` → `Testing`, `staging` → `Staging`, `prod` → `Deployed`). If the state lags — e.g. commits on `staging` but the item is still `Testing` — add one line: `⚠ State lags environment: Testing, expected at least Staging — /status AB#<id> can catch it up.`
92
+
93
+ That's it — read-only. Do not modify branches, push, create PRs, or change states.