specweave 0.26.4 → 0.26.5

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.
Files changed (28) hide show
  1. package/CLAUDE.md +120 -0
  2. package/dist/src/core/increment/increment-reopener.d.ts.map +1 -1
  3. package/dist/src/core/increment/increment-reopener.js +13 -14
  4. package/dist/src/core/increment/increment-reopener.js.map +1 -1
  5. package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
  6. package/dist/src/core/increment/metadata-manager.js +16 -0
  7. package/dist/src/core/increment/metadata-manager.js.map +1 -1
  8. package/dist/src/core/increment/status-change-sync-trigger.d.ts +85 -0
  9. package/dist/src/core/increment/status-change-sync-trigger.d.ts.map +1 -0
  10. package/dist/src/core/increment/status-change-sync-trigger.js +137 -0
  11. package/dist/src/core/increment/status-change-sync-trigger.js.map +1 -0
  12. package/dist/src/core/increment/sync-circuit-breaker.d.ts +64 -0
  13. package/dist/src/core/increment/sync-circuit-breaker.d.ts.map +1 -0
  14. package/dist/src/core/increment/sync-circuit-breaker.js +95 -0
  15. package/dist/src/core/increment/sync-circuit-breaker.js.map +1 -0
  16. package/dist/src/core/living-docs/living-docs-sync.d.ts +12 -0
  17. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  18. package/dist/src/core/living-docs/living-docs-sync.js +114 -18
  19. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  20. package/package.json +2 -2
  21. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +16 -0
  22. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -1
  23. package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +267 -868
  24. package/plugins/specweave/skills/increment-planner/SKILL.md +337 -1253
  25. package/plugins/specweave/skills/role-orchestrator/SKILL.md +293 -969
  26. package/plugins/specweave-docs/skills/technical-writing/SKILL.md +333 -839
  27. package/plugins/specweave-testing/skills/tdd-expert/SKILL.md +269 -749
  28. package/plugins/specweave-testing/skills/unit-testing-expert/SKILL.md +318 -810
@@ -3,1124 +3,448 @@ name: role-orchestrator
3
3
  description: Multi-agent orchestration system that coordinates specialized agents (PM, Architect, DevOps, QA, Tech Lead, Security) to work together on complex tasks. Implements hierarchical orchestrator-worker pattern. Activates for complex multi-step requests requiring multiple roles/skills. Keywords: build product, create SaaS, full implementation, end-to-end, multi-agent, orchestrate, coordinate roles, complex project.
4
4
  ---
5
5
 
6
- # Role Orchestrator - Multi-Agent Coordination System
6
+ # Role Orchestrator - Multi-Agent Coordination
7
7
 
8
- **Purpose**: Coordinate multiple specialized agents to solve complex, multi-step problems through intelligent task decomposition and role assignment.
8
+ **Self-contained orchestration that works in ANY user project after `specweave init`.**
9
9
 
10
- ## Architecture Pattern
10
+ ---
11
+
12
+ ## Purpose
11
13
 
12
- The role-orchestrator implements the **Hierarchical Orchestrator-Worker Pattern** from multi-agent systems research:
14
+ Coordinate multiple specialized agents for complex, multi-step tasks through intelligent decomposition and role assignment.
13
15
 
16
+ **Architecture**: Hierarchical Orchestrator-Worker Pattern
14
17
  ```
15
- User Request
16
-
17
- Role Orchestrator (this skill)
18
-
19
- ├── Task Decomposition (PM Agent)
20
- ├── Architecture Design (Architect Agent)
21
- ├── Technical Planning (Tech Lead Agent)
22
- ├── Security Review (Security Agent)
23
- ├── QA Strategy (QA Lead Agent)
24
- ├── Implementation (Backend/Frontend Agents)
25
- └── Deployment (DevOps Agent)
18
+ User Request → Orchestrator → PM → Architect → Tech Lead → Implement → QA → Deploy
26
19
  ```
27
20
 
21
+ ---
22
+
28
23
  ## When to Activate
29
24
 
30
- This skill activates for requests that require **3+ agents** or **full product development**:
25
+ Activates for requests requiring **3+ agents** or **full product development**:
26
+
27
+ | User Says | Agents Needed | Pattern |
28
+ |-----------|---------------|---------|
29
+ | "Build a SaaS for X" | PM → Architect → Tech Lead → Implement → QA → DevOps | Sequential |
30
+ | "Create real-time chat" | Architect → Backend + Frontend (parallel) → QA | Parallel |
31
+ | "Secure authentication" | Security → Tech Lead → Backend → QA | Sequential |
32
+ | "Optimize performance" | Tech Lead → Performance → Backend → DevOps | Iterative |
31
33
 
32
- | User Says | Agents Needed | Orchestration Pattern |
33
- |-----------|---------------|---------------------|
34
- | "Build a SaaS for project management" | PM → Architect → Tech Lead → Implement → QA → DevOps | Sequential with feedback loops |
35
- | "Create real-time chat feature" | Architect → Tech Lead → Backend → Frontend → QA | Parallel (Backend + Frontend) |
36
- | "Secure our authentication system" | Security → Tech Lead → Backend → QA | Sequential validation |
37
- | "Deploy to production" | DevOps → QA → Backend → Tech Lead | Pre-flight checks |
38
- | "Optimize system performance" | Tech Lead → Performance → Backend → DevOps → QA | Iterative optimization |
34
+ ---
39
35
 
40
- ## Agent Roles & Responsibilities
36
+ ## Agent Roles
41
37
 
42
38
  ### Strategic Layer
43
39
 
44
- **1. PM Agent (pm-agent)**
45
- - Product strategy and requirements
46
- - User story creation
47
- - Feature prioritization
48
- - Stakeholder communication
40
+ **PM Agent (pm-agent)**
41
+ - Product strategy, user stories, prioritization
49
42
  - **When**: Starting new products/features
50
43
 
51
- **2. Architect Agent (architect-agent)**
52
- - System design and architecture
53
- - Technology stack decisions
54
- - Create Architecture Decision Records (ADRs)
55
- - Component design
56
- - **When**: Designing new systems or major features
44
+ **Architect Agent (architect-agent)**
45
+ - System design, ADRs, technology stack
46
+ - **When**: Designing systems or major features
57
47
 
58
48
  ### Execution Layer
59
49
 
60
- **3. Tech Lead Agent (tech-lead-agent)**
61
- - Technical planning and estimation
62
- - Code review and quality standards
63
- - Team guidance
64
- - Technology mentorship
65
- - **When**: Complex technical decisions needed
66
-
67
- **4. Backend Developers**
68
- - nodejs-backend: Node.js/TypeScript implementation
69
- - python-backend: Python/FastAPI implementation
70
- - dotnet-backend: C#/.NET implementation
71
- - **When**: Implementing server-side logic
72
-
73
- **5. Frontend Agent (frontend-agent)**
74
- - React/Next.js implementation
75
- - UI/UX implementation
76
- - Client-side logic
50
+ **Tech Lead Agent (tech-lead-agent)**
51
+ - Technical planning, code review, quality standards
52
+ - **When**: Complex technical decisions
53
+
54
+ **Backend Agents**
55
+ - nodejs-backend, python-backend, dotnet-backend
56
+ - **When**: Server-side implementation
57
+
58
+ **Frontend Agent (frontend-agent)**
59
+ - React/Next.js, UI/UX implementation
77
60
  - **When**: Building user interfaces
