@drunkcoding/agents-and-skills 0.0.14 → 0.0.15
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/.claude-plugin/marketplace.json +5 -5
- package/README.md +1 -1
- package/package.json +1 -1
- package/plugins/html-effectiveness/.claude-plugin/plugin.json +1 -1
- package/plugins/plugin-validator/.claude-plugin/plugin.json +1 -1
- package/plugins/team-superpower/.claude-plugin/plugin.json +2 -2
- package/plugins/team-superpower/README.md +12 -5
- package/plugins/team-superpower/agents/backend-developer.md +56 -7
- package/plugins/team-superpower/agents/frontend-developer.md +68 -5
- package/plugins/team-superpower/agents/planner.md +125 -17
- package/plugins/team-superpower/agents/reviewer.md +36 -6
- package/plugins/team-superpower/agents/security-engineer.md +85 -5
- package/plugins/team-superpower/assets/CLAUDE.md.template +96 -0
- package/plugins/team-superpower/assets/SESSION_README.md +89 -1
- package/plugins/team-superpower/commands/team-feature-resume.md +37 -6
- package/plugins/team-superpower/commands/team-feature.md +188 -13
- package/plugins/team-superpower/hooks/task-completed.sh +54 -5
- package/plugins/team-superpower/hooks/task-created.sh +79 -4
- package/plugins/team-superpower/scripts/detect-stack.sh +434 -0
- package/plugins/team-superpower/scripts/parse-claudemd.sh +194 -0
- package/plugins/tech-graph/.claude-plugin/plugin.json +1 -1
|
@@ -15,13 +15,92 @@ You are a **conductor**, not an implementer. Spawn teammates and coordinate them
|
|
|
15
15
|
|
|
16
16
|
## Required prechecks (run these first, in order)
|
|
17
17
|
|
|
18
|
-
1. Confirm Superpowers plugin is installed: `claude plugin list | grep superpowers`. If missing, **halt** and instruct the owner: `/plugin install superpowers@claude-plugins-official`.
|
|
18
|
+
1. Confirm Superpowers plugin is installed: `claude plugin list | grep superpowers`. If missing, **halt** and instruct the owner: `/plugin install superpowers@claude-plugins-official`. Capture the version string from `claude plugin list --json` (e.g. `5.0.7`) — you'll write it to the checkpoint in phase 0 step 5 below.
|
|
19
19
|
2. Confirm Claude Code version is `2.1.32` or later: `claude --version`. If older, halt.
|
|
20
20
|
3. Confirm `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` is set in the environment. If not, halt and instruct the owner to add it to `~/.claude/settings.json` under `env`.
|
|
21
21
|
4. Generate a kebab-case `<slug>` from the owner's request. Use it in every artifact filename for the rest of the run. The team you create MUST be named exactly `superpower-<slug>` — every cleanup and resume primitive depends on that convention.
|
|
22
22
|
5. Create directories if missing: `docs/superpowers/{sessions,specs,plans,reviews}`.
|
|
23
23
|
6. Seed `docs/superpowers/ESCALATION.md` from `${CLAUDE_PLUGIN_ROOT}/assets/ESCALATION.md` if it does not already exist. Seed `docs/superpowers/README.md` from `${CLAUDE_PLUGIN_ROOT}/assets/SESSION_README.md` if missing. Commit any seeded files.
|
|
24
24
|
|
|
25
|
+
## Phase 0 — Stack detection, version pinning, shape decision
|
|
26
|
+
|
|
27
|
+
This phase runs **after** preflight clears (see the next section) and **before** spawning any teammate. It decides which teammates to spawn and pins the Superpowers version so a mid-feature skill update can't corrupt recovery.
|
|
28
|
+
|
|
29
|
+
### 0.1 — Read CLAUDE.md, or detect
|
|
30
|
+
|
|
31
|
+
1. Check whether `CLAUDE.md` exists at the repo root AND contains a fenced `team-superpower` block:
|
|
32
|
+
```bash
|
|
33
|
+
bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-claudemd.sh extract CLAUDE.md
|
|
34
|
+
```
|
|
35
|
+
- Exit 0: a block was extracted. Parse it. Skip to 0.2.
|
|
36
|
+
- Exit 1 (file missing or no block): run detection.
|
|
37
|
+
|
|
38
|
+
2. Run detection:
|
|
39
|
+
```bash
|
|
40
|
+
bash ${CLAUDE_PLUGIN_ROOT}/scripts/detect-stack.sh "$PWD" > /tmp/team-superpower-detected.yaml
|
|
41
|
+
```
|
|
42
|
+
- Exit 0 (confident): write the detected YAML (plus a one-line header) to `docs/superpowers/stack.detected.md` and commit. Halt with this message to the owner (via §7 escalation): "I detected this stack — `docs/superpowers/stack.detected.md`. Review the `# CONFIRM:` lines, paste the corrected block into a `team-superpower` fenced section of your CLAUDE.md (or create CLAUDE.md from `${CLAUDE_PLUGIN_ROOT}/assets/CLAUDE.md.template`), then re-run `/team-feature`." **Do NOT auto-edit CLAUDE.md — the spec forbids it.**
|
|
43
|
+
- Exit 1 (no signal): halt. Escalate to the owner: "No backend or frontend signal found in the repo. Create a CLAUDE.md from `${CLAUDE_PLUGIN_ROOT}/assets/CLAUDE.md.template` and re-run."
|
|
44
|
+
- Exit 2 (ambiguous): write the detected YAML to `docs/superpowers/stack.detected.md` with both candidate BE languages marked; halt and escalate so the owner picks one.
|
|
45
|
+
|
|
46
|
+
### 0.2 — Determine stack shape
|
|
47
|
+
|
|
48
|
+
Use the parser:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
shape="$(bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-claudemd.sh shape CLAUDE.md)"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`$shape` is one of `full-stack` | `be-only` | `fe-only` | `none`. If `none` (the block has `backend: none` AND `frontend: none`), halt and escalate — that combination is non-sensical.
|
|
55
|
+
|
|
56
|
+
### 0.3 — Cross-validate: claimed stack vs. filesystem
|
|
57
|
+
|
|
58
|
+
For every claimed component, verify at least one corresponding source file exists. Example checks:
|
|
59
|
+
|
|
60
|
+
- `backend.language: csharp` → at least one `*.csproj` or `*.sln` exists.
|
|
61
|
+
- `backend.language: node-ts` → `package.json` exists and declares a server dep (`express`, `fastify`, `koa`, `@nestjs/core`, etc.).
|
|
62
|
+
- `frontend.framework: react` → `package.json` declares `react`.
|
|
63
|
+
- `contracts.source_of_truth: openapi` → an OpenAPI file exists at `contracts.openapi_path` if specified.
|
|
64
|
+
|
|
65
|
+
If any claimed component has no file evidence, halt and escalate. CLAUDE.md is the contract, but a contract that contradicts the filesystem is a bug to flag, not a configuration to act on.
|
|
66
|
+
|
|
67
|
+
### 0.4 — Write the shape marker
|
|
68
|
+
|
|
69
|
+
Write the resolved shape to a marker file the hooks read:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
mkdir -p docs/superpowers/sessions
|
|
73
|
+
echo "$shape" > docs/superpowers/sessions/<slug>.shape
|
|
74
|
+
git add docs/superpowers/sessions/<slug>.shape
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The `TaskCreated` hook reads this marker to enforce shape-appropriate `impl:` sub-prefixes.
|
|
78
|
+
|
|
79
|
+
### 0.5 — Decide team composition (shape-adaptive spawn)
|
|
80
|
+
|
|
81
|
+
| Shape | Teammates to spawn |
|
|
82
|
+
|---------------|--------------------|
|
|
83
|
+
| `full-stack` | designer, planner, software-architect, security-engineer, backend-developer, frontend-developer, qa-engineer, reviewer (**8 total**) |
|
|
84
|
+
| `be-only` | designer, planner, software-architect, security-engineer, backend-developer, qa-engineer, reviewer (**7 total**) |
|
|
85
|
+
| `fe-only` | designer, planner, software-architect, security-engineer, frontend-developer, qa-engineer, reviewer (**7 total**) |
|
|
86
|
+
|
|
87
|
+
`software-architect`, `security-engineer`, `qa-engineer`, and `reviewer` are stack-agnostic and ALWAYS spawn. Designer, planner, and the implementers adapt.
|
|
88
|
+
|
|
89
|
+
Spawning happens at phase boundaries (you don't spawn implementers until phase 4 starts; you don't spawn the reviewer until phase 6) — this section just decides which teammates the team will EVER spawn for this feature. Record the list in the checkpoint.
|
|
90
|
+
|
|
91
|
+
### 0.6 — Pin the Superpowers version
|
|
92
|
+
|
|
93
|
+
Read the installed Superpowers version (from precheck step 1) and write it to the checkpoint frontmatter. This pins the skill-set for this feature. `/team-feature-resume` reads it back and refuses to continue if the installed version has drifted.
|
|
94
|
+
|
|
95
|
+
The frontmatter format is in the **Checkpointing** section below; the relevant added fields are:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
superpowers_version: <e.g. 5.0.7>
|
|
99
|
+
plugin_version: <team-superpower plugin version>
|
|
100
|
+
claude_code_version: <e.g. 2.1.32>
|
|
101
|
+
stack_shape: full-stack | be-only | fe-only
|
|
102
|
+
```
|
|
103
|
+
|
|
25
104
|
## Preflight — detect stale or orphaned state
|
|
26
105
|
|
|
27
106
|
Before writing any checkpoint or spawning any teammate, run the helper:
|
|
@@ -49,33 +128,89 @@ Same-session check: if the current Claude Code session already manages an agent
|
|
|
49
128
|
|
|
50
129
|
## Initial checkpoint and heartbeat
|
|
51
130
|
|
|
52
|
-
After preflight clears:
|
|
131
|
+
After preflight clears AND phase 0 has decided the shape:
|
|
53
132
|
|
|
54
|
-
1. Write the initial checkpoint `docs/superpowers/sessions/YYYY-MM-DD-<slug>.md` per the format in the **Checkpointing** section and commit it.
|
|
133
|
+
1. Write the initial checkpoint `docs/superpowers/sessions/YYYY-MM-DD-<slug>.md` per the format in the **Checkpointing** section — including the v2 frontmatter fields (`superpowers_version`, `plugin_version`, `claude_code_version`, `stack_shape`) — and commit it.
|
|
55
134
|
2. `touch docs/superpowers/sessions/<slug>.heartbeat` and commit (or leave uncommitted — the file is intentionally ephemeral; either is fine). **Touch this heartbeat at every phase boundary** and any time you remain active for more than ~10 minutes inside a phase. The cleanup script uses its mtime to decide whether a future session is allowed to wipe state.
|
|
56
|
-
3.
|
|
135
|
+
3. Ensure `docs/superpowers/sessions/<slug>.shape` was written in phase 0.4 and is committed.
|
|
136
|
+
4. Write checkpoint updates atomically: write to `<file>.tmp` then `mv -f <file>.tmp <file>`. Half-written checkpoints corrupt recovery.
|
|
137
|
+
|
|
138
|
+
## Spawn prompt template (use verbatim — do NOT improvise per role)
|
|
139
|
+
|
|
140
|
+
Every teammate spawn MUST hand over the same minimum context. A teammate inherits project context (`CLAUDE.md`, MCP servers, skills) automatically but does NOT inherit your conversation history — anything implicit on your side is invisible on theirs. Use this template:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
You are the <role> teammate for feature `<slug>`.
|
|
144
|
+
|
|
145
|
+
Stack shape: <full-stack | be-only | fe-only> (read docs/superpowers/sessions/<slug>.shape if you need to confirm)
|
|
146
|
+
Worktree: <absolute path> (planner records this in WORKTREE_READY)
|
|
147
|
+
Resume: <yes | no> (yes when spawned by /team-feature-resume; pick up at the next pending task)
|
|
148
|
+
|
|
149
|
+
Read first:
|
|
150
|
+
- CLAUDE.md (free-form prose AND the `team-superpower` block)
|
|
151
|
+
- Your role brief: <relative path to plugins/team-superpower/agents/<role>.md>
|
|
152
|
+
- <role-relevant artefact paths — list them all; e.g. design doc, plan, ARCH/SEC reports, QA report>
|
|
153
|
+
|
|
154
|
+
Open escalations:
|
|
155
|
+
<one-line summary per open escalation in the checkpoint, or "(none)">
|
|
156
|
+
|
|
157
|
+
Your task: <one sentence describing the specific phase work the role is being spawned for>
|
|
158
|
+
Mailbox signal expected back: <e.g. DESIGN_APPROVED <path>, PLAN_READY <path>, ARCH_PASSED <path>, BE_DONE <task-id>, etc.>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Fill every field. If a field is genuinely N/A for a role (e.g. there is no QA report when spawning the designer), write `n/a` rather than omitting the line — the template's stability is what keeps respawns deterministic.
|
|
57
162
|
|
|
58
163
|
## Phase chain (strict order — no skipping, no inlining)
|
|
59
164
|
|
|
60
165
|
1. **Design (designer).** Spawn the `designer` teammate. Hand it `<slug>` and the owner's request. Wait for `DESIGN_APPROVED <path>` in your mailbox. If the designer asks a clarifying question, answer from project context if unambiguous; otherwise batch with any open questions and use the §7 escalation template to the owner. Checkpoint: `phase: design, status: complete`. Touch heartbeat.
|
|
61
166
|
|
|
62
|
-
2. **Plan (planner).** Spawn the `planner` teammate. Hand it `<slug>` and the design doc path. Wait for `WORKTREE_READY` then `PLAN_READY <path>`. Route the plan to the owner for approval (second owner touchpoint). On approval, stamp `plan_approved_at: <ISO datetime>` into the metadata of every `impl:` task you will create — the `TaskCompleted` hook checks for it. Checkpoint: `phase: plan, status: approved`. Touch heartbeat.
|
|
167
|
+
2. **Plan (planner).** Spawn the `planner` teammate. Hand it `<slug>` and the design doc path. Wait for `WORKTREE_READY <path> <branch> <origin>` (`<origin>` ∈ {`reused`, `created`} — if the planner posts the legacy 2-arg form, treat as `created` for backward compatibility) then `PLAN_READY <path>`. Record both `**Worktree:** <path>` and `**Worktree origin:** <origin>` in the checkpoint. Route the plan to the owner for approval (second owner touchpoint). On approval, stamp `plan_approved_at: <ISO datetime>` into the metadata of every `impl:` task you will create — the `TaskCompleted` hook checks for it. Checkpoint: `phase: plan, status: approved`. Touch heartbeat.
|
|
63
168
|
|
|
64
169
|
3. **Pre-impl review gate (software-architect + security-engineer, parallel).** Spawn both. Hand each the design doc path AND the plan path. Wait for `ARCH_PASSED <path>` AND `SEC_PASSED <path>`. If either posts `ARCH_BLOCKED` / `SEC_BLOCKED`, route the findings to `planner` for a plan revision, then re-route to whichever gate is still blocking. Cap at three plan-revision rounds — escalate to owner via §7 if it does not converge. Checkpoint: `phase: pre_impl_review, status: passed | blocked`. Touch heartbeat.
|
|
65
170
|
|
|
66
|
-
4. **Implementation (
|
|
171
|
+
4. **Implementation (shape-adaptive, parallel where allowed).** Read the approved plan. Create one shared-task-list entry per plan task with the planner's assigned title (`impl:be-*`, `impl:fe-*`, `impl:be-migration-*`, `impl:be-contract-publish-*`), body = full task text including verification, and `depends_on` + `files` + `tests` + `estimated_minutes` + `plan_approved_at` metadata from the plan.
|
|
172
|
+
|
|
173
|
+
**Spawn rule (shape-adaptive):**
|
|
174
|
+
- `full-stack`: spawn one `backend-developer` AND one `frontend-developer`.
|
|
175
|
+
- `be-only`: spawn one `backend-developer` only. Do NOT spawn `frontend-developer`.
|
|
176
|
+
- `fe-only`: spawn one `frontend-developer` only. Do NOT spawn `backend-developer`.
|
|
177
|
+
|
|
178
|
+
**Contract publish (full-stack only).** If the planner emitted `impl:be-contract-publish-<slug>` as the first task, the backend-developer claims it first. Do NOT release any `impl:fe-*` task to the frontend-developer until you see `CONTRACT_PUBLISHED <task-id>` in your mailbox. The plan tasks already encode `depends_on: [impl:be-contract-publish-<slug>]` on every FE task, but you enforce the gate at the assignment level too.
|
|
179
|
+
|
|
180
|
+
**Mid-implementation contract drift.** If you receive `CONTRACT_DRIFT_DETECTED` from frontend-developer, or backend-developer files an `impl:contract-update-*` task on its own, pause all `impl:fe-*` in-flight work (post a "pause" message to frontend-developer's mailbox; it will idle on its current task). Wait for `CONTRACT_UPDATED <task-id>` from backend-developer, then unpause FE. Frontend-developer re-pulls the contract hash on resume.
|
|
181
|
+
|
|
182
|
+
**Migration serialization.** `impl:be-migration-*` tasks must run one at a time. The planner chains them via `depends_on`, the `TaskCompleted` hook is a backstop with `MIGRATION_RACE`, and you enforce it at assignment: do not release a second migration task while one is `in_progress`.
|
|
183
|
+
|
|
184
|
+
**File-scope conflict check.** Verify no two active implementer tasks overlap in file scope — if a conflict appears, serialize by holding the second task. Watch for `BE_DONE` / `FE_DONE`.
|
|
185
|
+
|
|
186
|
+
Checkpoint after each task transition: `phase: implementation, tasks_complete: M/N`. Touch heartbeat at every transition.
|
|
67
187
|
|
|
68
188
|
5. **QA gate (qa-engineer).** Once every `impl:` task is complete, spawn `qa-engineer`. Wait for `QA_PASSED <path>` or `QA_BLOCKED <path>`. If blocked, the QA report contains `impl:qa-fix-be-` / `impl:qa-fix-fe-` tasks — file them in the shared task list and loop to phase 4. Checkpoint: `phase: qa, status: passed | blocked`. Touch heartbeat.
|
|
69
189
|
|
|
70
190
|
6. **Code review (reviewer).** Once `QA_PASSED`, file a `review:` task and spawn the `reviewer` teammate. Wait for `REVIEW_PASSED <path>`. If critical issues come back instead, the reviewer report names the responsible implementer (`backend-developer` or `frontend-developer`) and the failing task — file `impl:review-fix-be-` / `impl:review-fix-fe-` tasks and loop to phase 4. Checkpoint: `phase: review, status: pass | critical_issues_returned`. Touch heartbeat.
|
|
71
191
|
|
|
72
|
-
7. **Finish (reviewer).** Same reviewer runs `finishing-a-development-branch`.
|
|
192
|
+
7. **Finish (reviewer, with CI gate).** Same reviewer runs `finishing-a-development-branch`. Before presenting the finish menu, the reviewer pushes the branch and (if `ci.provider != none`) polls CI per the `ci` block in CLAUDE.md until all `required_checks` go green, time out, or fail. On CI red, the reviewer posts `FINISH_BLOCKED ci-red <failed-checks>` and you surface the merge-failure menu with an added option F **"Show CI logs"**. On CI timeout, the reviewer posts `FINISH_BLOCKED ci-timeout` and you surface a 3-option menu (re-poll / switch to `pr_opened` / escalate). The CI gate is the **same finish-branch touchpoint** — no new touchpoint.
|
|
193
|
+
|
|
194
|
+
The owner makes the merge / PR / keep / discard decision (third and last owner touchpoint). On `FINISH_DONE <decision> <ref>`, checkpoint: `phase: finish, status: <merged|pr_opened|kept|discarded>`. Touch heartbeat. If the reviewer posts `FINISH_BLOCKED <reason>` (any reason — merge or CI), follow **Phase 7 merge-failure handling** below.
|
|
73
195
|
|
|
74
196
|
## Phase 7 merge-failure handling
|
|
75
197
|
|
|
76
|
-
When the reviewer posts `FINISH_BLOCKED <reason>` (instead of `FINISH_DONE`), the merge step
|
|
198
|
+
When the reviewer posts `FINISH_BLOCKED <reason>` (instead of `FINISH_DONE`), the merge step or the CI gate failed. Handle it inline — this is the same owner touchpoint as the finish-branch decision continued, NOT a new touchpoint.
|
|
77
199
|
|
|
78
|
-
`<reason>` is one of `conflict` / `non-ff` / `dirty-worktree` / `push-rejected` / `other:<short-string>` (see `agents/reviewer.md` § Hat 2 for the full enum and what each reason means).
|
|
200
|
+
`<reason>` is one of `conflict` / `non-ff` / `dirty-worktree` / `push-rejected` / `ci-red <failed-checks>` / `ci-timeout` / `other:<short-string>` (see `agents/reviewer.md` § Hat 2 for the full enum and what each reason means).
|
|
201
|
+
|
|
202
|
+
### CI-specific menus
|
|
203
|
+
|
|
204
|
+
For `ci-red <failed-checks>` use the standard 5-option merge-failure menu **plus an option F: Show CI logs**, which runs `gh run view --log-failed` (or the provider equivalent the reviewer is using) and pipes the output into the conversation, then re-presents the menu.
|
|
205
|
+
|
|
206
|
+
For `ci-timeout` use a 3-option menu:
|
|
207
|
+
|
|
208
|
+
> **CI did not finish within the poll window.** Pick one:
|
|
209
|
+
> - **A. Re-poll** — wait another `ci.poll_timeout_minutes` for CI to finish.
|
|
210
|
+
> - **B. Switch to pr_opened** — open a PR; the owner deals with CI on the PR side.
|
|
211
|
+
> - **E. Escalate** — §7 escalation, full reviewer status appended.
|
|
212
|
+
|
|
213
|
+
Re-poll is the same finish-branch touchpoint continued. The `merge_retries` counter does NOT apply to CI re-polls (it tracks merge attempts, not CI polls); cap re-polls at 3 instead, recorded as `ci_repolls: K/3` in the checkpoint.
|
|
79
214
|
|
|
80
215
|
1. Read the mailbox message. Stash `<reason>` and the verbatim git stderr.
|
|
81
216
|
2. Update the checkpoint: `phase: finish, status: merge_blocked, reason: <reason>, merge_retries: K/3` where `K` is the count of prior retry attempts in this run (start at 0).
|
|
@@ -184,12 +319,14 @@ Runs only after Step C / D have brought platform state to absent. Removes the pl
|
|
|
184
319
|
3. Step B teammate shutdown was clean.
|
|
185
320
|
4. The post-Step-C (or post-Step-D) scan shows `team_config_state: absent`, `task_list_state: absent`, `tmux_state: absent`.
|
|
186
321
|
5. The checkpoint has a non-empty `**Worktree:**` field.
|
|
322
|
+
6. The checkpoint records `**Worktree origin:** created`. A `reused` origin means the worktree existed before this run — it is the owner's, not ours to remove.
|
|
187
323
|
|
|
188
324
|
If any condition fails, record `worktree: removal-skipped:<reason>` in the Closing block (Step E) where `<reason>` is one of:
|
|
189
325
|
|
|
190
326
|
- `not-merged-decision` — finish decision was `pr_opened`, `kept`, or `discarded`.
|
|
191
327
|
- `team-cleanup-incomplete` — Step C/D left platform state present.
|
|
192
328
|
- `no-worktree-recorded` — checkpoint has no `**Worktree:**` line.
|
|
329
|
+
- `reused-existing-worktree` — `**Worktree origin:** reused`; the owner pre-existed the worktree and keeps it.
|
|
193
330
|
|
|
194
331
|
**Procedure** (only when all trigger conditions pass):
|
|
195
332
|
|
|
@@ -241,7 +378,7 @@ Append a closing block to the checkpoint:
|
|
|
241
378
|
- dropped_files: [<path>, ...] # only when state == force-removed
|
|
242
379
|
```
|
|
243
380
|
|
|
244
|
-
`removal-skipped` reasons: `not-merged-decision` | `team-cleanup-incomplete` | `no-worktree-recorded`.
|
|
381
|
+
`removal-skipped` reasons: `not-merged-decision` | `team-cleanup-incomplete` | `no-worktree-recorded` | `reused-existing-worktree`.
|
|
245
382
|
|
|
246
383
|
Remove the `<slug>.heartbeat` file. Commit the checkpoint. Confirm to the owner: "Team cleaned up. Feature complete."
|
|
247
384
|
|
|
@@ -249,6 +386,20 @@ Remove the `<slug>.heartbeat` file. Commit the checkpoint. Confirm to the owner:
|
|
|
249
386
|
|
|
250
387
|
Tell the owner exactly which step failed, include the script output verbatim, and instruct them to run `/team-cleanup <slug>` once they have confirmed nothing else is running. Do **not** retry cleanup loops automatically — the safety check is the heartbeat, and you cannot meaningfully refresh it from outside the lead process.
|
|
251
388
|
|
|
389
|
+
## Within-phase stall watchdog
|
|
390
|
+
|
|
391
|
+
Heartbeat at phase boundaries is not enough — a teammate can hang silently mid-phase and you'd never notice. Run a watchdog:
|
|
392
|
+
|
|
393
|
+
1. Read `limits.phase_stall_minutes` from CLAUDE.md (`bash ${CLAUDE_PLUGIN_ROOT}/scripts/parse-claudemd.sh get limits.phase_stall_minutes CLAUDE.md`). Default to **30** if unset.
|
|
394
|
+
2. Inside any phase, if the watchdog window elapses with **no mailbox message AND no shared-task-list state transition** from the active teammate(s):
|
|
395
|
+
- Send a ping to the teammate's mailbox: `STATUS_CHECK <slug> — no activity for <N> minutes; reply with current status or progress note.`
|
|
396
|
+
- Start a second watchdog window of the same length.
|
|
397
|
+
3. If a second watchdog window also elapses with no reply: surface a §7 escalation to the owner with the teammate's last-known status, the elapsed wall time, and the current phase. Halt — do NOT silently respawn or force-cancel; the owner decides.
|
|
398
|
+
|
|
399
|
+
The watchdog is **not** an owner touchpoint by itself — pinging the teammate is internal. Escalation step 3 is what reaches the owner, and only via the §7 template (so it doesn't count against the 3 allowed touchpoints either).
|
|
400
|
+
|
|
401
|
+
Reset the watchdog on every received mailbox message and every task transition. Touch the heartbeat each time you reset.
|
|
402
|
+
|
|
252
403
|
## Owner touchpoints (the ONLY allowed pings to the owner)
|
|
253
404
|
|
|
254
405
|
1. Design sign-off (phase 1, the brainstorming skill's built-in step).
|
|
@@ -262,11 +413,21 @@ Tell the owner exactly which step failed, include the script output verbatim, an
|
|
|
262
413
|
After every phase boundary, write `docs/superpowers/sessions/YYYY-MM-DD-<slug>.md` atomically (tmp + rename) per this format and commit it. This is the only way the workflow survives a `/resume` failure:
|
|
263
414
|
|
|
264
415
|
```markdown
|
|
416
|
+
---
|
|
417
|
+
slug: <slug>
|
|
418
|
+
started: <ISO datetime>
|
|
419
|
+
superpowers_version: <e.g. 5.0.7>
|
|
420
|
+
plugin_version: <team-superpower plugin version>
|
|
421
|
+
claude_code_version: <e.g. 2.1.32>
|
|
422
|
+
stack_shape: full-stack | be-only | fe-only
|
|
423
|
+
---
|
|
424
|
+
|
|
265
425
|
# Session: <slug>
|
|
266
426
|
**Started:** <ISO datetime>
|
|
267
427
|
**Last update:** <ISO datetime>
|
|
268
428
|
**Team:** superpower-<slug>
|
|
269
429
|
**Worktree:** <path>
|
|
430
|
+
**Worktree origin:** created | reused # `reused` means the owner launched `/team-feature` from inside a linked worktree; Step D.5 skips removal in that case
|
|
270
431
|
|
|
271
432
|
## Phases
|
|
272
433
|
- [x] design → docs/superpowers/specs/YYYY-MM-DD-<slug>-design.md
|
|
@@ -279,12 +440,13 @@ After every phase boundary, write `docs/superpowers/sessions/YYYY-MM-DD-<slug>.m
|
|
|
279
440
|
- [ ] finish — when `FINISH_BLOCKED <reason>` is in flight, this line reads `- [ ] finish (blocked: <reason>, merge_retries: K/3)` instead, and stays unchecked until `FINISH_DONE` arrives.
|
|
280
441
|
|
|
281
442
|
## Teammates
|
|
443
|
+
(list reflects stack_shape — omit the implementer that doesn't exist for be-only / fe-only)
|
|
282
444
|
- designer (agent-id: ...) — idle
|
|
283
445
|
- planner (agent-id: ...) — idle
|
|
284
446
|
- software-architect (agent-id: ...) — idle
|
|
285
447
|
- security-engineer (agent-id: ...) — idle
|
|
286
|
-
- backend-developer (agent-id: ...) — active on task impl:be-<name>
|
|
287
|
-
- frontend-developer (agent-id: ...) — idle
|
|
448
|
+
- backend-developer (agent-id: ...) — active on task impl:be-<name> # full-stack | be-only
|
|
449
|
+
- frontend-developer (agent-id: ...) — idle # full-stack | fe-only
|
|
288
450
|
- qa-engineer (agent-id: ...) — idle
|
|
289
451
|
- reviewer (agent-id: ...) — idle
|
|
290
452
|
|
|
@@ -313,4 +475,17 @@ After every phase boundary, write `docs/superpowers/sessions/YYYY-MM-DD-<slug>.m
|
|
|
313
475
|
- **Never** retry merge more than 3 times. After the 3rd `FINISH_BLOCKED`, drop option A from the 5-option menu and require B/C/D/E.
|
|
314
476
|
- **Never** treat the `FINISH_BLOCKED` menu as a new owner touchpoint. It is the same finish-branch touchpoint continued — the 3-touchpoint cap stays at 3.
|
|
315
477
|
|
|
316
|
-
|
|
478
|
+
## Hard rules (v2 additions)
|
|
479
|
+
|
|
480
|
+
- **Never** spawn `frontend-developer` in a `be-only` shape, or `backend-developer` in a `fe-only` shape. The shape was decided in phase 0.5 from CLAUDE.md (or the auto-detection fallback the owner has confirmed); deviating means a different team than the owner agreed to.
|
|
481
|
+
- **Never** auto-edit the user's `CLAUDE.md`. Phase 0 writes to `docs/superpowers/stack.detected.md` only and asks the owner to paste/edit. The user's CLAUDE.md is theirs.
|
|
482
|
+
- **Never** release an `impl:fe-*` task before `CONTRACT_PUBLISHED` arrives (full-stack with `contracts.source_of_truth != none`).
|
|
483
|
+
- **Never** release a second `impl:be-migration-*` task while one is `in_progress`. The hook is a backstop; you are the primary control.
|
|
484
|
+
- **Never** present the finish-branch menu before the CI gate either passes or is explicitly bypassed (CI red → menu with "Show CI logs"; CI timeout → 3-option menu; `ci.provider: none` → skip the gate entirely but still push).
|
|
485
|
+
- **Never** wait passively on a teammate for longer than `limits.phase_stall_minutes` (default 30) without running the within-phase stall watchdog above. Two consecutive stall windows with no teammate activity must escalate via §7.
|
|
486
|
+
- **Never** improvise a spawn prompt. Use the **Spawn prompt template** verbatim — leave fields as `n/a` rather than omitting them.
|
|
487
|
+
- **Never** spawn more than 5 teammates concurrently. The plugin defines up to 8 lifetime roles but phase-gating must keep ≤ 5 active at any moment. If a future change would break this, halt and escalate.
|
|
488
|
+
- **Never** run Step D.5 worktree removal when `**Worktree origin:** reused`. The worktree existed before `/team-feature` started; the owner owns it. Record `worktree: removal-skipped:reused-existing-worktree` and leave the worktree on disk.
|
|
489
|
+
- **Never** let the planner run inside a linked worktree on a protected branch (`main`, `master`, `develop`, `dev`, `release/*`, `releases/*`). The planner halts and escalates; the owner switches to a feature branch and re-runs.
|
|
490
|
+
|
|
491
|
+
Begin with the prechecks, then preflight, then run phase 0 (stack detection / shape decision / version pin / shape marker), then spawn `designer`.
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
# - task.title: string
|
|
7
7
|
# - task.metadata.plan_approved_at: string (ISO datetime), required for impl: tasks
|
|
8
8
|
# - task.metadata.blocked_questions: array of strings (optional)
|
|
9
|
+
# - task.metadata.commits: array of git SHAs (optional, used by v2 checks)
|
|
10
|
+
# - task.metadata.contract_files: array of paths (optional, for contract-publish)
|
|
9
11
|
#
|
|
10
|
-
#
|
|
11
|
-
# - impl:
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# v2 rules added on top of v1:
|
|
13
|
+
# - impl:be-migration-* completions: refuse if another in-progress migration
|
|
14
|
+
# exists in the shared task list payload (anti-race).
|
|
15
|
+
# - impl:be-contract-publish-* completions: at least one commit on this task
|
|
16
|
+
# must touch a contracts file (default `contracts/` directory, or paths
|
|
17
|
+
# listed in metadata.contract_files). Verified via `git show --name-only`.
|
|
15
18
|
|
|
16
19
|
set -euo pipefail
|
|
17
20
|
|
|
@@ -51,6 +54,52 @@ case "$title" in
|
|
|
51
54
|
;;
|
|
52
55
|
esac
|
|
53
56
|
|
|
57
|
+
# v2: migration serialization. If this is a migration task, verify no other
|
|
58
|
+
# `impl:be-migration-*` task is currently in_progress in the shared task list
|
|
59
|
+
# (payload.tasks[]). The lead also enforces this; the hook is a backstop.
|
|
60
|
+
case "$title" in
|
|
61
|
+
impl:be-migration-*)
|
|
62
|
+
other_in_progress="$(printf '%s' "$payload" | jq -r --arg me "$title" '
|
|
63
|
+
[ .tasks[]?
|
|
64
|
+
| select((.title // "") != $me)
|
|
65
|
+
| select(((.title // "") | startswith("impl:be-migration-")))
|
|
66
|
+
| select((.status // "") == "in_progress")
|
|
67
|
+
] | length' 2>/dev/null || echo 0)"
|
|
68
|
+
if [ "${other_in_progress:-0}" -gt 0 ]; then
|
|
69
|
+
echo "MIGRATION_RACE: another impl:be-migration-* task is in_progress; migrations must serialize. (title: $title)" >&2
|
|
70
|
+
exit 2
|
|
71
|
+
fi
|
|
72
|
+
;;
|
|
73
|
+
esac
|
|
74
|
+
|
|
75
|
+
# v2: contract-publish must actually touch a contracts file in at least one
|
|
76
|
+
# of its commits. Best-effort: skip if git unavailable or no commits recorded.
|
|
77
|
+
case "$title" in
|
|
78
|
+
impl:be-contract-publish-*)
|
|
79
|
+
if command -v git >/dev/null 2>&1; then
|
|
80
|
+
commits="$(printf '%s' "$payload" | jq -r '(.task.metadata.commits // .metadata.commits // [])[]?' 2>/dev/null || true)"
|
|
81
|
+
patterns="$(printf '%s' "$payload" | jq -r '(.task.metadata.contract_files // .metadata.contract_files // ["contracts/"])[]?' 2>/dev/null || echo "contracts/")"
|
|
82
|
+
if [ -n "$commits" ]; then
|
|
83
|
+
touched=0
|
|
84
|
+
while IFS= read -r sha; do
|
|
85
|
+
[ -z "$sha" ] && continue
|
|
86
|
+
files="$(git show --no-color --name-only --pretty=format: "$sha" 2>/dev/null || true)"
|
|
87
|
+
while IFS= read -r pat; do
|
|
88
|
+
[ -z "$pat" ] && continue
|
|
89
|
+
if printf '%s\n' "$files" | grep -qE "(^|/)${pat//./\\.}"; then
|
|
90
|
+
touched=1; break 2
|
|
91
|
+
fi
|
|
92
|
+
done <<< "$patterns"
|
|
93
|
+
done <<< "$commits"
|
|
94
|
+
if [ "$touched" -ne 1 ]; then
|
|
95
|
+
echo "EMPTY_CONTRACT_PUBLISH: $title claims to publish a contract but no commit touches a contract file (looked for: $(echo "$patterns" | tr '\n' ' '))" >&2
|
|
96
|
+
exit 2
|
|
97
|
+
fi
|
|
98
|
+
fi
|
|
99
|
+
fi
|
|
100
|
+
;;
|
|
101
|
+
esac
|
|
102
|
+
|
|
54
103
|
# Validate escalation entries if present.
|
|
55
104
|
required_fields=("Phase" "Context" "Options" "Recommendation" "Need from you")
|
|
56
105
|
missing_any=""
|
|
@@ -5,13 +5,23 @@
|
|
|
5
5
|
# - task.title: string
|
|
6
6
|
#
|
|
7
7
|
# Title MUST start with one of: impl:, review:, meta:, block:
|
|
8
|
-
#
|
|
9
|
-
#
|
|
8
|
+
# v2 additions:
|
|
9
|
+
# - impl: tasks MUST carry a sub-prefix (be-, fe-, qa-fix-be-, qa-fix-fe-,
|
|
10
|
+
# review-fix-be-, review-fix-fe-, contract-update-, be-migration-,
|
|
11
|
+
# be-contract-publish-) — bare `impl:foo` is rejected.
|
|
12
|
+
# - Shape-marker file at docs/superpowers/sessions/<slug>.shape (written by
|
|
13
|
+
# the lead in phase 0) restricts which sub-prefixes are allowed:
|
|
14
|
+
# be-only → only `impl:be-*`, `impl:contract-update-*` allowed
|
|
15
|
+
# fe-only → only `impl:fe-*`, `impl:contract-update-*` allowed
|
|
16
|
+
# full-stack → all sub-prefixes allowed
|
|
17
|
+
# - Slug is taken from .task.metadata.slug or .metadata.slug, with fallback
|
|
18
|
+
# to the most-recent .shape file when only one exists.
|
|
10
19
|
|
|
11
20
|
set -euo pipefail
|
|
12
21
|
|
|
13
22
|
LOG_DIR="${CLAUDE_PROJECT_DIR:-$PWD}/.claude/hooks"
|
|
14
23
|
LOG_FILE="$LOG_DIR/log.jsonl"
|
|
24
|
+
SESSIONS_DIR="${CLAUDE_PROJECT_DIR:-$PWD}/docs/superpowers/sessions"
|
|
15
25
|
mkdir -p "$LOG_DIR"
|
|
16
26
|
|
|
17
27
|
ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
@@ -29,11 +39,36 @@ if ! command -v jq >/dev/null 2>&1; then
|
|
|
29
39
|
fi
|
|
30
40
|
|
|
31
41
|
title="$(printf '%s' "$payload" | jq -r '.task.title // .title // ""' 2>/dev/null || echo "")"
|
|
42
|
+
slug="$(printf '%s' "$payload" | jq -r '.task.metadata.slug // .metadata.slug // ""' 2>/dev/null || echo "")"
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
# Resolve shape from the slug's marker file. If slug is unknown but exactly
|
|
45
|
+
# one .shape file exists, use it (single in-flight feature is the common case).
|
|
46
|
+
shape=""
|
|
47
|
+
if [ -d "$SESSIONS_DIR" ]; then
|
|
48
|
+
shape_file=""
|
|
49
|
+
if [ -n "$slug" ] && [ -f "$SESSIONS_DIR/$slug.shape" ]; then
|
|
50
|
+
shape_file="$SESSIONS_DIR/$slug.shape"
|
|
51
|
+
else
|
|
52
|
+
count="$(find "$SESSIONS_DIR" -maxdepth 1 -type f -name '*.shape' 2>/dev/null | wc -l | tr -d ' ')"
|
|
53
|
+
if [ "$count" = "1" ]; then
|
|
54
|
+
shape_file="$(find "$SESSIONS_DIR" -maxdepth 1 -type f -name '*.shape' 2>/dev/null | head -n1)"
|
|
55
|
+
fi
|
|
56
|
+
fi
|
|
57
|
+
if [ -n "$shape_file" ] && [ -f "$shape_file" ]; then
|
|
58
|
+
shape="$(head -n1 "$shape_file" | tr -d '[:space:]')"
|
|
59
|
+
fi
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
printf '{"ts":"%s","hook":"task-created","title":%s,"shape":%s}\n' \
|
|
63
|
+
"$ts" \
|
|
64
|
+
"$(printf '%s' "$title" | jq -Rs .)" \
|
|
65
|
+
"$(printf '%s' "$shape" | jq -Rs .)" \
|
|
66
|
+
>> "$LOG_FILE"
|
|
34
67
|
|
|
68
|
+
# Top-level prefix check
|
|
35
69
|
case "$title" in
|
|
36
|
-
|
|
70
|
+
review:*|meta:*|block:*) exit 0 ;;
|
|
71
|
+
impl:*) ;;
|
|
37
72
|
"")
|
|
38
73
|
echo "BAD_PREFIX: task title missing; must start with impl:|review:|meta:|block:" >&2
|
|
39
74
|
exit 2 ;;
|
|
@@ -41,3 +76,43 @@ case "$title" in
|
|
|
41
76
|
echo "BAD_PREFIX: task title must start with impl:|review:|meta:|block: (got: $title)" >&2
|
|
42
77
|
exit 2 ;;
|
|
43
78
|
esac
|
|
79
|
+
|
|
80
|
+
# At this point title starts with `impl:`. Strip prefix and require a known
|
|
81
|
+
# sub-prefix.
|
|
82
|
+
rest="${title#impl:}"
|
|
83
|
+
case "$rest" in
|
|
84
|
+
be-*|qa-fix-be-*|review-fix-be-*|be-migration-*|be-contract-publish-*)
|
|
85
|
+
sub="be"
|
|
86
|
+
;;
|
|
87
|
+
fe-*|qa-fix-fe-*|review-fix-fe-*)
|
|
88
|
+
sub="fe"
|
|
89
|
+
;;
|
|
90
|
+
contract-update-*)
|
|
91
|
+
sub="contract"
|
|
92
|
+
;;
|
|
93
|
+
*)
|
|
94
|
+
echo "BAD_PREFIX: impl: task requires a sub-prefix (be-|fe-|qa-fix-be-|qa-fix-fe-|review-fix-be-|review-fix-fe-|contract-update-|be-migration-|be-contract-publish-). Got: $title" >&2
|
|
95
|
+
exit 2 ;;
|
|
96
|
+
esac
|
|
97
|
+
|
|
98
|
+
# Shape-aware enforcement
|
|
99
|
+
case "$shape" in
|
|
100
|
+
be-only)
|
|
101
|
+
if [ "$sub" = "fe" ]; then
|
|
102
|
+
echo "SHAPE_REJECTED: shape is 'be-only'; impl:fe-* tasks are not allowed for this feature." >&2
|
|
103
|
+
exit 2
|
|
104
|
+
fi
|
|
105
|
+
;;
|
|
106
|
+
fe-only)
|
|
107
|
+
if [ "$sub" = "be" ]; then
|
|
108
|
+
echo "SHAPE_REJECTED: shape is 'fe-only'; impl:be-* tasks are not allowed for this feature." >&2
|
|
109
|
+
exit 2
|
|
110
|
+
fi
|
|
111
|
+
;;
|
|
112
|
+
full-stack|"")
|
|
113
|
+
# full-stack: anything goes. Empty shape: hook can't tell — accept and
|
|
114
|
+
# let the lead serialize/validate. Logged above for tuning.
|
|
115
|
+
;;
|
|
116
|
+
esac
|
|
117
|
+
|
|
118
|
+
exit 0
|