pi-gauntlet 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +300 -0
- package/LICENSE +24 -0
- package/README.md +278 -0
- package/agents/code-reviewer.md +48 -0
- package/agents/conformance-reviewer.md +139 -0
- package/agents/implementer.md +40 -0
- package/agents/spec-council-member.md +47 -0
- package/agents/spec-council-synthesizer.md +39 -0
- package/agents/spec-reviewer.md +47 -0
- package/agents/spec-summarizer.md +42 -0
- package/bin/install-agents.mjs +141 -0
- package/extensions/phase-tracker.ts +622 -0
- package/extensions/plan-tracker.ts +308 -0
- package/extensions/verify-before-ship.ts +132 -0
- package/package.json +43 -0
- package/skills/brainstorming/SKILL.md +290 -0
- package/skills/dispatching-parallel-agents/SKILL.md +192 -0
- package/skills/finishing-a-development-branch/SKILL.md +311 -0
- package/skills/receiving-code-review/SKILL.md +200 -0
- package/skills/requesting-code-review/SKILL.md +115 -0
- package/skills/requesting-code-review/code-reviewer.md +166 -0
- package/skills/roasting-the-spec/SKILL.md +139 -0
- package/skills/subagent-driven-development/SKILL.md +223 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +25 -0
- package/skills/subagent-driven-development/implementer-prompt.md +113 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +68 -0
- package/skills/systematic-debugging/SKILL.md +151 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/reference/rationalizations.md +61 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/test-driven-development/SKILL.md +230 -0
- package/skills/test-driven-development/reference/examples.md +99 -0
- package/skills/test-driven-development/reference/rationalizations.md +65 -0
- package/skills/test-driven-development/reference/when-stuck.md +31 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/using-git-worktrees/SKILL.md +193 -0
- package/skills/verification-before-completion/SKILL.md +169 -0
- package/skills/verification-before-completion/reference/conformance-check.md +220 -0
- package/skills/writing-plans/SKILL.md +244 -0
- package/skills/writing-skills/SKILL.md +429 -0
- package/skills/writing-skills/reference/anthropic-best-practices.md +1130 -0
- package/skills/writing-skills/reference/persuasion.md +187 -0
- package/skills/writing-skills/reference/testing-skills-with-subagents.md +384 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Code Review Agent
|
|
2
|
+
|
|
3
|
+
You are reviewing code changes for production readiness.
|
|
4
|
+
|
|
5
|
+
## Boundaries
|
|
6
|
+
|
|
7
|
+
- **Read code, run tests, run git commands: yes**
|
|
8
|
+
- **Edit, create, or delete any source files: NO**
|
|
9
|
+
- **Apply fixes or refactors: NO**
|
|
10
|
+
- You are a reviewer. Your output is a written report. You never touch the code.
|
|
11
|
+
|
|
12
|
+
**Your task:**
|
|
13
|
+
1. Review {WHAT_WAS_IMPLEMENTED}
|
|
14
|
+
2. Compare against {PLAN_OR_REQUIREMENTS}
|
|
15
|
+
3. Check code quality, architecture, testing
|
|
16
|
+
4. Categorize issues by severity
|
|
17
|
+
5. Flag plan deviations explicitly
|
|
18
|
+
6. Assess production readiness
|
|
19
|
+
|
|
20
|
+
## Calibration
|
|
21
|
+
|
|
22
|
+
Before writing the report:
|
|
23
|
+
|
|
24
|
+
- **Not everything is Critical.** Reserve Critical for bugs, data loss, security, broken functionality. A missing helper method is Important. A naming preference is Minor.
|
|
25
|
+
- **Lead with strengths.** Accurate praise earns the implementer's trust on the critique that follows. Generic praise ("good code") undermines it.
|
|
26
|
+
- **If you wouldn't block a PR over it, it's not Critical.** Be honest with yourself about severity before assigning it.
|
|
27
|
+
- **Plan deviations get their own treatment.** If the implementation diverged from the spec/plan — added scope, removed scope, changed an interface — call it out under a dedicated "Plan Deviations" heading, not buried in Critical or Minor.
|
|
28
|
+
|
|
29
|
+
## What Was Implemented
|
|
30
|
+
|
|
31
|
+
{DESCRIPTION}
|
|
32
|
+
|
|
33
|
+
## Requirements/Plan
|
|
34
|
+
|
|
35
|
+
{PLAN_REFERENCE}
|
|
36
|
+
|
|
37
|
+
## Git Range to Review
|
|
38
|
+
|
|
39
|
+
**Base:** {BASE_SHA}
|
|
40
|
+
**Head:** {HEAD_SHA}
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git diff --stat {BASE_SHA}..{HEAD_SHA}
|
|
44
|
+
git diff {BASE_SHA}..{HEAD_SHA}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Review Checklist
|
|
48
|
+
|
|
49
|
+
**Code Quality:**
|
|
50
|
+
- Clean separation of concerns?
|
|
51
|
+
- Proper error handling?
|
|
52
|
+
- Type safety (if applicable)?
|
|
53
|
+
- DRY principle followed?
|
|
54
|
+
- Edge cases handled?
|
|
55
|
+
|
|
56
|
+
**Architecture:**
|
|
57
|
+
- Sound design decisions?
|
|
58
|
+
- Scalability considerations?
|
|
59
|
+
- Performance implications?
|
|
60
|
+
- Security concerns?
|
|
61
|
+
|
|
62
|
+
**Testing:**
|
|
63
|
+
- Tests actually test logic (not mocks)?
|
|
64
|
+
- Edge cases covered?
|
|
65
|
+
- Integration tests where needed?
|
|
66
|
+
- All tests passing?
|
|
67
|
+
|
|
68
|
+
**Requirements:**
|
|
69
|
+
- All plan requirements met?
|
|
70
|
+
- Implementation matches spec?
|
|
71
|
+
- No scope creep?
|
|
72
|
+
- Breaking changes documented?
|
|
73
|
+
|
|
74
|
+
**Production Readiness:**
|
|
75
|
+
- Migration strategy (if schema changes)?
|
|
76
|
+
- Backward compatibility considered?
|
|
77
|
+
- Documentation complete?
|
|
78
|
+
- No obvious bugs?
|
|
79
|
+
|
|
80
|
+
## Output Format
|
|
81
|
+
|
|
82
|
+
### Strengths
|
|
83
|
+
[What's well done? Be specific.]
|
|
84
|
+
|
|
85
|
+
### Plan Deviations
|
|
86
|
+
[Did the implementation diverge from {PLAN_OR_REQUIREMENTS}? List each deviation with: what the spec said, what the code does, whether the deviation is acceptable. If none, write "None."]
|
|
87
|
+
|
|
88
|
+
### Issues
|
|
89
|
+
|
|
90
|
+
#### Critical (Must Fix)
|
|
91
|
+
[Bugs, security issues, data loss risks, broken functionality]
|
|
92
|
+
|
|
93
|
+
#### Important (Should Fix)
|
|
94
|
+
[Architecture problems, missing features, poor error handling, test gaps]
|
|
95
|
+
|
|
96
|
+
#### Minor (Nice to Have)
|
|
97
|
+
[Code style, optimization opportunities, documentation improvements]
|
|
98
|
+
|
|
99
|
+
**For each issue:**
|
|
100
|
+
- File:line reference
|
|
101
|
+
- What's wrong
|
|
102
|
+
- Why it matters
|
|
103
|
+
- How to fix (if not obvious)
|
|
104
|
+
|
|
105
|
+
### Recommendations
|
|
106
|
+
[Improvements for code quality, architecture, or process]
|
|
107
|
+
|
|
108
|
+
### Assessment
|
|
109
|
+
|
|
110
|
+
**Ready to merge?** [Yes/No/With fixes]
|
|
111
|
+
|
|
112
|
+
**Reasoning:** [Technical assessment in 1-2 sentences]
|
|
113
|
+
|
|
114
|
+
## Critical Rules
|
|
115
|
+
|
|
116
|
+
**DO:**
|
|
117
|
+
- Categorize by actual severity (not everything is Critical)
|
|
118
|
+
- Be specific (file:line, not vague)
|
|
119
|
+
- Explain WHY issues matter
|
|
120
|
+
- Acknowledge strengths
|
|
121
|
+
- Give clear verdict
|
|
122
|
+
|
|
123
|
+
**DON'T:**
|
|
124
|
+
- Say "looks good" without checking
|
|
125
|
+
- Mark nitpicks as Critical
|
|
126
|
+
- Give feedback on code you didn't review
|
|
127
|
+
- Be vague ("improve error handling")
|
|
128
|
+
- Avoid giving a clear verdict
|
|
129
|
+
|
|
130
|
+
## Example Output
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
### Strengths
|
|
134
|
+
- Clean database schema with proper migrations (db.ts:15-42)
|
|
135
|
+
- Comprehensive test coverage (18 tests, all edge cases)
|
|
136
|
+
- Good error handling with fallbacks (summarizer.ts:85-92)
|
|
137
|
+
|
|
138
|
+
### Issues
|
|
139
|
+
|
|
140
|
+
#### Important
|
|
141
|
+
1. **Missing help text in CLI wrapper**
|
|
142
|
+
- File: index-conversations:1-31
|
|
143
|
+
- Issue: No --help flag, users won't discover --concurrency
|
|
144
|
+
- Fix: Add --help case with usage examples
|
|
145
|
+
|
|
146
|
+
2. **Date validation missing**
|
|
147
|
+
- File: search.ts:25-27
|
|
148
|
+
- Issue: Invalid dates silently return no results
|
|
149
|
+
- Fix: Validate ISO format, throw error with example
|
|
150
|
+
|
|
151
|
+
#### Minor
|
|
152
|
+
1. **Progress indicators**
|
|
153
|
+
- File: indexer.ts:130
|
|
154
|
+
- Issue: No "X of Y" counter for long operations
|
|
155
|
+
- Impact: Users don't know how long to wait
|
|
156
|
+
|
|
157
|
+
### Recommendations
|
|
158
|
+
- Add progress reporting for user experience
|
|
159
|
+
- Consider config file for excluded projects (portability)
|
|
160
|
+
|
|
161
|
+
### Assessment
|
|
162
|
+
|
|
163
|
+
**Ready to merge: With fixes**
|
|
164
|
+
|
|
165
|
+
**Reasoning:** Core implementation is solid with good architecture and tests. Important issues (help text, date validation) are easily fixed and don't affect core functionality.
|
|
166
|
+
```
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: roasting-the-spec
|
|
3
|
+
description: Use after writing a spec, when a spec council is configured (piGauntlet.specCouncil in the repo's .pi/settings.json, else the active preset's settings). Auto-dispatched by /skill:brainstorming as the critique pass when members is non-empty (no longer offered). N members on different models critique in parallel, a neutral chair consolidates and adjudicates, the parent proposes dispositions, the user approves.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Roasting the Spec (Spec Council)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
A multi-model critique pass for a freshly written spec. Each council **member** runs on a different model and critiques the spec independently — different models surface different angles. A neutral **chair** consolidates the critiques and adjudicates disagreements. The parent proposes what to apply; the **user** approves. The council never decides on its own what changes land.
|
|
11
|
+
|
|
12
|
+
Auto-dispatched from `/skill:brainstorming` as the critique pass, after the inline lint and before the user review gate, **only when a council is configured** (`members` non-empty). brainstorming owns that gate; when no council is configured it runs a single fresh-`worker` critique instead and does not invoke this skill.
|
|
13
|
+
|
|
14
|
+
## Hard constraint
|
|
15
|
+
|
|
16
|
+
This skill may read anything and edit **only** the spec under `doc/specs/`. It does not write code, does not run implementation skills, and does not land anything on `main`. Applied edits ride in the same worktree spec commit as the rest of brainstorming's output.
|
|
17
|
+
|
|
18
|
+
## Separation of powers
|
|
19
|
+
|
|
20
|
+
- **Members** — independent witnesses. One per configured model, fresh context, read-only.
|
|
21
|
+
- **Chair** — judge of the testimony. Fresh context (never saw the spec authored); consolidates and resolves member-vs-member conflicts. Final say on conflicts; no say on what gets applied.
|
|
22
|
+
- **Parent (you)** — advocate. Proposes apply / defer / reject per finding on scope grounds. Cannot suppress findings.
|
|
23
|
+
- **User** — jury. Approves what actually lands, at the existing review gate.
|
|
24
|
+
|
|
25
|
+
## Configuration and gating
|
|
26
|
+
|
|
27
|
+
Resolve `piGauntlet.specCouncil` from **two** settings files, repo-local first:
|
|
28
|
+
|
|
29
|
+
1. `<repo-root>/.pi/settings.json` (repo root = `git rev-parse --show-toplevel`, which inside a worktree is the worktree root). **If this file defines `specCouncil`, it wins** — even an empty `members` here is an explicit "no council for this repo".
|
|
30
|
+
2. `$PI_CODING_AGENT_DIR/settings.json` (agent preset) — consulted **only** when the repo file does not define `specCouncil` at all.
|
|
31
|
+
|
|
32
|
+
The first file that defines the key wins; do not merge member lists across files. Do not hardcode a project path in place of `$PI_CODING_AGENT_DIR` — expand the env var. The resolved config looks like:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"piGauntlet": {
|
|
37
|
+
"specCouncil": {
|
|
38
|
+
"members": ["<provider/model>", "<provider/model>"],
|
|
39
|
+
"chair": "<provider/model>"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- `members` — array of `provider/model` strings. Council size = array length.
|
|
46
|
+
- `chair` — optional model for the synthesizer; if omitted, the synthesizer inherits the parent's model.
|
|
47
|
+
|
|
48
|
+
brainstorming owns the gate: it parses this config (it may contain comments — read it, do not pipe through a strict JSON parser), emits any malformed-config warning, and decides whether to invoke this skill. This skill is dispatched **only after** brainstorming confirms `members` is non-empty, so it runs the council unconditionally on entry — no offer, no numbered choice. Absent/empty/malformed config never reaches here (brainstorming runs the fresh-`worker` critique instead). A minimal defensive re-parse is fine, but ownership of "should the council run" lives in brainstorming, not here.
|
|
49
|
+
|
|
50
|
+
## The council run
|
|
51
|
+
|
|
52
|
+
### 1 — Fan out to members
|
|
53
|
+
|
|
54
|
+
Create an absolute temp dir outside the worktree so member files are never tracked by git:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
mktemp -d # absolute path, e.g. /tmp/tmp.XXXXXX
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Dispatch one member per configured model, in parallel, each writing its critique into that dir. Do **not** read these files yourself — they are for the chair.
|
|
61
|
+
|
|
62
|
+
Capture the worktree path once (`git rev-parse --show-toplevel`, run from inside the worktree) and pass it as `cwd:` on every dispatch below — a child otherwise inherits pi's launch dir (the primary checkout), not the worktree.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
subagent({
|
|
66
|
+
control: { needsAttentionAfterMs: 600000 },
|
|
67
|
+
tasks: members.map((model, i) => ({
|
|
68
|
+
agent: "spec-council-member",
|
|
69
|
+
model,
|
|
70
|
+
cwd: "<abs worktree path>",
|
|
71
|
+
task: "Problem statement: <the problem the spec addresses, from its Context section and the user's stated intent>.\n" +
|
|
72
|
+
"Read the spec at <abs path to doc/specs/...>. Critique it on your five axes and emit your template.",
|
|
73
|
+
output: "<tmpdir>/member-" + i + "-" + slug(model) + ".md"
|
|
74
|
+
}))
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`control` is a **run-level** field: it must sit beside `tasks`, not inside the `members.map(...)` task objects (the per-task schema has no `control` field and would silently drop it). The 10-minute `needsAttentionAfterMs` suppresses false-positive "no observed activity" idle notices — members do one long, tool-less reasoning turn that crosses the 60s default with zero activity events — while still letting a genuinely wedged run surface eventually.
|
|
79
|
+
|
|
80
|
+
`slug(model)` = the model string with `/` and any other non-alphanumeric character replaced by `-` (so `provider/model` → `provider-model`); the chair recovers this slug from each filename for `raised-by` attribution. Relative `output:` paths in parallel mode resolve against the worktree and would get committed — always use the absolute temp dir.
|
|
81
|
+
|
|
82
|
+
If a member fails (e.g. its model is unreachable in this preset), skip it and continue as long as at least one member succeeded. If **all** members fail, abort the council, say so, and return to the user gate.
|
|
83
|
+
|
|
84
|
+
### 2 — Synthesize and adjudicate
|
|
85
|
+
|
|
86
|
+
Dispatch the chair once. It reads the member files (not you), the spec, and the problem statement, and returns one consolidated, conflict-resolved report. You ingest **only** this report.
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
subagent({
|
|
90
|
+
agent: "spec-council-synthesizer",
|
|
91
|
+
model: <chair from config, else omit to inherit>,
|
|
92
|
+
cwd: "<abs worktree path>",
|
|
93
|
+
control: { needsAttentionAfterMs: 600000 },
|
|
94
|
+
reads: [ <the member file paths under the temp dir> ],
|
|
95
|
+
task: "Problem statement: <paste>. Spec: <abs path>.\n" +
|
|
96
|
+
"Member critiques (already injected via reads — do not search for them):\n" +
|
|
97
|
+
members.map((model, i) => "<tmpdir>/member-" + i + "-" + slug(model) + ".md").join("\n") + "\n" +
|
|
98
|
+
"Consolidate and adjudicate the member critiques."
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The chair runs one long single-turn synthesis (one observed false positive ran 506s); `control: { needsAttentionAfterMs: 600000 }` raises the idle threshold to 10 minutes so the healthy run is not flagged stale, without disabling attention tracking entirely.
|
|
103
|
+
|
|
104
|
+
List the exact member paths in the task text. The `reads:` array injects their contents, but the chair's prompt expects the paths explicitly; without them it scans the tree for `*.md` and stalls.
|
|
105
|
+
|
|
106
|
+
If the configured `chair` model is unreachable, retry once with the inherited model.
|
|
107
|
+
|
|
108
|
+
### 3 — Propose dispositions
|
|
109
|
+
|
|
110
|
+
For each cluster in the chair's report, decide and state one of:
|
|
111
|
+
|
|
112
|
+
- **apply** — with the concrete edit you will make.
|
|
113
|
+
- **defer** — out of scope for this spec; name where it belongs.
|
|
114
|
+
- **reject** — with a one-line reason.
|
|
115
|
+
|
|
116
|
+
You are the advocate here, not the judge — propose, do not unilaterally apply.
|
|
117
|
+
|
|
118
|
+
### 4 — User gate
|
|
119
|
+
|
|
120
|
+
Fold the chair's clusters, its `resolved` audit notes, and your proposed dispositions into brainstorming's user review gate. Let the user approve or adjust.
|
|
121
|
+
|
|
122
|
+
### 5 — Apply and clean up
|
|
123
|
+
|
|
124
|
+
Apply the approved edits to the spec under `doc/specs/`. Re-run brainstorming's placeholder scan. Remove the temp dir (`rm -rf` the `mktemp -d` path). Then continue with brainstorming's normal commit. Nothing council-related (member files) is ever staged.
|
|
125
|
+
|
|
126
|
+
Single pass — no automatic re-roast loop. The user can invoke this skill again after edits for another round.
|
|
127
|
+
|
|
128
|
+
## Red flags — STOP
|
|
129
|
+
|
|
130
|
+
- Running the council when `piGauntlet.specCouncil.members` is absent or empty (brainstorming owns the gate and should have used the worker fallback).
|
|
131
|
+
- Reading member critique files yourself instead of routing them through the chair.
|
|
132
|
+
- Writing member files to a relative path (they land in the worktree).
|
|
133
|
+
- Auto-applying findings without the user gate.
|
|
134
|
+
- Surfacing member-vs-member disagreements to the user instead of letting the chair adjudicate.
|
|
135
|
+
- Editing anything other than the spec under `doc/specs/`.
|
|
136
|
+
|
|
137
|
+
## Project overrides
|
|
138
|
+
|
|
139
|
+
If `.pi/gauntlet-overrides.md` exists, read it. Any sections relevant to this skill — by name match, by topic (routing, verification, worktrees, etc.), or by workflow convention — override or extend the instructions above. Project-local `AGENTS.md` is already in context — check it for project-specific routing tables, service paths, and verification commands.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subagent-driven-development
|
|
3
|
+
description: Use when executing implementation plans with independent tasks in the current session
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
> **Related skills:** Need an isolated workspace? `/skill:using-git-worktrees`. Need a plan first? `/skill:writing-plans`. Done? `/skill:finishing-a-development-branch`. Reached via the auto-chain from `/skill:writing-plans` (not a direct human entry point; direct invocation stays possible for recovery, e.g. re-running after a STOP).
|
|
7
|
+
|
|
8
|
+
# Subagent-Driven Development
|
|
9
|
+
|
|
10
|
+
Execute a plan by dispatching a **fresh subagent per task**, with two-stage review after each: spec compliance first, then code quality.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Fresh subagent per task + two-stage review = high quality, fast iteration.
|
|
13
|
+
|
|
14
|
+
If a tool result contains a ⚠️ workflow warning, stop immediately and address it before continuing.
|
|
15
|
+
|
|
16
|
+
## Why Subagents
|
|
17
|
+
|
|
18
|
+
Your context window holds the full plan, prior decisions, and conversation history. Each subagent gets a fresh window with only the current task's text and context.
|
|
19
|
+
|
|
20
|
+
- **No context pollution.** Task N's noise doesn't leak into Task N+1.
|
|
21
|
+
- **Tighter focus.** Subagent reads less, makes fewer cross-task assumptions, ships smaller diffs.
|
|
22
|
+
- **Cheaper at scale.** Smaller models can handle simple subtasks; you only spend top-tier tokens on orchestration and hard problems.
|
|
23
|
+
|
|
24
|
+
You are the **orchestrator**. You read the plan, dispatch, review the review, decide. You do **not** write code yourself.
|
|
25
|
+
|
|
26
|
+
## Continuous Execution
|
|
27
|
+
|
|
28
|
+
**Do not pause to check in with the user between tasks.** The plan is already approved. Pause only when:
|
|
29
|
+
|
|
30
|
+
- A subagent returns `NEEDS_CONTEXT` or `BLOCKED` (see [Implementer Status](#implementer-status))
|
|
31
|
+
- A reviewer finds issues the implementer cannot resolve in two attempts
|
|
32
|
+
- A ⚠️ workflow warning fires
|
|
33
|
+
- You hit the end of the plan (then stop and report — see [After All Tasks](#after-all-tasks-complete))
|
|
34
|
+
|
|
35
|
+
Periodic "should I continue?" prompts add latency without adding safety. The plan is the contract; execute it.
|
|
36
|
+
|
|
37
|
+
## Prerequisites
|
|
38
|
+
|
|
39
|
+
- Running inside a dedicated worktree (the same one the spec and plan were authored in). If you're on `main` in the primary checkout, stop and invoke `/skill:using-git-worktrees` first — implementation never lands directly on `main`.
|
|
40
|
+
- Approved plan or clear task scope
|
|
41
|
+
- `plan_tracker` initialized with the full task list
|
|
42
|
+
|
|
43
|
+
## Sequential vs. Parallel-Wave
|
|
44
|
+
|
|
45
|
+
subagent-driven-development runs **sequentially by default**; when the plan groups independent tasks into waves, [Parallel-Wave Mode](#parallel-wave-mode) parallelizes the tasks within a wave. The mode is auto-selected by `writing-plans` at handoff (≥2 tasks in some wave → parallel; else sequential) — you are not asked to choose.
|
|
46
|
+
|
|
47
|
+
**Dependent tasks:** include the previous task's implementation summary and relevant file paths in the next subagent's `task`. Track outputs so you can pass them forward.
|
|
48
|
+
|
|
49
|
+
## The Process
|
|
50
|
+
|
|
51
|
+
Before the first task, enter the implement phase: `phase_tracker({ action: "start", phase: "implement" })` — you hold this phase for the parent session while the per-task work is dispatched to subagents; `plan_tracker` auto-completes it once every task is done.
|
|
52
|
+
|
|
53
|
+
For each task in `plan_tracker`:
|
|
54
|
+
|
|
55
|
+
1. **Dispatch implementer.** Pass the full task text + scene-setting context. Don't make the subagent re-read the plan.
|
|
56
|
+
2. **Handle implementer status** (see below).
|
|
57
|
+
3. **Dispatch spec reviewer.** Verify the diff matches the spec — nothing missing, nothing extra.
|
|
58
|
+
4. If spec reviewer finds gaps → re-dispatch implementer to fix → re-review. Loop until ✅.
|
|
59
|
+
5. **Dispatch code-quality reviewer.** Only after spec is ✅.
|
|
60
|
+
6. If quality reviewer finds issues → re-dispatch implementer → re-review. Loop until ✅.
|
|
61
|
+
7. Mark task complete in `plan_tracker`.
|
|
62
|
+
|
|
63
|
+
After all tasks: dispatch a final reviewer over the full diff. Then [After All Tasks](#after-all-tasks-complete).
|
|
64
|
+
|
|
65
|
+
## Implementer Status
|
|
66
|
+
|
|
67
|
+
Every implementer dispatch returns one of:
|
|
68
|
+
|
|
69
|
+
| Status | Meaning | Orchestrator action |
|
|
70
|
+
|---|---|---|
|
|
71
|
+
| `DONE` | Implemented + tests pass + self-reviewed + committed | Proceed to spec review |
|
|
72
|
+
| `DONE_WITH_CONCERNS` | Implemented + tests pass, but flagged a deviation or risk | Read concerns. If acceptable, proceed. If not, dispatch fix subagent. |
|
|
73
|
+
| `NEEDS_CONTEXT` | Implementer needs information you have | Answer the questions, re-dispatch with answers in the task text |
|
|
74
|
+
| `BLOCKED` | Cannot proceed (missing dependency, spec contradicts code, environment broken) | Stop. Diagnose. Either fix orchestration-level issue and re-dispatch, or escalate to user. |
|
|
75
|
+
|
|
76
|
+
Implementer prompt templates must instruct subagents to return one of these statuses explicitly.
|
|
77
|
+
|
|
78
|
+
## Model Selection
|
|
79
|
+
|
|
80
|
+
Pi-subagents accepts a per-task `model` override. Use it.
|
|
81
|
+
|
|
82
|
+
| Task complexity | Model tier | Use cases |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| Trivial mechanical change | Cheap | Rename, formatter run, dependency bump, file-move with no edits |
|
|
85
|
+
| Standard implementation | Default | Most plan tasks — feature work with tests, refactor with tests |
|
|
86
|
+
| Hard / novel / large surface | Most capable | New subsystem, complex algorithm, cross-service contract change |
|
|
87
|
+
| Spec review | Default | Reads diff + spec, mechanical comparison |
|
|
88
|
+
| Code-quality review | Most capable | Judgment call on naming, design, complexity |
|
|
89
|
+
| Final reviewer | Most capable | Whole-PR-scope review |
|
|
90
|
+
| Conformance / closure | Most capable | Whole-deliverable-vs-origin intent gate (`conformance-reviewer`; model from `piGauntlet.closureReview.model`, injected call-site) |
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
subagent({
|
|
94
|
+
agent: "implementer",
|
|
95
|
+
task: "...",
|
|
96
|
+
model: "anthropic/claude-haiku-4" // cheap tier
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
When in doubt, default. Don't downgrade reviewers — false negatives are expensive.
|
|
101
|
+
|
|
102
|
+
## Dispatch
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// implementer
|
|
106
|
+
subagent({ agent: "implementer", task: "<task text + context + status protocol>" })
|
|
107
|
+
|
|
108
|
+
// spec compliance
|
|
109
|
+
subagent({ agent: "spec-reviewer", task: "<diff range + spec excerpt + ask: does this match?>" })
|
|
110
|
+
|
|
111
|
+
// code quality
|
|
112
|
+
subagent({ agent: "code-reviewer", task: "<diff range + ask: production-ready?>" })
|
|
113
|
+
|
|
114
|
+
// closing-loop conformance (origin vs deliverable) — its OWN dispatch, never fused with code quality
|
|
115
|
+
// model from piGauntlet.closureReview.model (read $PI_CODING_AGENT_DIR/settings.json); omit to inherit
|
|
116
|
+
subagent({ agent: "conformance-reviewer", model: /* piGauntlet.closureReview.model from config, else omit to inherit */, task: "<spec path + verbatim original prompt + full diff vs main; per conformance-check.md>" })
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Prompt templates live alongside this SKILL.md:
|
|
120
|
+
|
|
121
|
+
- `./implementer-prompt.md`
|
|
122
|
+
- `./spec-reviewer-prompt.md`
|
|
123
|
+
- `./code-quality-reviewer-prompt.md`
|
|
124
|
+
|
|
125
|
+
## Parallel-Wave Mode
|
|
126
|
+
|
|
127
|
+
Auto-selected at handoff by `writing-plans` (any wave with ≥2 tasks) when the plan groups tasks into **waves** (see `writing-plans`). Waves run in sequence; within a wave, tasks that the plan certified file- **and** runtime-resource-disjoint run concurrently in isolated worktrees, integrated serially behind one test + review gate. The sequential [Process](#the-process) above is the default and the fallback; this mode is the deliberate, worktree-isolated exception to the "no parallel implementers" red flag.
|
|
128
|
+
|
|
129
|
+
**Enter the implement phase first.** Before the first wave, call `phase_tracker({ action: "start", phase: "implement" })` (as in [The Process](#the-process)); `plan_tracker` auto-completes it once every task across all waves is done.
|
|
130
|
+
|
|
131
|
+
**Progress tracking (`plan_tracker`).** `plan_tracker` is a flat list with no native group concept, so waves are *encoded*, not modeled:
|
|
132
|
+
|
|
133
|
+
- **Init once, wave-ordered:** `init` with every task across all waves in wave order, each name prefixed with its wave (`"W1: <title>"`, `"W2: <title>"`, …). Indices are positional and stable; never re-init mid-run (it drops statuses).
|
|
134
|
+
- **Wave fan-out → `in_progress`:** mark every task index in the wave `in_progress`. Multiple simultaneous `in_progress` entries is expected (sequential mode has one).
|
|
135
|
+
- **Wave commit → `complete`:** after the wave's gate passes and it commits, mark all that wave's indices `complete`. `complete` = durably committed, so a task in conflict-fallback stays `in_progress` until its wave commits.
|
|
136
|
+
- **Lifecycle per task:** `pending → in_progress (wave fan-out) → complete (wave commit)`.
|
|
137
|
+
- **Widget caveat (known, deliberately unfixed).** The persistent `plan_tracker` widget's icon strip (`○ → ✓`) and `(c/total)` count reflect every task, but its trailing *name* shows only the **first** `in_progress` task. In parallel mode the icon strip and the `status` action are the full in-flight view; a richer multi-task widget is a separate extension change, out of scope (YAGNI).
|
|
138
|
+
- **Sequential mode is unchanged:** init the full list, one `in_progress` at a time; wave prefixes are harmless if present.
|
|
139
|
+
|
|
140
|
+
**Per-wave loop:**
|
|
141
|
+
|
|
142
|
+
1. **Independence check.** Parse the wave's tasks' `Files:` blocks; assert pairwise-disjoint (mechanical). Runtime-resource disjointness (DB/schema, port, fixture, external service, shared temp path) is not machine-checkable here — trust the plan's wave grouping, which `writing-plans`' D5 contract guarantees. Either kind of overlap → the wave is mis-grouped; run those tasks as sequential single-task waves and note it.
|
|
143
|
+
2. **Fan out.** One parallel dispatch (shape below): `implementer` per task, `context: "fresh"`, `worktree: true`. Each returns a status + a patch.
|
|
144
|
+
3. **Status + spec review per task.** Parse each `DONE`/`BLOCKED`/etc. (see [Implementer Status](#implementer-status)); spec-review each returned patch against its task (read-only, parallelizable). Re-dispatch incomplete tasks (fresh, `worktree: true`) until `DONE` + spec ✅.
|
|
145
|
+
4. **Integrate.** `git apply` each task's patch sequentially onto HEAD. Apply fails = textual conflict → drop that task, finish the rest, re-run the dropped task sequentially on the updated HEAD.
|
|
146
|
+
5. **Test gate.** Run the suite on the integrated tree. Failure = semantic conflict or bug → re-run the offending task sequentially, else fix per [When a Subagent Fails](#when-a-subagent-fails).
|
|
147
|
+
6. **Quality review.** Code-quality review on the integrated wave diff; loop fixes to ✅.
|
|
148
|
+
7. **Commit the wave.** Leaves a clean tree; the next wave's children branch from this commit and so see the integrated work.
|
|
149
|
+
|
|
150
|
+
**Two-stage review is preserved:** spec review per task (pre-integration), quality review per wave (post-integration). Both gates required before the wave commits.
|
|
151
|
+
|
|
152
|
+
**Dependent context across waves:** wave N+1 tasks branch from a HEAD containing wave N, so they see the code; still forward wave N's task summaries into wave N+1 prompts.
|
|
153
|
+
|
|
154
|
+
**Caveat:** each task must be independently runnable and verifiable in a fresh worktree — no reliance on uncommitted local state. `pi-cohort` symlinks `node_modules`; repos needing other per-worktree setup must account for it.
|
|
155
|
+
|
|
156
|
+
**Set `cwd` to your worktree — resilience-critical.** This whole workflow runs *inside* a worktree, but the `subagent` tool resolves the worktree base from the **top-level `cwd`**, which defaults to the orchestrator's process cwd — the *primary* checkout (usually `main`), not the worktree. Omit `cwd` and `worktree: true` branches every child from the primary checkout's HEAD: the children never see your spec, plan, or prior-wave commits, and integration runs against the wrong baseline. Pass the worktree's absolute path as the top-level `cwd`. Do **not** set per-task `cwd` under `worktree: true` — pi-cohort requires it to equal the shared cwd and errors otherwise. (Clean-tree is enforced here too — `resolveRepoState` rejects a dirty tree — which is why each wave commits before the next.)
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
subagent({
|
|
160
|
+
context: "fresh",
|
|
161
|
+
cwd: "/abs/path/to/this/worktree", // REQUIRED: the worktree you're in, else children branch from main
|
|
162
|
+
worktree: true, // each task in its own git worktree, branched from cwd's HEAD
|
|
163
|
+
concurrency: 4, // default; cap = wave size
|
|
164
|
+
tasks: [
|
|
165
|
+
// do NOT set per-task cwd under worktree:true — it must equal the top-level cwd or the run errors
|
|
166
|
+
{ agent: "implementer", task: "<task text + owned files + status protocol>", output: "wave1-task1.md" },
|
|
167
|
+
{ agent: "implementer", task: "<task text + owned files + status protocol>", output: "wave1-task2.md" },
|
|
168
|
+
],
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
For the fan-out + worktree + patch-integration + conflict mechanics, see `dispatching-parallel-agents`.
|
|
173
|
+
|
|
174
|
+
## When a Subagent Fails
|
|
175
|
+
|
|
176
|
+
**You are the orchestrator. You do NOT write code.**
|
|
177
|
+
|
|
178
|
+
1. **Attempt 1:** dispatch a NEW fix subagent with the error output, the original task, and specific instructions about what went wrong.
|
|
179
|
+
2. **Attempt 2:** if attempt 1 also fails, dispatch one more with a simplified scope or different approach.
|
|
180
|
+
3. **After 2 failed attempts:** STOP. Report failure to the user. The task probably needs redesign.
|
|
181
|
+
|
|
182
|
+
**NEVER:**
|
|
183
|
+
- Write code yourself to "help" or "finish up"
|
|
184
|
+
- Fix the subagent's work inline — that pollutes your context and defeats fresh-subagent isolation
|
|
185
|
+
- Silently skip the failed task
|
|
186
|
+
- Lower quality gates (skip reviews) because a task is "almost done"
|
|
187
|
+
|
|
188
|
+
## After All Tasks Complete
|
|
189
|
+
|
|
190
|
+
0. Call `phase_tracker({ action: "start", phase: "verify" })`. (The `implement` phase was started at execution start and auto-completes from `plan_tracker` once all tasks are done; this flow runs its own verify gate instead of `/skill:verification-before-completion`, so it must mark verify itself.)
|
|
191
|
+
1. Dispatch the final reviewer over the full diff (already covered in [The Process](#the-process) step "After all tasks").
|
|
192
|
+
2. **Run an audit pass automatically.** Run `/skill:requesting-code-review` against the worktree's full diff vs `main`. Then, if the project ships a project-specific audit skill (e.g., `.agents/skills/self-audit/`), run it as an optional supplement (it adds project-specific checks and fixes, not a replacement). Address Critical and Moderate findings before handoff. Do not ask the user — just run it.
|
|
193
|
+
3. **Close the loop — conformance check.** The audit in step 2 is plan-vs-code (single-step); it inherits any requirement the plan already dropped. Before marking verify complete, dispatch a fresh-context **`conformance-reviewer`** — its **own** dispatch, never fused into the step-1 final review — to confront the deliverable (code **and** docs) against the *origin* — the spec **and** the original prompt — per `verification-before-completion/reference/conformance-check.md`. Pass the spec path, the verbatim original prompt, and the full diff. On `GAPS`, do not auto-fix or auto-proceed: run the remediation loop in `verification-before-completion/reference/conformance-check.md` "When the check finds gaps" (disposition menu → isolated fix waves → bounded delta re-audit, capped by `piGauntlet.closureReview.maxFixRounds`). Only when the verdict is `CONFORMS` (or every gap is dispositioned) call `phase_tracker({ action: "complete", phase: "verify" })`.
|
|
194
|
+
4. Summarize what was implemented (tasks completed, files changed, test counts, self-audit verdict). Give the closing loop its **own section** — `Closure / conformance: CONFORMS` (or `GAPS` with each gap and its disposition) — so the user sees intent-fidelity as a first-class line before any finishing decision, not buried in the audit verdict.
|
|
195
|
+
5. **Proceed to finishing — no confirmation prompt.** When the verdict is `CONFORMS` (or every gap is dispositioned), invoke `/skill:finishing-a-development-branch` immediately. Its Step 4 menu (squash / PR / keep / discard) is the human gate; a separate "ready to finish?" prompt only stacks a second stop in front of it. Open gaps are already owned by step 3, so nothing is left to decide here. Manual testing is a follow-up after the finishing choice (on `<base-branch>` after a squash-merge, or on the PR branch), never a reason to hold this gate.
|
|
196
|
+
|
|
197
|
+
## Red Flags — STOP
|
|
198
|
+
|
|
199
|
+
- Writing code yourself instead of dispatching
|
|
200
|
+
- Dispatching parallel implementers on overlapping files, or without `worktree: true` outside Parallel-Wave Mode (wave mode is the sanctioned exception: disjoint files + worktree isolation + serial integration)
|
|
201
|
+
- Parallelizing a wave whose tasks contend on a shared mutable runtime resource (DB/schema, port, fixture, external service, shared temp path) — that wave was mis-grouped; run those tasks as sequential single-task waves
|
|
202
|
+
- Making a subagent read the plan instead of passing task text
|
|
203
|
+
- Starting code-quality review before spec compliance is ✅
|
|
204
|
+
- Moving to next task with either review still showing issues
|
|
205
|
+
- Letting implementer self-review replace external review (both needed)
|
|
206
|
+
- Pausing to "check in" between tasks (continuous execution rule)
|
|
207
|
+
- Skipping the `Implementer Status` parse — treating every response as DONE
|
|
208
|
+
- Starting on main without explicit user consent
|
|
209
|
+
|
|
210
|
+
## Integration
|
|
211
|
+
|
|
212
|
+
**Required workflow skills:**
|
|
213
|
+
- `/skill:using-git-worktrees` — set up isolation first (small changes can branch in place with user approval)
|
|
214
|
+
- `/skill:writing-plans` — creates the plan this skill executes
|
|
215
|
+
- `/skill:requesting-code-review` — review template for reviewer subagents
|
|
216
|
+
- `/skill:finishing-a-development-branch` — invoked automatically once the conformance verdict is `CONFORMS` (or all gaps dispositioned)
|
|
217
|
+
|
|
218
|
+
**Subagents follow by default:**
|
|
219
|
+
- TDD — runtime warnings on source-before-test. Implementer agents receive the three-scenario TDD instructions (new feature / modifying tested code / trivial) via agent profile and prompt template.
|
|
220
|
+
|
|
221
|
+
## Project overrides
|
|
222
|
+
|
|
223
|
+
If `.pi/gauntlet-overrides.md` exists, read it. Any sections relevant to this skill — by name match, by topic (routing, verification, worktrees, etc.), or by workflow convention — override or extend the instructions above. Project-local `AGENTS.md` is already in context — check it for project-specific routing tables, service paths, and verification commands.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Code Quality Reviewer Prompt Template
|
|
2
|
+
|
|
3
|
+
Use this template when dispatching a code quality reviewer subagent.
|
|
4
|
+
|
|
5
|
+
**Purpose:** Verify implementation is well-built (clean, tested, maintainable)
|
|
6
|
+
|
|
7
|
+
**Only dispatch after spec compliance review passes.**
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Dispatch a subagent with the code-reviewer template:
|
|
11
|
+
Use the template at ../requesting-code-review/code-reviewer.md
|
|
12
|
+
|
|
13
|
+
DESCRIPTION: [task summary, from implementer's report]
|
|
14
|
+
PLAN_OR_REQUIREMENTS: Task N from [plan-file]
|
|
15
|
+
BASE_SHA: [commit before task]
|
|
16
|
+
HEAD_SHA: [current commit]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**In addition to standard code quality concerns, the reviewer should check:**
|
|
20
|
+
- Does each file have one clear responsibility with a well-defined interface?
|
|
21
|
+
- Are units decomposed so they can be understood and tested independently?
|
|
22
|
+
- Is the implementation following the file structure from the plan?
|
|
23
|
+
- Did this implementation create new files that are already large, or significantly grow existing files? (Don't flag pre-existing file sizes — focus on what this change contributed.)
|
|
24
|
+
|
|
25
|
+
**Code reviewer returns:** Strengths, Issues (Critical/Moderate/Minor), Assessment
|