78
61
 
79
62
  ### Quality & Operations Layer
80
63
 
81
- **6. QA Lead Agent (qa-lead-agent)**
82
- - Test strategy creation
83
- - Quality assurance
84
- - Test case design
85
- - Test coverage analysis
64
+ **QA Lead Agent (qa-lead-agent)**
65
+ - Test strategy, quality assurance, coverage
86
66
  - **When**: Defining testing approach
87
67
 
88
- **7. Security Agent (security-agent)**
89
- - Security architecture review
90
- - Threat modeling
91
- - Penetration testing
92
- - Compliance validation (OWASP, PCI-DSS)
68
+ **Security Agent (security-agent)**
69
+ - Security architecture, threat modeling, compliance
93
70
  - **When**: Security-critical features
94
71
 
95
- **8. DevOps Agent (devops-agent)**
96
- - Infrastructure provisioning
97
- - CI/CD pipeline setup
98
- - Deployment automation
99
- - Monitoring and observability
100
- - **When**: Deployment and operations tasks
101
-
102
- ## ⚠️ CRITICAL: Increment Creation FIRST
103
-
104
- **MANDATORY FIRST STEP**: Before invoking ANY agents, the role-orchestrator MUST create an increment folder.
72
+ **DevOps Agent (devops-agent)**
73
+ - Infrastructure, CI/CD, deployment, monitoring
74
+ - **When**: Operations tasks
105
75
 
106
- ### Phase 0: Create Increment Structure
107
-
108
- ```typescript
109
- async function createIncrementFirst(userRequest: string): Promise<IncrementInfo> {
110
- // 1. Parse user request to extract project name
111
- const projectName = extractProjectName(userRequest);
112
- // e.g., "event management" → "event-management"
113
-
114
- // 2. Auto-number increment (scan .specweave/increments/ for highest)
115
- const nextNumber = await getNextIncrementNumber();
116
- // e.g., 0001, 0002, 0003
117
-
118
- // 3. Create increment folder
119
- const incrementPath = `.specweave/increments/${nextNumber}-${projectName}/`;
120
- await mkdir(incrementPath, { recursive: true });
121
-
122
- // 4. Create subdirectories
123
- await mkdir(`${incrementPath}logs/`);
124
- await mkdir(`${incrementPath}scripts/`);
125
- await mkdir(`${incrementPath}reports/`);
126
-
127
- // 5. Create placeholder files
128
- await writeFile(`${incrementPath}spec.md`, SPEC_TEMPLATE);
129
- await writeFile(`${incrementPath}tasks.md`, TASKS_TEMPLATE);
130
- await writeFile(`${incrementPath}tests.md`, TESTS_TEMPLATE);
131
- await writeFile(`${incrementPath}context-manifest.yaml`, CONTEXT_MANIFEST_TEMPLATE);
132
-
133
- // 6. Return increment info for agents
134
- return {
135
- id: `${nextNumber}-${projectName}`,
136
- path: incrementPath,
137
- number: nextNumber,
138
- name: projectName
139
- };
140
- }
141
- ```
142
-
143
- **Templates**:
144
-
145
- ```yaml
146
- # spec.md frontmatter
147
- ---
148
- increment: 0001-event-management
149
- title: "Event Management SaaS"
150
- priority: P1
151
- status: planned
152
- created: 2025-10-26
153
- structure: user-stories
154
76
  ---
155
77
 
156
- # Event Management SaaS
157
-
158
- ## Overview
159
-
160
- (To be filled by PM Agent)
161
- ```
78
+ ## CRITICAL: Safe Orchestration Pattern
162
79
 
163
- ```yaml
164
- # context-manifest.yaml
165
- ---
166
- spec_sections:
167
- - .specweave/docs/internal/strategy/README.md
80
+ **Rule**: Orchestrator creates structure, guides user to invoke agents in MAIN context (NOT nested spawning).
168
81
 
169
- documentation:
170
- - .specweave/docs/internal/architecture/README.md
82
+ ### Phase 0: Create Increment Structure FIRST
171
83
 
172
- max_context_tokens: 10000
173
- priority: high
174
- auto_refresh: false
175
- ---
176
- ```
84
+ Before invoking ANY agents, create increment folder:
177
85
 
178
- **Then pass increment path to ALL agents**:
179
86
  ```typescript
180
- const increment = await createIncrementFirst(userRequest);
181
-
182
- // Now invoke agents with increment path
183
- await invokeAgent('pm', {
184
- task: 'Define product requirements',
185
- outputPath: `${increment.path}reports/pm-analysis.md`,
186
- incrementId: increment.id
187
- });
188
- ```
87
+ // 1. Parse user request
88
+ const projectName = extractProjectName(userRequest);
89
+ // "event management" "event-management"
189
90
 
190
- ### ⚠️ CRITICAL: File Reading Instructions for Agents
91
+ // 2. Get next number
92
+ const nextNumber = getNextIncrementNumber();
93
+ // e.g., 0001, 0002, 0003
191
94
 
192
- When invoking agents, provide clear instructions to **read FILES, not DIRECTORIES**:
95
+ // 3. Create structure
96
+ const incrementPath = `.specweave/increments/${nextNumber}-${projectName}/`;
97
+ mkdir -p ${incrementPath}
98
+ mkdir -p ${incrementPath}logs/
99
+ mkdir -p ${incrementPath}scripts/
100
+ mkdir -p ${incrementPath}reports/
193
101
 
194
- **❌ WRONG**:
195
- ```typescript
196
- await invokeAgent('architect', {
197
- task: 'Read .specweave/docs/internal/strategy and design architecture'
198
- });
199
- ```
200
- This will fail with `EISDIR: illegal operation on a directory, read`
201
-
202
- **✅ CORRECT**:
203
- ```typescript
204
- await invokeAgent('architect', {
205
- task: `Read .specweave/docs/internal/strategy/README.md for existing strategy.
206
- Use Glob to find additional files: .specweave/docs/internal/strategy/**/*.md
207
- Then design system architecture.`
208
- });
102
+ // 4. Create placeholder files
103
+ write ${incrementPath}spec.md (basic template)
104
+ write ${incrementPath}plan.md (basic template)
105
+ write ${incrementPath}tasks.md (basic template)
106
+ write ${incrementPath}metadata.json (MANDATORY)
209
107
  ```
210
108
 
