specweave 1.0.416 → 1.0.418
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/dist/src/core/background/job-launcher.d.ts.map +1 -1
- package/dist/src/core/background/job-launcher.js +46 -4
- package/dist/src/core/background/job-launcher.js.map +1 -1
- package/package.json +1 -1
- package/plugins/specweave/hooks/v2/guards/increment-existence-guard.sh +80 -11
- package/plugins/specweave/skills/team-build/SKILL.md +120 -39
- package/plugins/specweave/skills/team-lead/SKILL.md +502 -177
- package/plugins/specweave/skills/team-lead/agents/brainstorm-advocate.md +65 -0
- package/plugins/specweave/skills/team-lead/agents/brainstorm-critic.md +75 -0
- package/plugins/specweave/skills/team-lead/agents/brainstorm-pragmatist.md +83 -0
- package/plugins/specweave/skills/team-lead/agents/reviewer-logic.md +63 -0
- package/plugins/specweave/skills/team-lead/agents/reviewer-performance.md +63 -0
- package/plugins/specweave/skills/team-lead/agents/reviewer-security.md +62 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Orchestrate multi-agent parallel
|
|
2
|
+
description: Orchestrate multi-agent parallel teams for implementation, PR reviews, brainstorming, and analysis. Supports 4 modes — implementation (spec-required, domain agents), review (parallel reviewers for PRs/code), brainstorm (multi-perspective ideation), and analysis (codebase research). PROACTIVELY invoke for 3+ domains or 15+ tasks. Also use when user says "team setup", "parallel agents", "team lead", "agent teams", "review this PR", "brainstorm", "analyze the codebase".
|
|
3
3
|
hooks:
|
|
4
4
|
PreToolUse:
|
|
5
5
|
- matcher: TeamCreate
|
|
@@ -10,32 +10,70 @@ hooks:
|
|
|
10
10
|
|
|
11
11
|
# Team Lead
|
|
12
12
|
|
|
13
|
-
**
|
|
13
|
+
**Orchestrate parallel agent teams for implementation, reviews, brainstorming, and analysis.**
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
/sw:team-lead "<
|
|
18
|
+
/sw:team-lead "<description>" [--mode implementation|review|brainstorm|analysis] [OPTIONS]
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Options
|
|
22
22
|
|
|
23
23
|
| Option | Description | Default |
|
|
24
24
|
|--------|-------------|---------|
|
|
25
|
+
| `--mode` | Team mode: `implementation`, `review`, `brainstorm`, `analysis` | auto-detect |
|
|
25
26
|
| `--dry-run` | Show proposed agent plan without launching | false |
|
|
26
|
-
| `--domains` | Override domain detection (
|
|
27
|
+
| `--domains` | Override domain detection (implementation mode) | auto-detect |
|
|
27
28
|
| `--max-agents` | Maximum number of concurrent agents | 6 |
|
|
28
29
|
|
|
29
30
|
---
|
|
30
31
|
|
|
31
|
-
## 0.
|
|
32
|
+
## 0. Mode Detection (FIRST STEP)
|
|
32
33
|
|
|
33
|
-
**
|
|
34
|
-
|
|
34
|
+
**Before anything else, determine which mode this team operates in.** The mode dictates the entire workflow — different modes have fundamentally different agent structures, naming conventions, and requirements.
|
|
35
|
+
|
|
36
|
+
### Auto-Detection Rules
|
|
37
|
+
|
|
38
|
+
| Signal | Mode | Examples |
|
|
39
|
+
|--------|------|---------|
|
|
40
|
+
| Explicit `--mode` flag | As specified | `--mode review` |
|
|
41
|
+
| PR/review keywords | **review** | "review PR #63", "code review", "audit the auth module", "review this pull request" |
|
|
42
|
+
| Brainstorm keywords | **brainstorm** | "brainstorm approaches", "explore ideas", "pros and cons", "ideate on", "what are our options" |
|
|
43
|
+
| Analysis keywords | **analysis** | "analyze the codebase", "research how X works", "explore the architecture", "investigate performance" |
|
|
44
|
+
| Implementation signals | **implementation** | "build X", "implement Y", "add feature Z", 3+ domains detected, 15+ tasks in tasks.md |
|
|
45
|
+
|
|
46
|
+
### Keyword Priority
|
|
47
|
+
|
|
48
|
+
If multiple signals conflict, explicit `--mode` flag wins. Otherwise: review > brainstorm > analysis > implementation.
|
|
49
|
+
|
|
50
|
+
### Team Naming Convention (CRITICAL for Guard)
|
|
51
|
+
|
|
52
|
+
The PreToolUse guard uses team_name prefix to determine mode. **You MUST use these prefixes:**
|
|
53
|
+
|
|
54
|
+
| Mode | team_name pattern | Example |
|
|
55
|
+
|------|------------------|---------|
|
|
56
|
+
| Implementation | `impl-*` or any non-prefixed name | `impl-checkout`, `feature-auth` |
|
|
57
|
+
| Review | `review-*` | `review-pr-63`, `review-auth-module` |
|
|
58
|
+
| Brainstorm | `brainstorm-*` | `brainstorm-architecture`, `brainstorm-pricing` |
|
|
59
|
+
| Analysis | `analysis-*` | `analysis-performance`, `analysis-codebase` |
|
|
60
|
+
|
|
61
|
+
**WHY**: The guard only enforces spec-first for implementation teams. Using the correct prefix lets review/brainstorm/analysis teams proceed without an increment.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Mode 1: Implementation (Spec-Required)
|
|
66
|
+
|
|
67
|
+
**When to use**: Building features, fixing bugs, any work that produces code changes requiring spec-driven coordination.
|
|
68
|
+
|
|
69
|
+
**Requires**: An existing increment with substantive spec.md (enforced by guard).
|
|
35
70
|
|
|
36
|
-
|
|
71
|
+
### 0a. Increment Pre-Flight (BLOCKING)
|
|
37
72
|
|
|
38
|
-
|
|
73
|
+
**CRITICAL: Implementation mode REQUIRES an existing increment with a substantive spec.md.**
|
|
74
|
+
A PreToolUse guard on TeamCreate will BLOCK team creation if no increment exists.
|
|
75
|
+
|
|
76
|
+
**You MUST verify an increment exists BEFORE proceeding.**
|
|
39
77
|
|
|
40
78
|
```bash
|
|
41
79
|
# Single-repo
|
|
@@ -45,7 +83,7 @@ find .specweave/increments -maxdepth 2 -name "spec.md" 2>/dev/null | head -5
|
|
|
45
83
|
find repositories -path "*/.specweave/increments/*/spec.md" -maxdepth 6 2>/dev/null | head -5
|
|
46
84
|
```
|
|
47
85
|
|
|
48
|
-
|
|
86
|
+
#### If NO increment exists → Auto-invoke /sw:increment
|
|
49
87
|
|
|
50
88
|
Do NOT ask permission. Invoke the increment skill with the user's feature description:
|
|
51
89
|
|
|
@@ -54,42 +92,280 @@ Skill({ skill: "sw:increment", args: "the user's feature description" })
|
|
|
54
92
|
```
|
|
55
93
|
|
|
56
94
|
Wait for /sw:increment to complete (spec.md, plan.md, tasks.md created and approved).
|
|
57
|
-
Then continue
|
|
95
|
+
Then continue. If /sw:increment fails: **STOP. Do NOT proceed.**
|
|
58
96
|
|
|
59
|
-
If
|
|
60
|
-
Report the failure to the user and ask them to run `/sw:increment` manually.
|
|
61
|
-
|
|
62
|
-
### If increment exists → Read the master spec
|
|
97
|
+
#### If increment exists → Read the master spec
|
|
63
98
|
|
|
64
99
|
Read the increment's spec.md. This is the **source of truth** for all agent work:
|
|
65
100
|
- Scope and boundaries
|
|
66
101
|
- User stories and acceptance criteria
|
|
67
102
|
- Task breakdown and dependencies
|
|
68
103
|
|
|
69
|
-
Store the increment path as `MASTER_INCREMENT_PATH
|
|
70
|
-
|
|
71
|
-
**WHY THIS MATTERS**: Without a spec, agents infer scope from natural language alone.
|
|
72
|
-
This leads to uncoordinated implementation, scope creep, and missing acceptance criteria.
|
|
73
|
-
The spec-first principle exists because specs are the contract between user intent and agent execution.
|
|
104
|
+
Store the increment path as `MASTER_INCREMENT_PATH`.
|
|
74
105
|
|
|
75
|
-
|
|
106
|
+
#### Activate the Master Increment (MANDATORY)
|
|
76
107
|
|
|
77
|
-
**Before spawning ANY agents**, transition the master increment to `"active"` status.
|
|
108
|
+
**Before spawning ANY agents**, transition the master increment to `"active"` status.
|
|
78
109
|
|
|
79
110
|
```bash
|
|
80
|
-
# Read current status
|
|
81
111
|
STATUS=$(jq -r '.status' [MASTER_INCREMENT_PATH]/metadata.json)
|
|
82
|
-
|
|
83
|
-
# If not already active, activate it
|
|
84
112
|
if [ "$STATUS" != "active" ] && [ "$STATUS" != "ready_for_review" ]; then
|
|
85
|
-
|
|
86
|
-
Edit metadata.json:
|
|
87
|
-
"status": "planned" → "status": "active"
|
|
88
|
-
"lastActivity": "<current ISO timestamp>"
|
|
113
|
+
Edit metadata.json: "status": "planned" → "status": "active"
|
|
89
114
|
fi
|
|
90
115
|
```
|
|
91
116
|
|
|
92
|
-
|
|
117
|
+
### Implementation Workflow
|
|
118
|
+
|
|
119
|
+
Follow Sections 1-11 below (the full implementation protocol).
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Mode 2: Review (No Increment Required)
|
|
124
|
+
|
|
125
|
+
**When to use**: PR reviews, code audits, architecture reviews, security audits, pre-release quality checks.
|
|
126
|
+
|
|
127
|
+
**Does NOT require**: An increment or spec.md. Reviews examine existing code.
|
|
128
|
+
|
|
129
|
+
### Review Workflow
|
|
130
|
+
|
|
131
|
+
#### Step 1: Determine Review Scope
|
|
132
|
+
|
|
133
|
+
Identify what's being reviewed:
|
|
134
|
+
- **PR review**: Extract PR number, fetch diff with `gh pr diff <number>`
|
|
135
|
+
- **Code audit**: Identify target files/modules
|
|
136
|
+
- **Architecture review**: Identify system boundaries and components
|
|
137
|
+
|
|
138
|
+
#### Step 2: Create Review Team
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
TeamCreate({
|
|
142
|
+
team_name: "review-pr-63", // MUST use review-* prefix
|
|
143
|
+
description: "Review PR #63 for security, logic, and performance"
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Step 3: Spawn Review Agents (All Parallel)
|
|
148
|
+
|
|
149
|
+
Review agents run in parallel — they examine code independently from different perspectives. **Read the agent definition files** from `agents/` directory, replace placeholders, and spawn.
|
|
150
|
+
|
|
151
|
+
| Agent | File | Focus |
|
|
152
|
+
|-------|------|-------|
|
|
153
|
+
| Security Reviewer | `agents/reviewer-security.md` | Vulnerabilities, injection, auth flaws, secrets exposure, OWASP |
|
|
154
|
+
| Logic Reviewer | `agents/reviewer-logic.md` | Correctness, edge cases, error handling, race conditions, logic bugs |
|
|
155
|
+
| Performance Reviewer | `agents/reviewer-performance.md` | N+1 queries, memory leaks, unnecessary allocations, algorithmic complexity |
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
// Spawn ALL reviewers in parallel — no dependencies between them
|
|
159
|
+
Task({
|
|
160
|
+
team_name: "review-pr-63",
|
|
161
|
+
name: "security-reviewer",
|
|
162
|
+
subagent_type: "general-purpose",
|
|
163
|
+
mode: "bypassPermissions",
|
|
164
|
+
prompt: <content of agents/reviewer-security.md with placeholders replaced>
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
Task({
|
|
168
|
+
team_name: "review-pr-63",
|
|
169
|
+
name: "logic-reviewer",
|
|
170
|
+
subagent_type: "general-purpose",
|
|
171
|
+
mode: "bypassPermissions",
|
|
172
|
+
prompt: <content of agents/reviewer-logic.md with placeholders replaced>
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
Task({
|
|
176
|
+
team_name: "review-pr-63",
|
|
177
|
+
name: "performance-reviewer",
|
|
178
|
+
subagent_type: "general-purpose",
|
|
179
|
+
mode: "bypassPermissions",
|
|
180
|
+
prompt: <content of agents/reviewer-performance.md with placeholders replaced>
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Step 4: Collect and Merge Reviews
|
|
185
|
+
|
|
186
|
+
Wait for all agents to signal REVIEW_COMPLETE. Each agent produces a structured findings report. The team-lead:
|
|
187
|
+
|
|
188
|
+
1. Collects all REVIEW_COMPLETE messages
|
|
189
|
+
2. Deduplicates overlapping findings
|
|
190
|
+
3. Prioritizes by severity (CRITICAL > HIGH > MEDIUM > LOW)
|
|
191
|
+
4. Produces a unified review summary with:
|
|
192
|
+
- **Must Fix** (blocking): Security vulnerabilities, logic bugs, data loss risks
|
|
193
|
+
- **Should Fix** (non-blocking): Performance issues, code quality, missing error handling
|
|
194
|
+
- **Consider** (optional): Style improvements, documentation gaps, refactoring opportunities
|
|
195
|
+
|
|
196
|
+
#### Step 5: Deliver Review
|
|
197
|
+
|
|
198
|
+
Present the merged review to the user. If reviewing a PR, optionally post the review as a PR comment via `gh pr review`.
|
|
199
|
+
|
|
200
|
+
### Review Agent Communication Protocol
|
|
201
|
+
|
|
202
|
+
| Prefix | Purpose | Sender | Receiver |
|
|
203
|
+
|--------|---------|--------|----------|
|
|
204
|
+
| `REVIEW_COMPLETE:` | Agent finished reviewing | Review agent | team-lead |
|
|
205
|
+
| `REVIEW_QUESTION:` | Agent needs clarification | Review agent | team-lead |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Mode 3: Brainstorm (No Increment Required)
|
|
210
|
+
|
|
211
|
+
**When to use**: Exploring ideas, evaluating approaches, multi-perspective ideation, architecture decision exploration, trade-off analysis.
|
|
212
|
+
|
|
213
|
+
**Does NOT require**: An increment or spec.md. Brainstorming is pre-spec exploration.
|
|
214
|
+
|
|
215
|
+
### Brainstorm Workflow
|
|
216
|
+
|
|
217
|
+
#### Step 1: Frame the Question
|
|
218
|
+
|
|
219
|
+
Extract the core question or decision to brainstorm:
|
|
220
|
+
- "How should we architect the payment system?"
|
|
221
|
+
- "What approach for real-time notifications?"
|
|
222
|
+
- "Should we use microservices or monolith?"
|
|
223
|
+
|
|
224
|
+
#### Step 2: Create Brainstorm Team
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
TeamCreate({
|
|
228
|
+
team_name: "brainstorm-payment-arch", // MUST use brainstorm-* prefix
|
|
229
|
+
description: "Brainstorm payment system architecture approaches"
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Step 3: Spawn Perspective Agents (All Parallel)
|
|
234
|
+
|
|
235
|
+
Brainstorm agents represent different thinking perspectives. **Read the agent definition files** from `agents/` directory, replace placeholders, and spawn.
|
|
236
|
+
|
|
237
|
+
| Agent | File | Perspective |
|
|
238
|
+
|-------|------|------------|
|
|
239
|
+
| Advocate | `agents/brainstorm-advocate.md` | Champions the most ambitious/innovative approach. Pushes boundaries. |
|
|
240
|
+
| Critic | `agents/brainstorm-critic.md` | Devil's advocate. Finds risks, edge cases, failure modes. Questions assumptions. |
|
|
241
|
+
| Pragmatist | `agents/brainstorm-pragmatist.md` | Practical realist. Considers timelines, team skills, maintenance burden. |
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// Spawn ALL perspective agents in parallel
|
|
245
|
+
Task({
|
|
246
|
+
team_name: "brainstorm-payment-arch",
|
|
247
|
+
name: "advocate",
|
|
248
|
+
subagent_type: "general-purpose",
|
|
249
|
+
mode: "bypassPermissions",
|
|
250
|
+
prompt: <content of agents/brainstorm-advocate.md with placeholders replaced>
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
Task({
|
|
254
|
+
team_name: "brainstorm-payment-arch",
|
|
255
|
+
name: "critic",
|
|
256
|
+
subagent_type: "general-purpose",
|
|
257
|
+
mode: "bypassPermissions",
|
|
258
|
+
prompt: <content of agents/brainstorm-critic.md with placeholders replaced>
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
Task({
|
|
262
|
+
team_name: "brainstorm-payment-arch",
|
|
263
|
+
name: "pragmatist",
|
|
264
|
+
subagent_type: "general-purpose",
|
|
265
|
+
mode: "bypassPermissions",
|
|
266
|
+
prompt: <content of agents/brainstorm-pragmatist.md with placeholders replaced>
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
#### Step 4: Synthesize Perspectives
|
|
271
|
+
|
|
272
|
+
Wait for all agents to signal PERSPECTIVE_COMPLETE. The team-lead:
|
|
273
|
+
|
|
274
|
+
1. Collects all perspectives
|
|
275
|
+
2. Identifies areas of agreement (strong signals)
|
|
276
|
+
3. Maps areas of disagreement (decision points)
|
|
277
|
+
4. Produces a **Decision Matrix**:
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
| Approach | Advocate View | Critic Concerns | Pragmatist Assessment | Score |
|
|
281
|
+
|----------|--------------|-----------------|----------------------|-------|
|
|
282
|
+
| Option A | Pro: X, Y | Risk: Z | Feasible, 2 weeks | 7/10 |
|
|
283
|
+
| Option B | Pro: A, B | Risk: C, D | Complex, 4 weeks | 5/10 |
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
5. Recommends a path forward with clear rationale
|
|
287
|
+
6. If the user wants to proceed → suggest `/sw:increment` to formalize the chosen approach
|
|
288
|
+
|
|
289
|
+
### Brainstorm Agent Communication Protocol
|
|
290
|
+
|
|
291
|
+
| Prefix | Purpose | Sender | Receiver |
|
|
292
|
+
|--------|---------|--------|----------|
|
|
293
|
+
| `PERSPECTIVE_COMPLETE:` | Agent finished their analysis | Perspective agent | team-lead |
|
|
294
|
+
| `INSIGHT:` | Important finding during analysis | Perspective agent | team-lead |
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Mode 4: Analysis (No Increment Required)
|
|
299
|
+
|
|
300
|
+
**When to use**: Codebase research, dependency analysis, architecture mapping, performance profiling, tech debt assessment, migration feasibility studies.
|
|
301
|
+
|
|
302
|
+
**Does NOT require**: An increment or spec.md. Analysis is exploratory.
|
|
303
|
+
|
|
304
|
+
### Analysis Workflow
|
|
305
|
+
|
|
306
|
+
#### Step 1: Define Analysis Scope
|
|
307
|
+
|
|
308
|
+
Identify what needs to be analyzed and what questions need answers:
|
|
309
|
+
- "How are API endpoints structured?"
|
|
310
|
+
- "What's the dependency graph for the auth module?"
|
|
311
|
+
- "Where are the performance bottlenecks?"
|
|
312
|
+
|
|
313
|
+
#### Step 2: Create Analysis Team
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
TeamCreate({
|
|
317
|
+
team_name: "analysis-auth-deps", // MUST use analysis-* prefix
|
|
318
|
+
description: "Analyze authentication module dependencies and architecture"
|
|
319
|
+
});
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### Step 3: Spawn Analysis Agents
|
|
323
|
+
|
|
324
|
+
Unlike fixed-role review/brainstorm agents, analysis agents are **dynamically composed** based on the analysis scope. Common patterns:
|
|
325
|
+
|
|
326
|
+
| Pattern | Agents | Use Case |
|
|
327
|
+
|---------|--------|----------|
|
|
328
|
+
| **Architecture mapping** | structure-agent, dependency-agent, pattern-agent | Understanding system design |
|
|
329
|
+
| **Performance analysis** | profiler-agent, bottleneck-agent, optimization-agent | Finding performance issues |
|
|
330
|
+
| **Tech debt assessment** | complexity-agent, coverage-agent, freshness-agent | Evaluating maintenance burden |
|
|
331
|
+
| **Migration feasibility** | source-agent, target-agent, risk-agent | Planning technology migrations |
|
|
332
|
+
|
|
333
|
+
Agents are spawned with focused prompts tailored to the specific analysis question. There are no fixed agent templates — the team-lead crafts prompts from the analysis scope.
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
// Example: Architecture mapping
|
|
337
|
+
Task({
|
|
338
|
+
team_name: "analysis-auth-deps",
|
|
339
|
+
name: "structure-agent",
|
|
340
|
+
subagent_type: "general-purpose",
|
|
341
|
+
mode: "bypassPermissions",
|
|
342
|
+
prompt: "Analyze the directory structure and module organization of the auth system. Map all files in src/auth/, src/middleware/auth*, and related test files. Report: file count, module boundaries, export/import graph, and any circular dependencies. Signal completion with ANALYSIS_COMPLETE: prefix."
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
Task({
|
|
346
|
+
team_name: "analysis-auth-deps",
|
|
347
|
+
name: "dependency-agent",
|
|
348
|
+
subagent_type: "general-purpose",
|
|
349
|
+
mode: "bypassPermissions",
|
|
350
|
+
prompt: "Analyze external dependencies used by the auth module. Check package.json for auth-related packages, trace their usage, check for CVEs, and assess upgrade paths. Signal completion with ANALYSIS_COMPLETE: prefix."
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
#### Step 4: Synthesize Findings
|
|
355
|
+
|
|
356
|
+
Wait for all ANALYSIS_COMPLETE signals. Produce a structured analysis report:
|
|
357
|
+
|
|
358
|
+
1. **Findings Summary**: Key discoveries from each agent
|
|
359
|
+
2. **Diagrams**: ASCII architecture diagrams, dependency graphs
|
|
360
|
+
3. **Recommendations**: Prioritized list of actions
|
|
361
|
+
4. **Next Steps**: Suggest `/sw:increment` if actionable improvements are identified
|
|
362
|
+
|
|
363
|
+
### Analysis Agent Communication Protocol
|
|
364
|
+
|
|
365
|
+
| Prefix | Purpose | Sender | Receiver |
|
|
366
|
+
|--------|---------|--------|----------|
|
|
367
|
+
| `ANALYSIS_COMPLETE:` | Agent finished analysis | Analysis agent | team-lead |
|
|
368
|
+
| `FINDING:` | Significant discovery during analysis | Analysis agent | team-lead |
|
|
93
369
|
|
|
94
370
|
---
|
|
95
371
|
|
|
@@ -104,7 +380,7 @@ fi
|
|
|
104
380
|
|
|
105
381
|
---
|
|
106
382
|
|
|
107
|
-
## 2. Domain-to-Skill Mapping
|
|
383
|
+
## 2. Domain-to-Skill Mapping (Implementation Mode)
|
|
108
384
|
|
|
109
385
|
Analyze the feature request and map affected domains to SpecWeave skills.
|
|
110
386
|
|
|
@@ -126,7 +402,7 @@ The orchestrator infers domains from the feature description and codebase struct
|
|
|
126
402
|
|
|
127
403
|
---
|
|
128
404
|
|
|
129
|
-
## 3. Contract-First Spawning Protocol
|
|
405
|
+
## 3. Contract-First Spawning Protocol (Implementation Mode)
|
|
130
406
|
|
|
131
407
|
Agents are NOT all spawned simultaneously. The orchestrator follows a two-phase dependency protocol to prevent integration conflicts.
|
|
132
408
|
|
|
@@ -192,10 +468,6 @@ umbrella-project/
|
|
|
192
468
|
│ │ └── .specweave/increments/0001-shared-types/
|
|
193
469
|
│ └── {ORG}/sw-ecom-api/
|
|
194
470
|
│ └── .specweave/increments/0001-api-endpoints/
|
|
195
|
-
|
|
196
|
-
# WRONG: All agents dumping into umbrella root
|
|
197
|
-
umbrella-project/
|
|
198
|
-
├── .specweave/increments/0001-everything/ # WRONG!
|
|
199
471
|
```
|
|
200
472
|
|
|
201
473
|
**Rules:**
|
|
@@ -262,7 +534,7 @@ Analyze domains
|
|
|
262
534
|
|
|
263
535
|
---
|
|
264
536
|
|
|
265
|
-
## 3b. Plan Review Workflow
|
|
537
|
+
## 3b. Plan Review Workflow (Implementation Mode)
|
|
266
538
|
|
|
267
539
|
The team lead acts as **architectural reviewer** for all sub-agent plans. Do NOT auto-accept plans.
|
|
268
540
|
|
|
@@ -276,7 +548,7 @@ Without review, agents may duplicate work across domains, misinterpret scope, ma
|
|
|
276
548
|
- Agents run as separate processes that encounter folder trust prompts
|
|
277
549
|
- Trust prompts require interactive input that agents CANNOT provide
|
|
278
550
|
- Without `bypassPermissions`, agents get STUCK waiting for trust confirmation and never execute
|
|
279
|
-
- This applies to ALL agent spawns — upstream and downstream
|
|
551
|
+
- This applies to ALL agent spawns — upstream and downstream, ALL MODES
|
|
280
552
|
|
|
281
553
|
**NEVER use `mode: "plan"` for agent spawns** — it causes agents to block on the trust-folder prompt.
|
|
282
554
|
|
|
@@ -331,10 +603,6 @@ SendMessage({
|
|
|
331
603
|
|
|
332
604
|
Plan review MUST NOT block other agents. Review plans as they arrive — agents waiting for approval are idle, but other agents continue working normally.
|
|
333
605
|
|
|
334
|
-
### Multi-Increment Consideration
|
|
335
|
-
|
|
336
|
-
For very large features, the team lead MAY split work into multiple increments per domain for better tracking and independent closure. Decide this during initial analysis (Step 1), before spawning agents.
|
|
337
|
-
|
|
338
606
|
### Task Cap Per Agent (CRITICAL — Context Overflow Prevention)
|
|
339
607
|
|
|
340
608
|
**Maximum 15 tasks per agent.** Agents with more tasks accumulate too much context in auto-mode, leading to extended thinking loops and stuck agents.
|
|
@@ -344,22 +612,15 @@ When distributing tasks from the master spec:
|
|
|
344
612
|
2. If a domain has >15 tasks: **split into 2 agents** (e.g., `jira-agent-a`, `jira-agent-b`) with non-overlapping task ranges
|
|
345
613
|
3. If splitting isn't natural, group tasks into phases and create 2 increments per domain
|
|
346
614
|
|
|
347
|
-
```
|
|
348
|
-
Domain tasks analysis:
|
|
349
|
-
Frontend: 12 tasks -> 1 agent (OK)
|
|
350
|
-
Backend: 8 tasks -> 1 agent (OK)
|
|
351
|
-
JIRA: 23 tasks -> SPLIT into 2 agents (tasks 1-12, tasks 13-23)
|
|
352
|
-
```
|
|
353
|
-
|
|
354
615
|
**Why**: Each auto-mode iteration adds context (spec reads, edits, test outputs). At 20+ tasks, accumulated context causes the model to enter extended thinking (30+ min) and effectively hang. The 15-task cap keeps agents within a safe context budget.
|
|
355
616
|
|
|
356
617
|
---
|
|
357
618
|
|
|
358
619
|
## 4. Agent Spawn Prompt Templates
|
|
359
620
|
|
|
360
|
-
Agent definitions live as reusable `.md` files in the `agents/` subdirectory. When spawning
|
|
621
|
+
Agent definitions live as reusable `.md` files in the `agents/` subdirectory. When spawning an agent, **Read the agent file and use its full content as the Task() prompt**, with placeholders replaced.
|
|
361
622
|
|
|
362
|
-
### Agent Reference
|
|
623
|
+
### Implementation Agent Reference
|
|
363
624
|
|
|
364
625
|
| Agent | File | Domain | Phase | Primary Skills |
|
|
365
626
|
|-------|------|--------|-------|---------------|
|
|
@@ -369,32 +630,41 @@ Agent definitions live as reusable `.md` files in the `agents/` subdirectory. Wh
|
|
|
369
630
|
| Testing | `agents/testing.md` | Unit, integration, E2E | 2 (downstream) | `testing:qa`, `testing:e2e` |
|
|
370
631
|
| Security | `agents/security.md` | Auth, validation, audit | 2 (downstream) | `sw:security` |
|
|
371
632
|
|
|
633
|
+
### Review Agent Reference
|
|
634
|
+
|
|
635
|
+
| Agent | File | Focus |
|
|
636
|
+
|-------|------|-------|
|
|
637
|
+
| Security Reviewer | `agents/reviewer-security.md` | Vulnerabilities, injection, auth, secrets, OWASP |
|
|
638
|
+
| Logic Reviewer | `agents/reviewer-logic.md` | Correctness, edge cases, error handling, race conditions |
|
|
639
|
+
| Performance Reviewer | `agents/reviewer-performance.md` | N+1 queries, memory leaks, algorithmic complexity |
|
|
640
|
+
|
|
641
|
+
### Brainstorm Agent Reference
|
|
642
|
+
|
|
643
|
+
| Agent | File | Perspective |
|
|
644
|
+
|-------|------|------------|
|
|
645
|
+
| Advocate | `agents/brainstorm-advocate.md` | Champions innovative/ambitious approaches |
|
|
646
|
+
| Critic | `agents/brainstorm-critic.md` | Devil's advocate — finds risks and failure modes |
|
|
647
|
+
| Pragmatist | `agents/brainstorm-pragmatist.md` | Practical realist — timelines, skills, maintenance |
|
|
648
|
+
|
|
372
649
|
### How to Use Agent Files
|
|
373
650
|
|
|
374
|
-
For each
|
|
651
|
+
For each agent to spawn:
|
|
375
652
|
|
|
376
|
-
1. **Read** the agent definition: `Read("agents/{
|
|
653
|
+
1. **Read** the agent definition: `Read("agents/{name}.md")`
|
|
377
654
|
2. **Replace placeholders** in the content:
|
|
378
|
-
- `[
|
|
379
|
-
- `[
|
|
655
|
+
- `[REVIEW_TARGET]` → PR number, file paths, or module name being reviewed
|
|
656
|
+
- `[BRAINSTORM_QUESTION]` → the core question being explored
|
|
657
|
+
- `[INCREMENT_ID]` → the increment ID (implementation mode)
|
|
658
|
+
- `[MASTER_INCREMENT_PATH]` → full path to the master increment directory (implementation mode)
|
|
380
659
|
- `{ORG}` → the discovered organization name
|
|
381
660
|
- `{repo-name}` → the assigned repository name
|
|
382
|
-
3. **Spawn** via Task() with the replaced content as the prompt
|
|
383
|
-
```
|
|
384
|
-
Task({
|
|
385
|
-
team_name: "<team-name>",
|
|
386
|
-
name: "<domain>-agent",
|
|
387
|
-
subagent_type: "general-purpose",
|
|
388
|
-
mode: "bypassPermissions",
|
|
389
|
-
prompt: <replaced agent content>
|
|
390
|
-
})
|
|
391
|
-
```
|
|
661
|
+
3. **Spawn** via Task() with the replaced content as the prompt
|
|
392
662
|
|
|
393
663
|
**CRITICAL**: Always use `mode: "bypassPermissions"` — agents cannot handle interactive trust-folder prompts.
|
|
394
664
|
|
|
395
665
|
---
|
|
396
666
|
|
|
397
|
-
## 5. File Ownership
|
|
667
|
+
## 5. File Ownership (Implementation Mode)
|
|
398
668
|
|
|
399
669
|
Each agent has exclusive WRITE access to specific file patterns. This prevents merge conflicts.
|
|
400
670
|
|
|
@@ -421,51 +691,49 @@ Each agent has exclusive WRITE access to specific file patterns. This prevents m
|
|
|
421
691
|
5. **Conflict detection** -- the orchestrator checks for ownership overlap before spawning and resolves ambiguity upfront
|
|
422
692
|
6. **Repository directory structure** -- for multi-repo setups, ALL repository cloning and creation MUST use the `repositories/{ORG}/` directory convention
|
|
423
693
|
|
|
694
|
+
**Note**: Review, brainstorm, and analysis mode agents have READ-ONLY access to all files. They do not write code (unless explicitly asked to produce fixes in review mode).
|
|
695
|
+
|
|
424
696
|
---
|
|
425
697
|
|
|
426
698
|
## 6. Communication Protocol
|
|
427
699
|
|
|
428
|
-
Agents communicate
|
|
700
|
+
Agents communicate using `SendMessage`. The message prefix convention varies by mode.
|
|
429
701
|
|
|
430
|
-
###
|
|
702
|
+
### Implementation Mode Messages
|
|
431
703
|
|
|
432
704
|
| Prefix | Purpose | Sender | Receiver |
|
|
433
705
|
|--------|---------|--------|----------|
|
|
434
|
-
| `CONTRACT_READY:` | Upstream contract is published | Upstream agent | team-lead
|
|
706
|
+
| `CONTRACT_READY:` | Upstream contract is published | Upstream agent | team-lead |
|
|
435
707
|
| `BLOCKING_ISSUE:` | Agent is stuck, needs help | Any agent | team-lead |
|
|
436
708
|
| `COMPLETION:` | Agent finished all tasks | Any agent | team-lead |
|
|
709
|
+
| `PLAN_READY:` | Agent's plan is ready for review | Any agent | team-lead |
|
|
710
|
+
| `PLAN_APPROVED:` | Plan approved, proceed | team-lead | Agent |
|
|
711
|
+
| `PLAN_REJECTED:` | Plan needs revision | team-lead | Agent |
|
|
437
712
|
|
|
438
|
-
###
|
|
713
|
+
### Review Mode Messages
|
|
439
714
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
recipient: "team-lead",
|
|
445
|
-
content: "CONTRACT_READY: TypeScript interfaces written to src/types/checkout.ts. Exports: CheckoutItem, CartSummary, PaymentIntent.",
|
|
446
|
-
summary: "Shared types contract ready"
|
|
447
|
-
});
|
|
715
|
+
| Prefix | Purpose | Sender | Receiver |
|
|
716
|
+
|--------|---------|--------|----------|
|
|
717
|
+
| `REVIEW_COMPLETE:` | Review findings ready | Review agent | team-lead |
|
|
718
|
+
| `REVIEW_QUESTION:` | Needs clarification about code | Review agent | team-lead |
|
|
448
719
|
|
|
449
|
-
|
|
450
|
-
SendMessage({
|
|
451
|
-
type: "message",
|
|
452
|
-
recipient: "team-lead",
|
|
453
|
-
content: "BLOCKING_ISSUE: Cannot implement payment webhook -- Stripe webhook secret not found in .env. Need STRIPE_WEBHOOK_SECRET to proceed.",
|
|
454
|
-
summary: "Blocked on missing Stripe secret"
|
|
455
|
-
});
|
|
720
|
+
### Brainstorm Mode Messages
|
|
456
721
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
722
|
+
| Prefix | Purpose | Sender | Receiver |
|
|
723
|
+
|--------|---------|--------|----------|
|
|
724
|
+
| `PERSPECTIVE_COMPLETE:` | Perspective analysis done | Brainstorm agent | team-lead |
|
|
725
|
+
| `INSIGHT:` | Important finding during analysis | Brainstorm agent | team-lead |
|
|
726
|
+
|
|
727
|
+
### Analysis Mode Messages
|
|
728
|
+
|
|
729
|
+
| Prefix | Purpose | Sender | Receiver |
|
|
730
|
+
|--------|---------|--------|----------|
|
|
731
|
+
| `ANALYSIS_COMPLETE:` | Analysis findings ready | Analysis agent | team-lead |
|
|
732
|
+
| `FINDING:` | Significant discovery | Analysis agent | team-lead |
|
|
465
733
|
|
|
466
734
|
---
|
|
467
735
|
|
|
468
|
-
## 7. Spawning Agents
|
|
736
|
+
## 7. Spawning Agents (Implementation Mode)
|
|
469
737
|
|
|
470
738
|
### Step 1: Create the Team
|
|
471
739
|
|
|
@@ -480,10 +748,9 @@ TeamCreate({
|
|
|
480
748
|
|
|
481
749
|
All agents are spawned with `mode: "bypassPermissions"` to prevent blocking on trust-folder prompts. Plan review is enforced via the SendMessage PLAN_READY/PLAN_APPROVED protocol (see Section 3b).
|
|
482
750
|
|
|
483
|
-
For each agent: **Read the agent definition file** (see Section 4 reference table), replace placeholders
|
|
751
|
+
For each agent: **Read the agent definition file** (see Section 4 reference table), replace placeholders, and use the full content as the Task() prompt.
|
|
484
752
|
|
|
485
753
|
```typescript
|
|
486
|
-
// Read agents/database.md, replace placeholders, then:
|
|
487
754
|
Task({
|
|
488
755
|
team_name: "feature-checkout",
|
|
489
756
|
name: "database-agent",
|
|
@@ -500,8 +767,6 @@ Messages are delivered automatically via SendMessage from upstream agents.
|
|
|
500
767
|
### Step 4: Spawn Downstream Agents (Phase 2)
|
|
501
768
|
|
|
502
769
|
```typescript
|
|
503
|
-
// Read agents/backend.md, agents/frontend.md, agents/testing.md
|
|
504
|
-
// Replace placeholders, then spawn each:
|
|
505
770
|
Task({
|
|
506
771
|
team_name: "feature-checkout",
|
|
507
772
|
name: "backend-agent",
|
|
@@ -529,7 +794,7 @@ Task({
|
|
|
529
794
|
|
|
530
795
|
---
|
|
531
796
|
|
|
532
|
-
## 8. Quality Gates
|
|
797
|
+
## 8. Quality Gates (Implementation Mode)
|
|
533
798
|
|
|
534
799
|
Quality gates are split: agents handle tests, team-lead handles closure (grill, done, judge-llm). This prevents context overflow in agents from loading 4+ additional skill definitions during closure.
|
|
535
800
|
|
|
@@ -546,8 +811,6 @@ Agent Workflow:
|
|
|
546
811
|
7. Do NOT run /sw:grill or /sw:done — team-lead handles closure centrally
|
|
547
812
|
```
|
|
548
813
|
|
|
549
|
-
**Why agents don't run /sw:done**: The /sw:done skill invokes 4 sub-skills (grill, judge-llm, sync-docs, qa), each loading a full SKILL.md. After 15+ tasks of auto-mode context, this pushes agents into extended thinking (30+ min hangs). Centralizing closure on the team-lead (which has a cleaner context) avoids this.
|
|
550
|
-
|
|
551
814
|
### Orchestrator Quality Gate (Centralized Closure)
|
|
552
815
|
|
|
553
816
|
After all agents complete, the team-lead runs closure **centrally** for each increment.
|
|
@@ -562,7 +825,7 @@ Orchestrator Final Check:
|
|
|
562
825
|
4. For EACH increment in dependency order (shared → database → backend → frontend → testing → security):
|
|
563
826
|
a. PRE-CLOSURE STATUS CHECK:
|
|
564
827
|
- Read metadata.json status
|
|
565
|
-
- If status is "planned" or "backlog" → Edit to "active"
|
|
828
|
+
- If status is "planned" or "backlog" → Edit to "active"
|
|
566
829
|
- If status is "completed" → Skip (already closed)
|
|
567
830
|
b. Run /sw:grill on the increment
|
|
568
831
|
c. If grill finds CRITICAL/BLOCKER issues:
|
|
@@ -570,7 +833,7 @@ Orchestrator Final Check:
|
|
|
570
833
|
→ Re-run /sw:grill (max 2 retries)
|
|
571
834
|
→ If still failing after 2 retries → log failure, move to next increment
|
|
572
835
|
d. Run /sw:done --auto <id>
|
|
573
|
-
e. If /sw:done fails
|
|
836
|
+
e. If /sw:done fails:
|
|
574
837
|
→ Read the error output carefully
|
|
575
838
|
→ Fix the root cause (sync ACs, update task counts, write missing reports)
|
|
576
839
|
→ Re-run /sw:done --auto <id> (max 2 retries)
|
|
@@ -578,7 +841,6 @@ Orchestrator Final Check:
|
|
|
578
841
|
5. After all increments attempted:
|
|
579
842
|
- If ALL closed → /sw:team-merge
|
|
580
843
|
- If SOME failed → report which increments are still open with failure reasons
|
|
581
|
-
- Do NOT leave increments in limbo — either close them or clearly report why they can't close
|
|
582
844
|
```
|
|
583
845
|
|
|
584
846
|
**Common closure failures and fixes:**
|
|
@@ -592,17 +854,6 @@ Orchestrator Final Check:
|
|
|
592
854
|
| Task count mismatch | tasks.md frontmatter != actual checked tasks | Update `completed_tasks` in tasks.md frontmatter |
|
|
593
855
|
| ACs not all checked | Some ACs still `[ ]` in spec.md | Verify implementation, then check them `[x]` |
|
|
594
856
|
|
|
595
|
-
### Grill Checklist per Domain
|
|
596
|
-
|
|
597
|
-
| Domain | Grill Checks |
|
|
598
|
-
|--------|-------------|
|
|
599
|
-
| Frontend | Components render, no console errors, accessibility, responsive |
|
|
600
|
-
| Backend | API endpoints return correct status codes, validation works, error handling |
|
|
601
|
-
| Database | Migrations apply cleanly, seed data loads, rollback works |
|
|
602
|
-
| Testing | All tests pass, coverage threshold met, no flaky tests |
|
|
603
|
-
| Security | No exposed secrets, input validation, auth working |
|
|
604
|
-
| DevOps | Docker builds, CI passes, deployment config valid |
|
|
605
|
-
|
|
606
857
|
---
|
|
607
858
|
|
|
608
859
|
## 8b. Agent Timeout and Stuck Detection
|
|
@@ -611,83 +862,102 @@ Agents can get stuck in extended thinking if their context overflows. The team-l
|
|
|
611
862
|
|
|
612
863
|
### Stuck Detection Rules
|
|
613
864
|
|
|
614
|
-
**Note**: Claude Code has no built-in timers. These are best-effort heuristics applied when the team-lead regains control
|
|
865
|
+
**Note**: Claude Code has no built-in timers. These are best-effort heuristics applied when the team-lead regains control.
|
|
615
866
|
|
|
616
867
|
| Condition | Action |
|
|
617
868
|
|-----------|--------|
|
|
618
869
|
| Agent has not messaged since team-lead's last turn | Send `STATUS_CHECK` message to agent |
|
|
619
870
|
| Agent does not respond to STATUS_CHECK on next team-lead turn | Declare agent stuck |
|
|
620
|
-
| Agent stuck | Log warning, proceed with other agents, handle stuck agent's
|
|
871
|
+
| Agent stuck | Log warning, proceed with other agents, handle stuck agent's work manually |
|
|
621
872
|
| All agents stuck | STOP team, report to user |
|
|
622
873
|
|
|
623
874
|
### Stuck Agent Recovery
|
|
624
875
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
4. Send shutdown_request to the stuck agent to free resources
|
|
876
|
+
1. Do NOT wait for it — proceed with closure of other agents' work
|
|
877
|
+
2. Note the stuck agent's last known progress
|
|
878
|
+
3. Send shutdown_request to the stuck agent to free resources
|
|
879
|
+
4. For implementation mode: leave stuck agent's increment open for manual completion
|
|
630
880
|
|
|
631
881
|
### Preventing Stuck Agents
|
|
632
882
|
|
|
633
|
-
- Enforce the 15-task cap (
|
|
634
|
-
- Agents use `--simple` flag in auto-mode
|
|
883
|
+
- Enforce the 15-task cap (implementation mode)
|
|
884
|
+
- Agents use `--simple` flag in auto-mode
|
|
635
885
|
- Agents do NOT run /sw:done (team-lead handles closure centrally)
|
|
636
|
-
-
|
|
886
|
+
- Review/brainstorm/analysis agents have inherently bounded scope
|
|
637
887
|
|
|
638
888
|
---
|
|
639
889
|
|
|
640
890
|
## 9. Workflow Summary
|
|
641
891
|
|
|
892
|
+
### Implementation Mode
|
|
893
|
+
|
|
642
894
|
```
|
|
643
895
|
/sw:team-lead "Build checkout flow"
|
|
644
896
|
│
|
|
645
|
-
├── Step 0:
|
|
897
|
+
├── Step 0: MODE DETECTION → implementation (default)
|
|
898
|
+
├── Step 0a: VERIFY INCREMENT EXISTS (BLOCKING)
|
|
646
899
|
│ ├── Found? → Read master spec.md as source of truth
|
|
647
900
|
│ └── Missing? → Auto-invoke /sw:increment, wait for completion
|
|
648
|
-
├── Step 0b: ACTIVATE MASTER INCREMENT
|
|
649
|
-
│ └── Edit metadata.json: set status to "active"
|
|
650
|
-
├── Step 1: Analyze feature
|
|
651
|
-
├── Step 2: Create team via TeamCreate
|
|
652
|
-
├── Step 3: Create per-domain increments
|
|
901
|
+
├── Step 0b: ACTIVATE MASTER INCREMENT
|
|
902
|
+
│ └── Edit metadata.json: set status to "active"
|
|
903
|
+
├── Step 1: Analyze feature → identify domains → decide increment split
|
|
904
|
+
├── Step 2: Create team via TeamCreate (team_name: "impl-*" or any)
|
|
905
|
+
├── Step 3: Create per-domain increments
|
|
653
906
|
├── Step 4: Contract-first spawning (all agents with mode: "bypassPermissions")
|
|
654
|
-
│ ├── Phase 1: Spawn shared + database
|
|
655
|
-
│ │ └── Receive PLAN_READY, review & approve via SendMessage (Section 3b)
|
|
656
|
-
│ │ └── Wait for CONTRACT_READY after approval
|
|
907
|
+
│ ├── Phase 1: Spawn shared + database → wait for CONTRACT_READY
|
|
657
908
|
│ └── Phase 2: Spawn backend + frontend + testing
|
|
658
|
-
|
|
659
|
-
├── Step
|
|
660
|
-
├── Step
|
|
661
|
-
├── Step 7: Team-lead runs centralized closure per increment:
|
|
662
|
-
│ ├── Pre-closure: verify/fix metadata.json status → must be "active"
|
|
663
|
-
│ ├── /sw:grill → fix findings → retry if needed (max 2)
|
|
664
|
-
│ └── /sw:done --auto → fix gate failures → retry if needed (max 2)
|
|
909
|
+
├── Step 5: Monitor progress via SendMessage
|
|
910
|
+
├── Step 6: Agents signal COMPLETION
|
|
911
|
+
├── Step 7: Team-lead runs centralized closure per increment
|
|
665
912
|
└── Step 8: Merge and close (/sw:team-merge)
|
|
666
913
|
```
|
|
667
914
|
|
|
668
|
-
|
|
669
|
-
Direct invocation of `/sw:team-lead` without an existing increment will trigger the guard and auto-invoke `/sw:increment`.
|
|
915
|
+
### Review Mode
|
|
670
916
|
|
|
671
|
-
|
|
917
|
+
```
|
|
918
|
+
/sw:team-lead "Review PR #63" --mode review
|
|
919
|
+
│
|
|
920
|
+
├── Step 0: MODE DETECTION → review
|
|
921
|
+
├── Step 1: Determine review scope (PR diff, target files)
|
|
922
|
+
├── Step 2: Create team (team_name: "review-pr-63")
|
|
923
|
+
├── Step 3: Spawn all reviewers in parallel
|
|
924
|
+
│ ├── Security Reviewer
|
|
925
|
+
│ ├── Logic Reviewer
|
|
926
|
+
│ └── Performance Reviewer
|
|
927
|
+
├── Step 4: Collect REVIEW_COMPLETE from all agents
|
|
928
|
+
├── Step 5: Merge, deduplicate, prioritize findings
|
|
929
|
+
└── Step 6: Deliver unified review to user
|
|
930
|
+
```
|
|
672
931
|
|
|
673
|
-
|
|
674
|
-
**Do NOT call TeamCreate in dry-run mode** — just show the formatted plan text.
|
|
932
|
+
### Brainstorm Mode
|
|
675
933
|
|
|
676
934
|
```
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
935
|
+
/sw:team-lead "Brainstorm payment architecture" --mode brainstorm
|
|
936
|
+
│
|
|
937
|
+
├── Step 0: MODE DETECTION → brainstorm
|
|
938
|
+
├── Step 1: Frame the core question
|
|
939
|
+
├── Step 2: Create team (team_name: "brainstorm-payment-arch")
|
|
940
|
+
├── Step 3: Spawn all perspective agents in parallel
|
|
941
|
+
│ ├── Advocate (champions innovative approaches)
|
|
942
|
+
│ ├── Critic (finds risks and failure modes)
|
|
943
|
+
│ └── Pragmatist (practical feasibility)
|
|
944
|
+
├── Step 4: Collect PERSPECTIVE_COMPLETE from all agents
|
|
945
|
+
├── Step 5: Synthesize into decision matrix
|
|
946
|
+
└── Step 6: Recommend path forward → suggest /sw:increment if proceeding
|
|
947
|
+
```
|
|
684
948
|
|
|
685
|
-
|
|
686
|
-
3. backend -> sw:architect, infra:devops | Increment: 0202-checkout-backend
|
|
687
|
-
4. frontend -> frontend:architect | Increment: 0203-checkout-frontend
|
|
949
|
+
### Analysis Mode
|
|
688
950
|
|
|
689
|
-
|
|
690
|
-
|
|
951
|
+
```
|
|
952
|
+
/sw:team-lead "Analyze auth module architecture" --mode analysis
|
|
953
|
+
│
|
|
954
|
+
├── Step 0: MODE DETECTION → analysis
|
|
955
|
+
├── Step 1: Define analysis scope and questions
|
|
956
|
+
├── Step 2: Create team (team_name: "analysis-auth-deps")
|
|
957
|
+
├── Step 3: Spawn analysis agents (dynamically composed)
|
|
958
|
+
├── Step 4: Collect ANALYSIS_COMPLETE from all agents
|
|
959
|
+
├── Step 5: Synthesize findings into structured report
|
|
960
|
+
└── Step 6: Deliver report → suggest /sw:increment if actionable
|
|
691
961
|
```
|
|
692
962
|
|
|
693
963
|
---
|
|
@@ -696,29 +966,27 @@ To execute, run without --dry-run.
|
|
|
696
966
|
|
|
697
967
|
| Issue | Cause | Fix |
|
|
698
968
|
|-------|-------|-----|
|
|
699
|
-
| **TeamCreate blocked by guard** | No increment
|
|
700
|
-
| **Agent stuck on trust folder** | Agent spawned without `bypassPermissions` | ALWAYS use `mode: "bypassPermissions"` — NEVER `mode: "plan"
|
|
701
|
-
| **Agents editing same files** | Overlapping file ownership
|
|
702
|
-
| **Token cost too high** | Too many agents
|
|
703
|
-
| **Agent stuck in extended thinking** | Too many tasks (>15)
|
|
704
|
-
| **
|
|
705
|
-
| **
|
|
706
|
-
| **
|
|
707
|
-
|
|
|
708
|
-
| **`specweave complete` exits silently** | metadata.json status is "planned" (not "active") | Agents don't manage lifecycle status. Team-lead MUST activate the increment before spawning agents (see Step 0). Fix: edit metadata.json to set `"status": "active"` before running `specweave complete` |
|
|
709
|
-
| **Closure fails on multiple increments** | Quality gates fail (grill, desync, missing reports) | Fix each issue and retry `/sw:done --auto` (max 2 retries per increment). See Section 8 closure failure table |
|
|
969
|
+
| **TeamCreate blocked by guard** | No increment exists AND team_name doesn't have a non-impl prefix | For implementation: run `/sw:increment` first. For review/brainstorm/analysis: use the correct team_name prefix (review-*, brainstorm-*, analysis-*) |
|
|
970
|
+
| **Agent stuck on trust folder** | Agent spawned without `bypassPermissions` | ALWAYS use `mode: "bypassPermissions"` — NEVER `mode: "plan"` |
|
|
971
|
+
| **Agents editing same files** | Overlapping file ownership (implementation mode) | Review ownership map; reassign conflicting files |
|
|
972
|
+
| **Token cost too high** | Too many agents | Reduce `--max-agents`; use `--domains` to limit scope |
|
|
973
|
+
| **Agent stuck in extended thinking** | Too many tasks (>15) | Enforce 15-task cap; split large domains |
|
|
974
|
+
| **Review agents missing context** | PR diff not provided in prompt | Ensure PR number or file paths are in [REVIEW_TARGET] placeholder |
|
|
975
|
+
| **Brainstorm too shallow** | Agents not exploring deeply enough | Add more specific context to [BRAINSTORM_QUESTION] placeholder |
|
|
976
|
+
| **Wrong mode detected** | Ambiguous description | Use explicit `--mode` flag or correct team_name prefix |
|
|
977
|
+
| **`specweave complete` exits silently** | metadata.json status is "planned" | Edit metadata.json: set status to "active" before closure |
|
|
710
978
|
|
|
711
979
|
---
|
|
712
980
|
|
|
713
981
|
## 11. Examples
|
|
714
982
|
|
|
715
|
-
### Example 1: Full-Stack Feature
|
|
983
|
+
### Example 1: Full-Stack Feature (Implementation Mode)
|
|
716
984
|
|
|
717
985
|
```
|
|
718
986
|
User: /sw:team-lead "Build user authentication with login, signup, password reset, and OAuth"
|
|
719
987
|
|
|
720
|
-
|
|
721
|
-
|
|
988
|
+
Mode: implementation (auto-detected)
|
|
989
|
+
Domains: shared/types, database, backend, frontend, testing, security
|
|
722
990
|
|
|
723
991
|
Phase 1:
|
|
724
992
|
- shared-types agent: Auth types (User, Session, AuthToken interfaces)
|
|
@@ -731,18 +999,73 @@ Phase 2 (after contracts ready):
|
|
|
731
999
|
- security agent: Password hashing, JWT validation, rate limiting, CSRF
|
|
732
1000
|
```
|
|
733
1001
|
|
|
734
|
-
### Example 2:
|
|
1002
|
+
### Example 2: PR Review (Review Mode)
|
|
1003
|
+
|
|
1004
|
+
```
|
|
1005
|
+
User: /sw:team-lead "Review PR #63"
|
|
1006
|
+
|
|
1007
|
+
Mode: review (auto-detected from "PR #63")
|
|
1008
|
+
Team: review-pr-63
|
|
1009
|
+
|
|
1010
|
+
Spawns 3 parallel reviewers:
|
|
1011
|
+
- Security: Checks for injection, auth bypass, secrets in diff
|
|
1012
|
+
- Logic: Verifies correctness, edge cases, error handling in changed code
|
|
1013
|
+
- Performance: Identifies N+1 queries, unnecessary allocations in diff
|
|
1014
|
+
|
|
1015
|
+
Output: Unified review with Must Fix / Should Fix / Consider categories
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
### Example 3: Architecture Brainstorm (Brainstorm Mode)
|
|
1019
|
+
|
|
1020
|
+
```
|
|
1021
|
+
User: /sw:team-lead "Brainstorm: microservices vs monolith for our growing app"
|
|
1022
|
+
|
|
1023
|
+
Mode: brainstorm (auto-detected from "brainstorm")
|
|
1024
|
+
Team: brainstorm-arch-decision
|
|
1025
|
+
|
|
1026
|
+
Spawns 3 parallel perspective agents:
|
|
1027
|
+
- Advocate: Champions microservices — independent scaling, team autonomy, polyglot
|
|
1028
|
+
- Critic: Warns about distributed complexity, network latency, operational overhead
|
|
1029
|
+
- Pragmatist: Evaluates team size, current traffic, migration cost, timeline
|
|
1030
|
+
|
|
1031
|
+
Output: Decision matrix with scored options and recommended path
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
### Example 4: Codebase Analysis (Analysis Mode)
|
|
735
1035
|
|
|
736
1036
|
```
|
|
737
|
-
User: /sw:team-lead "
|
|
738
|
-
|
|
1037
|
+
User: /sw:team-lead "Analyze our dependency tree for security risks" --mode analysis
|
|
1038
|
+
|
|
1039
|
+
Mode: analysis (explicit flag)
|
|
1040
|
+
Team: analysis-dep-security
|
|
1041
|
+
|
|
1042
|
+
Spawns dynamically composed agents:
|
|
1043
|
+
- npm-audit-agent: Runs npm audit, maps CVEs to severity
|
|
1044
|
+
- license-agent: Checks license compliance across all deps
|
|
1045
|
+
- freshness-agent: Identifies outdated packages and upgrade paths
|
|
1046
|
+
|
|
1047
|
+
Output: Structured report with findings, risk assessment, prioritized action items
|
|
739
1048
|
```
|
|
740
1049
|
|
|
741
|
-
### Example
|
|
1050
|
+
### Example 5: Dry Run
|
|
742
1051
|
|
|
743
1052
|
```
|
|
744
1053
|
User: /sw:team-lead "Add payment processing" --dry-run
|
|
745
|
-
|
|
1054
|
+
|
|
1055
|
+
Team Orchestration Plan (DRY RUN)
|
|
1056
|
+
==================================================
|
|
1057
|
+
Feature: Add payment processing | Mode: implementation | Domains: 4
|
|
1058
|
+
|
|
1059
|
+
Phase 1 (upstream):
|
|
1060
|
+
1. shared-types -> sw:architect | Increment: 0200-payment-shared
|
|
1061
|
+
2. database -> sw:architect | Increment: 0201-payment-database
|
|
1062
|
+
|
|
1063
|
+
Phase 2 (downstream, parallel):
|
|
1064
|
+
3. backend -> sw:architect | Increment: 0202-payment-backend
|
|
1065
|
+
4. frontend -> frontend:architect | Increment: 0203-payment-frontend
|
|
1066
|
+
|
|
1067
|
+
Max agents: 4 (2 sequential + 2 parallel)
|
|
1068
|
+
To execute, run without --dry-run.
|
|
746
1069
|
```
|
|
747
1070
|
|
|
748
1071
|
---
|
|
@@ -753,6 +1076,8 @@ User: /sw:team-lead "Add payment processing" --dry-run
|
|
|
753
1076
|
|-------|---------|
|
|
754
1077
|
| `/sw:team-status` | Show progress of all agents in the current team session |
|
|
755
1078
|
| `/sw:team-merge` | Merge completed agent work in dependency order |
|
|
1079
|
+
| `/sw:team-build` | Preset-driven team spawning (full-stack, review, testing, tdd, migration) |
|
|
756
1080
|
| `/sw:auto` | Autonomous execution (single-agent mode) |
|
|
757
1081
|
| `/sw:architect` | System architecture and ADRs |
|
|
758
1082
|
| `/sw:grill` | Quality validation gate |
|
|
1083
|
+
| `/sw:brainstorm` | Single-agent brainstorming (for simpler ideation without teams) |
|