211
- **Best Practice**:
212
- - Always specify **file paths** (`.md` extension), NOT directory paths
213
- - Use `Glob` tool for pattern matching (`**/*.md`)
214
- - Read `README.md` files for directory overviews
215
- - List specific files to read
216
-
109
+ **spec.md template**:
110
+ ```yaml
111
+ ---
112
+ increment: 0001-project-name
113
+ title: "Project Name"
114
+ type: feature
115
+ priority: P1
116
+ status: planned
117
+ created: 2025-11-24
217
118
  ---
218
119
 
219
- ## Orchestration Workflows
120
+ # Project Name
220
121
 
221
- ### Workflow 1: New Product Development
122
+ ## Overview
123
+ (To be filled by PM Agent)
222
124
 
223
- ```yaml
224
- name: "Build SaaS Product"
225
- pattern: sequential_with_gates
226
- agents:
227
- - role: pm-agent
228
- task: "Define product requirements and user stories"
229
- output: specifications/product.md
230
- gate: user_approval_required
231
-
232
- - role: architect-agent
233
- task: "Design system architecture"
234
- input: specifications/product.md
235
- output: .specweave/docs/architecture/system-design.md
236
- gate: tech_review_required
237
-
238
- - role: tech-lead-agent
239
- task: "Create technical implementation plan"
240
- input: .specweave/docs/architecture/system-design.md
241
- output: .specweave/increments/####-product/plan.md
242
-
243
- - role: security-agent
244
- task: "Security architecture review"
245
- input: .specweave/docs/architecture/system-design.md
246
- output: .specweave/docs/architecture/security/threat-model.md
247
- gate: security_approval
248
-
249
- - role: qa-lead-agent
250
- task: "Define test strategy"
251
- input: specifications/product.md
252
- output: .specweave/increments/####-product/tests.md
253
-
254
- - role: [nodejs-backend, frontend-agent]
255
- task: "Implement features"
256
- pattern: parallel
257
- input: .specweave/increments/####-product/plan.md
258
-
259
- - role: qa-lead-agent
260
- task: "Execute tests"
261
- input: .specweave/increments/####-product/tests.md
262
- gate: all_tests_pass
263
-
264
- - role: devops-agent
265
- task: "Deploy to production"
266
- input: .specweave/increments/####-product/plan.md#deployment
267
- gate: deployment_approval
268
-
269
- success_criteria:
270
- - All gates passed
271
- - Tests passing (>80% coverage)
272
- - Security review approved
273
- - Deployed successfully
125
+ ## User Stories
126
+ (To be filled by PM Agent)
274
127
  ```
275
128
 
276
- ### Workflow 2: Feature Addition (Brownfield)
277
-
278
- ```yaml
279
- name: "Add Feature to Existing System"
280
- pattern: analyze_then_build
281
- agents:
282
- - role: tech-lead-agent
283
- task: "Analyze existing codebase"
284
- output: .specweave/increments/####-feature/analysis.md
285
-
286
- - role: architect-agent
287
- task: "Design integration approach"
288
- input: .specweave/increments/####-feature/analysis.md
289
- output: .specweave/increments/####-feature/plan.md
290
-
291
- - role: qa-lead-agent
292
- task: "Create regression test suite"
293
- input: .specweave/increments/####-feature/analysis.md
294
- output: .specweave/increments/####-feature/regression-tests.md
295
- gate: user_validates_tests
296
-
297
- - role: [backend-agent, frontend-agent]
298
- task: "Implement feature"
299
- pattern: parallel
300
-
301
- - role: qa-lead-agent
302
- task: "Run regression + new tests"
303
- gate: no_regressions_detected
304
-
305
- - role: devops-agent
306
- task: "Deploy with canary release"
129
+ **metadata.json template**:
130
+ ```json
131
+ {
132
+ "id": "0001-project-name",
133
+ "status": "planned",
134
+ "type": "feature",
135
+ "priority": "P1",
136
+ "created": "2025-11-24T12:00:00Z",
137
+ "lastActivity": "2025-11-24T12:00:00Z"
138
+ }
307
139
  ```
308
140
 
309
- ### Workflow 3: Security Hardening
141
+ ### Phase 1: Guide User Through Agent Workflow
310
142
 
311
- ```yaml
312
- name: "Secure Existing System"
313
- pattern: assess_fix_verify
314
- agents:
315
- - role: security-agent
316
- task: "Threat modeling and security assessment"
317
- output: .specweave/docs/architecture/security/assessment.md
318
-
319
- - role: tech-lead-agent
320
- task: "Prioritize security issues"
321
- input: .specweave/docs/architecture/security/assessment.md
322
- output: work/issues/###-security-fixes/
323
-
324
- - role: [backend-agent, frontend-agent]
325
- task: "Implement security fixes"
326
- pattern: parallel
327
-
328
- - role: security-agent
329
- task: "Penetration testing"
330
- gate: no_critical_vulns
331
-
332
- - role: qa-lead-agent
333
- task: "Security regression tests"
334
- gate: all_tests_pass
335
-
336
- - role: devops-agent
337
- task: "Deploy with zero-downtime"
338
- ```
143
+ **Output this workflow to user**:
339
144
 
340
- ### Workflow 4: Performance Optimization
341
-
342
- ```yaml
343
- name: "Optimize System Performance"
344
- pattern: measure_optimize_verify
345
- agents:
346
- - role: tech-lead-agent
347
- task: "Profile and identify bottlenecks"
348
- output: work/issues/###-performance/analysis.md
349
-
350
- - role: architect-agent
351
- task: "Design optimization strategy"
352
- input: work/issues/###-performance/analysis.md
353
-
354
- - role: [backend-agent, frontend-agent, devops-agent]
355
- task: "Implement optimizations"
356
- pattern: parallel
357
-
358
- - role: qa-lead-agent
359
- task: "Performance regression tests"
360
- gate: performance_targets_met
361
-
362
- - role: devops-agent
363
- task: "Deploy with traffic shaping"
364
145
  ```
146
+ ✅ Increment structure created: .specweave/increments/0001-project-name/
365
147
 
366
- ## Task Decomposition Strategy
148
+ 🎯 Complete workflow (run these commands in MAIN conversation):
367
149
 
368
- ### 1. Analyze Request Complexity
150
+ STEP 1: Product Strategy & Requirements
151
+ Tell Claude: "Complete the spec for increment 0001-project-name"
152
+ (PM agent will activate automatically)
369
153
 
370
- ```typescript
371
- interface ComplexityAnalysis {
372
- scope: 'single-feature' | 'multi-feature' | 'full-product' | 'system-wide';
373
- domains: string[]; // ['backend', 'frontend', 'database', 'infrastructure']
374
- phases: number; // Number of sequential phases
375
- agents_needed: string[];
376
- estimated_effort: 'small' | 'medium' | 'large' | 'xl';
377
- }
154
+ STEP 2: Architecture & Design
155
+ Tell Claude: "Design architecture for increment 0001-project-name"
156
+ (Architect agent will create ADRs and system design)
378
157
 
379
- function analyzeComplexity(userRequest: string): ComplexityAnalysis {
380
- // Use intent classification from skill-router
381
- // Analyze keywords, scope, and requirements
382
- // Return structured complexity analysis
383
- }
384
- ```
385
-
386
- ### 2. Create Execution Plan
387
-
388
- ```typescript
389
- interface ExecutionPlan {
390
- phases: Phase[];
391
- parallel_groups: ParallelGroup[];
392
- gates: QualityGate[];
393
- estimated_duration: string;
394
- }
158
+ STEP 3: Technical Planning
159
+ Tell Claude: "Create technical plan for increment 0001-project-name"
160
+ (Tech Lead agent will create implementation approach)
395
161
 
396
- interface Phase {
397
- name: string;
398
- agents: AgentAssignment[];
399
- dependencies: string[]; // Phase IDs this depends on
400
- outputs: string[]; // File paths to create
401
- }
162
+ STEP 4: Implementation Tasks
163
+ Tell Claude: "Create tasks for increment 0001-project-name"
164
+ (Test-aware planner will generate tasks with tests)
402
165
 
403
- interface ParallelGroup {
404
- agents: string[];
405
- can_run_concurrently: boolean;
406
- sync_point: string; // Where they must sync
407
- }
166
+ STEP 5: Security Review (if needed)
167
+ Tell Claude: "Review security for increment 0001-project-name"
168
+ (Security agent will perform threat modeling)
408
169
 
409
- interface QualityGate {
410
- phase: string;
411
- type: 'user_approval' | 'test_pass' | 'security_review' | 'performance_target';
412
- criteria: string[];
413
- blocker: boolean; // If true, cannot proceed until gate passes
414
- }
415
- ```
170
+ STEP 6: Implementation
171
+ Tell Claude: "Implement increment 0001-project-name"
172
+ (Backend/Frontend agents will implement code)
416
173
 
417
- ### 3. Execute with Monitoring
174
+ STEP 7: Quality Assurance
175
+ Tell Claude: "Run QA for increment 0001-project-name"
176
+ (QA agent will verify tests and coverage)
418
177
 
419
- ```typescript
420
- interface ExecutionState {
421
- current_phase: number;
422
- completed_tasks: string[];
423
- blocked_tasks: string[];
424
- gates_status: Record<string, 'pending' | 'passed' | 'failed'>;
425
- agent_outputs: Record<string, any>;
426
- }
178
+ STEP 8: Deployment Planning
179
+ Tell Claude: "Plan deployment for increment 0001-project-name"
180
+ (DevOps agent will create infrastructure)
427
181
 
428
- async function execute(plan: ExecutionPlan): Promise<ExecutionResult> {
429
- const state: ExecutionState = initializeState();
430
-
431
- for (const phase of plan.phases) {
432
- // Check dependencies satisfied
433
- if (!areDependenciesMet(phase, state)) {
434
- await waitForDependencies(phase);
435
- }
436
-
437
- // Execute agents (parallel or sequential)
438
- const results = await executePhase(phase);
439
-
440
- // Update state
441
- state.completed_tasks.push(...results.tasks);
442
- state.agent_outputs[phase.name] = results.outputs;
443
-
444
- // Check quality gates
445
- if (phase.gates) {
446
- const gateResults = await checkGates(phase.gates);
447
- if (gateResults.failed.length > 0) {
448
- // Handle gate failures
449
- await handleGateFailures(gateResults.failed);
450
- }
451
- }
452
- }
453
-
454
- return {
455
- success: state.blocked_tasks.length === 0,
456
- outputs: state.agent_outputs,
457
- summary: generateSummary(state)
458
- };
459
- }
182
+ ⚠️ Run these sequentially in MAIN conversation to prevent context explosion!
460
183
  ```
461
184
 
462
- ## Agent Communication Patterns
185
+ **DO NOT spawn all agents from this skill using Task() tool!**
463
186
 
464
- ### 1. Sequential Handoff
465
-
466
- ```
467
- PM Agent → Architect Agent → Tech Lead → Implementation
468
- (specs) (design) (plan) (code)
469
- ```
187
+ ---
470
188
 
471
- Each agent receives the previous agent's output and builds upon it.
189
+ ## Orchestration Patterns
472
190
 
473
- ### 2. Parallel Execution with Shared State
191
+ ### Pattern 1: Sequential (Default)
474
192
 
193
+ **When**: Dependencies between steps
475
194
  ```
476
- Backend Agent ─┐
477
- ├─→ Shared Memory (Context) ─→ Integration Phase
478
- Frontend Agent ─┘
195
+ PM → Architect → Tech Lead → Backend Frontend → QA → DevOps
479
196
  ```
480
197
 
481
- Multiple agents work simultaneously, coordinated through shared context.
198
+ **User workflow**:
199
+ 1. Create increment structure
200
+ 2. Guide user to invoke agents one by one
201
+ 3. Each agent completes before next starts
202
+ 4. User tracks progress
482
203
 
483
- ### 3. Feedback Loops
204
+ ### Pattern 2: Parallel Execution
484
205
 
206
+ **When**: Independent work streams
485
207
  ```
486
- Implementation QA → [FAIL] → Tech Lead (analysis) → Implementation
487
-
488
- [PASS]
489
-
490
- DevOps
208
+ PM + Architect (parallel)
209
+
210
+ Backend + Frontend (parallel)
211
+
212
+ QA + DevOps (parallel)
491
213
  ```
492
214
 
493
- Iterative refinement with quality gates.
215
+ **User workflow**:
216
+ 1. Create increment structure
217
+ 2. Identify parallel opportunities
218
+ 3. Guide user: "You can run these in parallel: [list]"
219
+ 4. User invokes agents concurrently
494
220
 
495
- ### 4. Hierarchical Decision-Making
221
+ ### Pattern 3: Adaptive (Context-Aware)
496
222
 
223
+ **When**: Requirements discovered during execution
497
224
  ```
498
- Role Orchestrator (strategic decisions)
499
-
500
- Tech Lead Agent (tactical decisions)
501
-
502
- Implementation Agents (execution)
225
+ PM Architect → [Discover need] → Security → Tech Lead → ...
503
226
  ```
504
227
 
505
- ## Context Management
506
-
507
- ### Shared Context Structure
508
-
509
- ```yaml
510
- # .specweave/orchestration/context.yaml
511
- project:
512
- name: "E-Commerce Platform"
513
- phase: "implementation"
514
- current_feature: "003-payment-processing"
515
-
516
- agents_active:
517
- - pm-agent: "requirements_complete"
518
- - architect-agent: "design_approved"
519
- - backend-agent: "in_progress"
520
- - frontend-agent: "in_progress"
521
- - qa-lead-agent: "test_strategy_ready"
522
-
523
- shared_artifacts:
524
- specifications: "specifications/modules/payments/"
525
- architecture: ".specweave/docs/architecture/payment-system.md"
526
- feature_plan: "features/003-payment-processing/plan.md"
527
- implementation: "src/payments/"
528
-
529
- quality_gates:
530
- - name: "security_review"
531
- status: "passed"
532
- approved_by: "security-agent"
533
- - name: "test_coverage"
534
- status: "pending"
535
- target: ">80%"
536
- current: "67%"
537
- ```
538
-
539
- ### Agent-to-Agent Communication
540
-
541
- Agents communicate through:
542
- 1. **File outputs**: Each agent creates files in designated locations
543
- 2. **Shared memory**: `.specweave/orchestration/context.yaml`
544
- 3. **Event system**: Agents emit events when tasks complete
545
- 4. **Quality gates**: Explicit approval/rejection points
546
-
547
- ## Decision-Making Framework
228
+ **User workflow**:
229
+ 1. Start with basic plan
230
+ 2. Agent discovers additional needs
231
+ 3. Inject new agents mid-workflow
232
+ 4. Adjust plan dynamically
548
233
 
549
- ### When to Use Which Agent
550
-
551
- ```typescript
552
- const agentSelectionRules = {
553
- // Product/Business decisions
554
- 'requirements|user-stories|product-strategy': 'pm-agent',
555
-
556
- // Architecture decisions
557
- 'design|architecture|system-design|tech-stack': 'architect-agent',
234
+ ---
558
235
 
559
- // Technical guidance
560
- 'code-review|best-practices|technical-debt|refactoring': 'tech-lead-agent',
236
+ ## Quality Gates (Checkpoints)
561
237
 
562
- // Security
563
- 'security|authentication|authorization|encryption|compliance': 'security-agent',
238
+ ### Gate 1: After PM (Requirements Complete)
239
+ **Check**:
240
+ - [ ] User stories defined with AC-IDs
241
+ - [ ] Success criteria measurable
242
+ - [ ] Dependencies identified
243
+ - [ ] Out of scope defined
564
244
 
565
- // Quality assurance
566
- 'testing|qa|test-strategy|test-coverage': 'qa-lead-agent',
245
+ **Decision**: Proceed to architecture OR refine requirements
567
246
 
568
- // Implementation
569
- 'implement-nodejs|api|backend': 'nodejs-backend',
570
- 'implement-python|ml|data': 'python-backend',
571
- 'implement-dotnet|csharp|enterprise': 'dotnet-backend',
572
- 'implement-ui|frontend|react': 'frontend-agent',
247
+ ### Gate 2: After Architect (Design Complete)
248
+ **Check**:
249
+ - [ ] System design documented
250
+ - [ ] ADRs created (≥3)
251
+ - [ ] Technology stack chosen
252
+ - [ ] Data model defined
573
253
 
574
- // Operations
575
- 'deploy|infrastructure|ci-cd|monitoring': 'devops-agent'
576
- };
254
+ **Decision**: Proceed to implementation OR redesign
577
255
 
578
- function selectAgents(task: string): string[] {
579
- const keywords = extractKeywords(task);
580
- const matchedAgents = [];
256
+ ### Gate 3: After Implementation (Code Complete)
257
+ **Check**:
258
+ - [ ] All P1 tasks completed
259
+ - [ ] Tests passing (≥80% coverage)
260
+ - [ ] Code reviewed
261
+ - [ ] Documentation updated
581
262
 
582
- for (const [pattern, agent] of Object.entries(agentSelectionRules)) {
583
- if (keywords.some(kw => pattern.includes(kw))) {
584
- matchedAgents.push(agent);
585
- }
586
- }
263
+ **Decision**: Proceed to deployment OR fix issues
587
264
 
588
- return matchedAgents;
589
- }
590
- ```
265
+ ### Gate 4: Before Deployment (Production Ready)
266
+ **Check**:
267
+ - [ ] Security review passed
268
+ - [ ] Performance acceptable
269
+ - [ ] Monitoring configured
270
+ - [ ] Rollback plan exists
591
271
 
592
- ## Error Handling & Resilience
272
+ **Decision**: Deploy OR address blockers
593
273
 
594
- ### Retry Strategy
274
+ ---
595
275
 
596
- ```typescript
597
- interface RetryConfig {
598
- max_attempts: number;
599
- backoff: 'linear' | 'exponential';
600
- fallback_agent?: string;
601
- }
276
+ ## Error Handling
602
277
 
603
- async function executeWithRetry(
604
- agent: string,
605
- task: string,
606
- config: RetryConfig
607
- ): Promise<AgentResult> {
608
- for (let attempt = 1; attempt <= config.max_attempts; attempt++) {
609
- try {
610
- const result = await invokeAgent(agent, task);
611
- if (result.success) {
612
- return result;
613
- }
614
- } catch (error) {
615
- if (attempt === config.max_attempts) {
616
- // Try fallback agent if configured
617
- if (config.fallback_agent) {
618
- return await invokeAgent(config.fallback_agent, task);
619
- }
620
- throw error;
621
- }
622
- await sleep(calculateBackoff(attempt, config.backoff));
623
- }
624
- }
625
- }
278
+ ### Agent Failure
626
279
  ```
627
-
628
- ### Feedback Loops with Auto-Refinement
629
-
630
- **NEW: Automatic quality improvement through iterative refinement**
631
-
632
- ```typescript
633
- interface FeedbackLoopConfig {
634
- enabled: boolean;
635
- max_retries: 3;
636
- stop_on_improvement: boolean;
637
- quality_threshold: number; // 0.0-1.0
638
- require_user_approval: boolean;
639
- }
640
-
641
- interface RefinementResult {
642
- attempt: number;
643
- output: string;
644
- score: number;
645
- issues: Issue[];
646
- improved: boolean;
647
- final: boolean;
648
- }
649
-
650
- async function executeWithFeedback(
651
- agent: string,
652
- task: string,
653
- validator: (output: string) => Promise<ValidationResult>,
654
- config: FeedbackLoopConfig
655
- ): Promise<RefinementResult> {
656
-
657
- let bestResult = null;
658
- let bestScore = 0;
659
-
660
- for (let attempt = 1; attempt <= config.max_retries; attempt++) {
661
- // Execute agent
662
- const output = await invokeAgent(agent, task);
663
-
664
- // Validate output
665
- const validation = await validator(output);
666
-
667
- // Track progress
668
- console.log(`🔄 Refinement Attempt ${attempt}/${config.max_retries}`);
669
- console.log(` Score: ${validation.score.toFixed(2)} (Target: ${config.quality_threshold})`);
670
-
671
- // Check if quality threshold met
672
- if (validation.score >= config.quality_threshold) {
673
- console.log(`✅ Quality threshold met (${validation.score.toFixed(2)} >= ${config.quality_threshold})`);
674
- return {
675
- attempt,
676
- output,
677
- score: validation.score,
678
- issues: [],
679
- improved: true,
680
- final: true
681
- };
682
- }
683
-
684
- // Track best result
685
- if (validation.score > bestScore) {
686
- bestScore = validation.score;
687
- bestResult = { attempt, output, score: validation.score, issues: validation.issues };
688
- }
689
-
690
- // Check if should stop (improvement + stop_on_improvement flag)
691
- if (config.stop_on_improvement && attempt > 1 && validation.score > bestScore) {
692
- console.log(`⏸️ Stopping early (score improved: ${bestScore.toFixed(2)} → ${validation.score.toFixed(2)})`);
693
- return {
694
- ...bestResult,
695
- improved: true,
696
- final: true
697
- };
698
- }
699
-
700
- // If not last attempt, prepare feedback for next iteration
701
- if (attempt < config.max_retries) {
702
- const feedback = generateFeedback(validation.issues);
703
-
704
- // Update task with feedback
705
- task = `${task}\n\n**Feedback from previous attempt (${validation.score.toFixed(2)}/1.00):**\n${feedback}`;
706
-
707
- console.log(` Issues found: ${validation.issues.length}`);
708
- console.log(` Retrying with feedback...`);
709
- }
710
- }
711
-
712
- // Max retries reached, return best result
713
- console.log(`⚠️ Max retries reached. Best score: ${bestScore.toFixed(2)}`);
714
-
715
- return {
716
- ...bestResult,
717
- improved: bestScore > 0,
718
- final: true
719
- };
720
- }
721
-
722
- function generateFeedback(issues: Issue[]): string {
723
- const feedback: string[] = [];
724
-
725
- for (const issue of issues) {
726
- feedback.push(`• ${issue.severity.toUpperCase()}: ${issue.description}`);
727
- if (issue.location) {
728
- feedback.push(` Location: ${issue.location}`);
729
- }
730
- if (issue.suggestion) {
731
- feedback.push(` Suggestion: ${issue.suggestion}`);
732
- }
733
- }
734
-
735
- return feedback.join('\n');
736
- }
280
+ If agent fails:
281
+ 1. Capture error details
282
+ 2. Retry with backoff (max 3 attempts)
283
+ 3. Try fallback agent if available
284
+ 4. If critical: pause and notify user
285
+ 5. NEVER fail silently
737
286
  ```
738
287
 
739
- ### Feedback Loop Workflow
740
-
288
+ ### Graceful Degradation
741
289
  ```
742
- Agent generates output
743
-
744
- Validate output (rule-based + LLM-judge)
745
-
746
- Score < threshold? ──No──→ ✅ Accept output
747
- ↓ Yes
748
- Extract issues and suggestions
749
-
750
- Generate feedback prompt
751
-
752
- Agent regenerates with feedback ──┐
753
- ↓ │
754
- Validate again │
755
- ↓ │
756
- Score improved? ──No──→ Retry ────┘ (max 3x)
757
- ↓ Yes
758
- ✅ Accept improved output
290
+ If PM fails → Use basic template
291
+ If Architect fails → Tech Lead creates simple design
292
+ If Backend fails Create manual implementation guide
293
+ If DevOps fails → Create manual deployment steps
759
294
  ```
760
295
 
761
- ### Agent-Specific Feedback Integration
762
-
763
- **PM Agent (Requirements)**
764
- ```typescript
765
- const pmValidator = async (spec: string) => {
766
- // Rule-based checks
767
- const ruleScore = await runRuleBasedValidation(spec);
768
-
769
- // Optional: LLM-as-judge quality check
770
- const qualityScore = await incrementQualityJudge.evaluate(spec);
771
-
772
- return {
773
- score: (ruleScore + qualityScore) / 2,
774
- issues: [...ruleIssues, ...qualityIssues]
775
- };
776
- };
777
-
778
- await executeWithFeedback(
779
- 'pm-agent',
780
- 'Define requirements for authentication',
781
- pmValidator,
782
- config
783
- );
296
+ ### User Intervention
784
297
  ```
785
-
786
- **Architect Agent (Design)**
787
- ```typescript
788
- const architectValidator = async (design: string) => {
789
- return await incrementQualityJudge.evaluate(design, {
790
- dimensions: ['feasibility', 'scalability', 'maintainability']
791
- });
792
- };
793
-
794
- await executeWithFeedback(
795
- 'architect-agent',
796
- 'Design authentication system',
797
- architectValidator,
798
- config
799
- );
298
+ If orchestrator stuck:
299
+ 1. Show current state
300
+ 2. Present options to user
301
+ 3. Let user decide next step
302
+ 4. Resume from checkpoint
800
303
  ```
801
304
 
802
- **QA Lead Agent (Test Strategy)**
803
- ```typescript
804
- const qaValidator = async (testPlan: string) => {
805
- // Check test coverage
806
- const coverage = await analyzeTestCoverage(testPlan);
807
-
808
- // Check testability
809
- const testability = await incrementQualityJudge.evaluate(testPlan, {
810
- dimensions: ['testability', 'completeness']
811
- });
812
-
813
- return {
814
- score: coverage >= 0.80 ? testability.score : 0.60,
815
- issues: testability.issues
816
- };
817
- };
818
-
819
- await executeWithFeedback(
820
- 'qa-lead-agent',
821
- 'Create test strategy',
822
- qaValidator,
823
- config
824
- );
825
- ```
826
-
827
- ### Example: PM Agent with Feedback Loop
828
-
829
- ```markdown
830
- 🔷 SpecWeave Multi-Agent Orchestration Active
831
-
832
- **Task**: Create authentication feature
833
- **Agent**: PM Agent (Requirements)
834
-
835
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
836
-
837
- **Attempt 1/3**: Generating requirements...
838
-
839
- ✅ PM Agent completed
840
- 🔍 Validating output...
841
-
842
- Validation Results:
843
- Rule-based: ✅ 47/47 passed
844
- Quality Score: 0.72/1.00 ⚠️ (Needs improvement)
845
-
846
- Issues Found:
847
- • MAJOR: Acceptance criteria not testable
848
- Location: Section "Success Criteria"
849
- Suggestion: Use measurable metrics (e.g., "Login completes in <2s")
850
-
851
- • MINOR: Missing rate limiting specification
852
- Location: Section "Security"
853
- Suggestion: Specify brute-force protection (5 attempts, 15min lockout)
854
-
855
- Score: 0.72 < 0.80 (threshold)
856
-
857
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
858
-
859
- 🔄 **Attempt 2/3**: Refining with feedback...
860
-
861
- ✅ PM Agent completed (with feedback)
862
- 🔍 Validating output...
863
-
864
- Validation Results:
865
- Rule-based: ✅ 47/47 passed
866
- Quality Score: 0.85/1.00 ✓ (Improved!)
867
-
868
- Issues Found:
869
- • MINOR: Performance requirements could be more specific
870
- Location: Section "Non-functional Requirements"
871
- Suggestion: Add p95/p99 latency targets
305
+ ---
872
306
 
873
- Score: 0.85 > 0.80 (threshold) ✅
307
+ ## Progress Tracking
874
308
 
875
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
309
+ ### Real-Time Updates
876
310
 
877
- **Final Result**: Requirements validated (0.85/1.00)
311
+ Show user current phase and progress:
312
+ ```
313
+ 🚀 Building SaaS for Event Management
878
314
 
879
- Improvements made:
880
- ✓ Acceptance criteria now measurable
881
- ✓ Rate limiting specified (5 attempts, 15min lockout)
882
- ✓ Testable success metrics added
315
+ Progress: 3/8 phases complete (37.5%)
883
316
 
884
- Minor issues remaining (can be addressed later):
885
- Performance requirements (p95/p99 targets)
317
+ Phase 1: Requirements (PM) - COMPLETE
318
+ Phase 2: Architecture (Architect) - COMPLETE
319
+ ✅ Phase 3: Technical Planning (Tech Lead) - COMPLETE
320
+ 🔄 Phase 4: Implementation (Backend + Frontend) - IN PROGRESS
321
+ ⏳ Phase 5: QA - PENDING
322
+ ⏳ Phase 6: Security Review - PENDING
323
+ ⏳ Phase 7: DevOps - PENDING
324
+ ⏳ Phase 8: Deployment - PENDING
886
325
 
887
- Proceeding to architecture phase...
326
+ Current: Backend implementing user authentication (T-015/45)
888
327
  ```
889
328
 
890
- ### Configuration for Feedback Loops
329
+ ---
891
330
 
331
+ ## Example Workflows
892
332
 
333
+ ### Example 1: Build SaaS Product
893
334
 
894
- ### Gate Failure Handling
335
+ **User request**: "Build a SaaS for event management"
895
336
 
896
- ```typescript
897
- async function handleGateFailure(gate: QualityGate): Promise<void> {
898
- switch (gate.type) {
899
- case 'test_pass':
900
- // Route to QA Lead for analysis
901
- await invokeAgent('qa-lead-agent', 'Analyze test failures');
902
- // Then route to appropriate implementation agent
903
- break;
904
-
905
- case 'security_review':
906
- // Route to Security Agent for details
907
- await invokeAgent('security-agent', 'Detail security issues');
908
- // Create work items for fixes
909
- break;
910
-
911
- case 'performance_target':
912
- // Route to Tech Lead for optimization strategy
913
- await invokeAgent('tech-lead-agent', 'Performance optimization plan');
914
- break;
915
-
916
- case 'user_approval':
917
- // Notify user, wait for feedback
918
- await notifyUser(gate);
919
- await waitForUserApproval(gate);
920
- break;
921
- }
922
- }
337
+ **Orchestrator response**:
923
338
  ```
339
+ 🎯 Creating increment for Event Management SaaS
924
340
 
925
- ## Monitoring & Observability
341
+ Created: .specweave/increments/0001-event-management/
926
342
 
927
- ### Progress Tracking
343
+ 📋 8-Phase Workflow:
928
344
 
929
- ```typescript
930
- interface OrchestrationMetrics {
931
- total_phases: number;
932
- completed_phases: number;
933
- agents_invoked: Record<string, number>;
934
- gates_passed: number;
935
- gates_failed: number;
936
- execution_time: number;
937
- estimated_time_remaining: number;
938
- }
345
+ Phase 1: Requirements & Strategy
346
+ Tell Claude: "Complete spec for increment 0001"
347
+ PM will define user stories, features, success criteria
939
348
 
940
- function trackProgress(state: ExecutionState): OrchestrationMetrics {
941
- // Calculate metrics
942
- // Store in .specweave/orchestration/metrics.json
943
- // Display to user
944
- }
945
- ```
349
+ Phase 2: System Architecture
350
+ Tell Claude: "Design architecture for increment 0001"
351
+ Architect will create system design and ADRs
946
352
 
947
- ### User Visibility
353
+ Phase 3: Technical Planning
354
+ Tell Claude: "Create technical plan for increment 0001"
355
+ → Tech Lead will plan implementation approach
948
356
 
949
- Provide clear progress updates:
357
+ Phase 4: Test Strategy
358
+ Tell Claude: "Create test strategy for increment 0001"
359
+ → QA Lead will define testing approach
950
360
 
951
- ```markdown
952
- 🔷 SpecWeave Multi-Agent Orchestration Active
361
+ Phase 5: Backend Implementation
362
+ Tell Claude: "Implement backend for increment 0001"
363
+ → Backend agent will build APIs and services
953
364
 
954
- **Task**: Build E-Commerce Platform
955
- **Progress**: Phase 3 of 6 (Implementation)
365
+ Phase 6: Frontend Implementation
366
+ Tell Claude: "Implement frontend for increment 0001"
367
+ → Frontend agent will build UI
956
368
 
957
- Phase 1: Requirements (PM Agent) - Complete
958
- Phase 2: Architecture (Architect Agent) - Complete
959
- 🔄 Phase 3: Implementation - In Progress
960
- ├─ Backend (nodejs-backend): 65% complete
961
- └─ Frontend (frontend-agent): 45% complete
962
- ⏳ Phase 4: Testing (QA Lead) - Waiting
963
- ⏳ Phase 5: Security Review - Waiting
964
- ⏳ Phase 6: Deployment - Waiting
369
+ Phase 7: Security Review
370
+ Tell Claude: "Review security for increment 0001"
371
+ Security agent will validate security
965
372
 
966
- **Quality Gates**:
967
- Architecture Review: Passed
968
- Test Coverage (Target: >80%): Currently 67%
969
- ⏳ Security Review: Pending
373
+ Phase 8: Deployment Setup
374
+ Tell Claude: "Setup deployment for increment 0001"
375
+ DevOps agent will create infrastructure
970
376
 
971
- **Estimated Time Remaining**: 2-3 hours
377
+ Start with Phase 1!
972
378
  ```
973
379
 
974
- ## Integration with Other Skills
380
+ ### Example 2: Critical Hotfix
975
381
 
976
- ### Skill Invocation
382
+ **User request**: "Fix critical security vulnerability CVE-2024-1234"
977
383
 
978
- ```typescript
979
- // role-orchestrator can invoke any other skill
980
- async function invokeSkill(skillName: string, task: string, context: any) {
981
- // Load skill context
982
- const skillContext = await loadSkillContext(skillName);
983
-
984
- // Merge with orchestration context
985
- const mergedContext = {
986
- ...context,
987
- ...skillContext,
988
- orchestration: {
989
- coordinator: 'role-orchestrator',
990
- phase: context.current_phase,
991
- task_id: generateTaskId()
992
- }
993
- };
994
-
995
- // Invoke skill
996
- const result = await executeSkill(skillName, task, mergedContext);
997
-
998
- // Store result in shared memory
999
- await storeResult(skillName, result);
1000
-
1001
- return result;
1002
- }
384
+ **Orchestrator response**:
1003
385
  ```
386
+ 🚨 CRITICAL HOTFIX WORKFLOW
1004
387
 
1005
- ### Called By
1006
-
1007
- - **specweave-detector**: For complex multi-agent requests
1008
- - **skill-router**: When complexity analysis indicates >3 agents needed
388
+ Created: .specweave/increments/0016-security-fix-cve-2024-1234/
389
+ Type: hotfix (expedited workflow)
1009
390
 
1010
- ### Calls
391
+ 4-Phase Fast Track:
1011
392
 
1012
- - All SpecWeave agent skills (pm-agent, architect-agent, etc.)
1013
- - SpecWeave utility skills (context-loader, docs-updater, etc.)
393
+ Phase 1: Security Assessment (5 min)
394
+ Tell Claude: "Assess security vulnerability for increment 0016"
1014
395
 
1015
- ## Configuration
396
+ Phase 2: Fix Implementation (15 min)
397
+ Tell Claude: "Implement security fix for increment 0016"
1016
398
 
399
+ Phase 3: Validation (10 min)
400
+ Tell Claude: "Validate security fix for increment 0016"
1017
401
 
402
+ Phase 4: Emergency Deploy (5 min)
403
+ Tell Claude: "Deploy hotfix for increment 0016"
1018
404
 
1019
- ## Testing
1020
-
1021
- ### Test Cases
1022
-
1023
- **TC-001: Simple Product Development**
1024
- - Given: User requests "Build a todo app"
1025
- - When: role-orchestrator analyzes request
1026
- - Then: Invokes PM → Architect → Backend → Frontend → QA → DevOps
1027
- - And: All phases complete successfully
1028
-
1029
- **TC-002: Parallel Execution**
1030
- - Given: User requests "Implement payment feature"
1031
- - When: Implementation phase starts
1032
- - Then: Backend and Frontend agents run in parallel
1033
- - And: Both complete without conflicts
1034
-
1035
- **TC-003: Quality Gate Failure**
1036
- - Given: Test coverage is 65% (target: >80%)
1037
- - When: QA gate evaluates
1038
- - Then: Gate fails, blocks deployment
1039
- - And: Routes to QA Lead for analysis
1040
-
1041
- **TC-004: Security Gate**
1042
- - Given: Security review finds critical vulnerability
1043
- - When: Security gate evaluates
1044
- - Then: Blocks deployment
1045
- - And: Creates work items for security fixes
405
+ Total estimated time: 35 minutes
406
+ ```
1046
407
 
1047
- **TC-005: Brownfield Integration**
1048
- - Given: Existing codebase needs new feature
1049
- - When: role-orchestrator receives request
1050
- - Then: Starts with Tech Lead analysis
1051
- - And: Creates regression tests before modification
408
+ ---
1052
409
 
1053
410
  ## Best Practices
1054
411
 
1055
- ### 1. Clear Phase Boundaries
1056
-
1057
- Each phase should have:
1058
- - Clear inputs
1059
- - Clear outputs
1060
- - Success criteria
1061
- - Failure handling
1062
-
1063
- ### 2. Explicit Dependencies
1064
-
1065
- Always declare:
1066
- - Which phases depend on which
1067
- - What artifacts are required
1068
- - What approvals are needed
412
+ **✅ DO**:
413
+ - Create increment structure FIRST
414
+ - Guide user through sequential workflow
415
+ - Use quality gates between phases
416
+ - Track progress and show user updates
417
+ - Handle errors gracefully with retry
418
+ - Allow user to skip optional phases
419
+
420
+ **❌ DON'T**:
421
+ - Spawn all agents at once (context explosion)
422
+ - Skip increment creation
423
+ - Proceed without quality gate checks
424
+ - Fail silently on agent errors
425
+ - Assume agents are infallible
426
+ - Block user from manual intervention
1069
427
 
1070
- ### 3. Quality Gates at Key Points
1071
-
1072
- Insert gates:
1073
- - After architecture decisions
1074
- - Before implementation
1075
- - After implementation (tests)
1076
- - Before deployment
1077
-
1078
- ### 4. User Visibility
1079
-
1080
- Keep users informed:
1081
- - Show current phase
1082
- - Display progress percentage
1083
- - Estimate time remaining
1084
- - Highlight blockers
428
+ ---
1085
429
 
1086
- ### 5. Graceful Degradation
430
+ ## Integration with SpecWeave Commands
1087
431
 
1088
- If an agent fails:
1089
- - Retry with backoff
1090
- - Try fallback agent
1091
- - If critical, pause and notify user
1092
- - Don't fail silently
432
+ **After orchestration complete**:
1093
433
 
1094
- ## Resources
434
+ ```bash
435
+ # Check status
436
+ /specweave:status
1095
437
 
1096
- ### Multi-Agent Systems Research
1097
- - [Microsoft Autogen](https://microsoft.github.io/autogen/) - Multi-agent conversation framework
1098
- - [LangGraph Multi-Agent](https://blog.langchain.com/langgraph-multi-agent-workflows/) - LangChain's orchestration
1099
- - [CrewAI](https://www.crewai.io/) - Role-based agent collaboration
1100
- - [Amazon Bedrock Multi-Agent](https://aws.amazon.com/blogs/machine-learning/design-multi-agent-orchestration-with-reasoning-using-amazon-bedrock-and-open-source-frameworks/) - AWS multi-agent patterns
438
+ # Sync to external tools
439
+ /specweave:sync-progress 0001
1101
440
 
1102
- ### Orchestration Patterns
1103
- - [Azure AI Agent Patterns](https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/ai-agent-design-patterns) - Microsoft's agent design patterns
1104
- - [Orchestrator-Worker Pattern](https://www.confluent.io/blog/event-driven-multi-agent-systems/) - Event-driven multi-agent systems
441
+ # Validate quality
442
+ /specweave:qa 0001
1105
443
 
1106
- ### Quality Gates
1107
- - [Shift-Left Testing](https://www.atlassian.com/continuous-delivery/software-testing/shift-left-testing) - Early quality gates
1108
- - [DORA Metrics](https://cloud.google.com/blog/products/devops-sre/using-the-four-keys-to-measure-your-devops-performance) - Deployment quality metrics
444
+ # Close increment
445
+ /specweave:done 0001
446
+ ```
1109
447
 
1110
448
  ---
1111
449
 
1112
- ## Summary
1113
-
1114
- The **role-orchestrator** skill is the **central nervous system** of SpecWeave's multi-agent architecture:
1115
-
1116
- ✅ Coordinates 10+ specialized agents
1117
- ✅ Implements hierarchical orchestrator-worker pattern
1118
- ✅ Supports sequential, parallel, and adaptive workflows
1119
- ✅ Enforces quality gates at critical points
1120
- ✅ Provides real-time progress tracking
1121
- ✅ Handles failures gracefully with retry and fallback
1122
- ✅ Enables complex product development with AI agents
1123
-
1124
- **User benefit**: Submit complex requests like "Build a SaaS" and watch multiple AI agents collaborate seamlessly to deliver the complete solution, from requirements to deployment.
1125
-
1126
- This is the **factory of agents** that makes SpecWeave a true AI-powered development framework.
450
+ **This skill is self-contained and works in ANY user project after `specweave init`.**