aiblueprint-cli 1.4.12 → 1.4.13

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 (54) hide show
  1. package/claude-code-config/scripts/.claude/commands/fix-on-my-computer.md +87 -0
  2. package/claude-code-config/scripts/command-validator/CLAUDE.md +112 -0
  3. package/claude-code-config/scripts/command-validator/src/__tests__/validator.test.ts +62 -111
  4. package/claude-code-config/scripts/command-validator/src/cli.ts +5 -3
  5. package/claude-code-config/scripts/command-validator/src/lib/security-rules.ts +3 -4
  6. package/claude-code-config/scripts/command-validator/src/lib/types.ts +1 -0
  7. package/claude-code-config/scripts/command-validator/src/lib/validator.ts +47 -317
  8. package/claude-code-config/scripts/statusline/CLAUDE.md +29 -7
  9. package/claude-code-config/scripts/statusline/README.md +89 -1
  10. package/claude-code-config/scripts/statusline/defaults.json +75 -0
  11. package/claude-code-config/scripts/statusline/src/index.ts +101 -24
  12. package/claude-code-config/scripts/statusline/src/lib/config-types.ts +100 -0
  13. package/claude-code-config/scripts/statusline/src/lib/config.ts +21 -0
  14. package/claude-code-config/scripts/statusline/src/lib/context.ts +32 -11
  15. package/claude-code-config/scripts/statusline/src/lib/formatters.ts +360 -22
  16. package/claude-code-config/scripts/statusline/src/lib/git.ts +100 -0
  17. package/claude-code-config/scripts/statusline/src/lib/render-pure.ts +177 -0
  18. package/claude-code-config/scripts/statusline/src/lib/types.ts +11 -0
  19. package/claude-code-config/scripts/statusline/statusline.config.json +93 -0
  20. package/claude-code-config/skills/claude-memory/SKILL.md +689 -0
  21. package/claude-code-config/skills/claude-memory/references/comprehensive-example.md +175 -0
  22. package/claude-code-config/skills/claude-memory/references/project-patterns.md +334 -0
  23. package/claude-code-config/skills/claude-memory/references/prompting-techniques.md +411 -0
  24. package/claude-code-config/skills/claude-memory/references/section-templates.md +347 -0
  25. package/claude-code-config/skills/create-slash-commands/SKILL.md +1110 -0
  26. package/claude-code-config/skills/create-slash-commands/references/arguments.md +273 -0
  27. package/claude-code-config/skills/create-slash-commands/references/patterns.md +947 -0
  28. package/claude-code-config/skills/create-slash-commands/references/prompt-examples.md +656 -0
  29. package/claude-code-config/skills/create-slash-commands/references/tool-restrictions.md +389 -0
  30. package/claude-code-config/skills/create-subagents/SKILL.md +425 -0
  31. package/claude-code-config/skills/create-subagents/references/context-management.md +567 -0
  32. package/claude-code-config/skills/create-subagents/references/debugging-agents.md +714 -0
  33. package/claude-code-config/skills/create-subagents/references/error-handling-and-recovery.md +502 -0
  34. package/claude-code-config/skills/create-subagents/references/evaluation-and-testing.md +374 -0
  35. package/claude-code-config/skills/create-subagents/references/orchestration-patterns.md +591 -0
  36. package/claude-code-config/skills/create-subagents/references/subagents.md +599 -0
  37. package/claude-code-config/skills/create-subagents/references/writing-subagent-prompts.md +513 -0
  38. package/package.json +1 -1
  39. package/claude-code-config/commands/apex.md +0 -109
  40. package/claude-code-config/commands/tasks/run-task.md +0 -220
  41. package/claude-code-config/commands/utils/watch-ci.md +0 -47
  42. package/claude-code-config/scripts/command-validator/biome.json +0 -29
  43. package/claude-code-config/scripts/command-validator/bun.lockb +0 -0
  44. package/claude-code-config/scripts/command-validator/package.json +0 -27
  45. package/claude-code-config/scripts/command-validator/vitest.config.ts +0 -7
  46. package/claude-code-config/scripts/hook-post-file.ts +0 -162
  47. package/claude-code-config/scripts/statusline/biome.json +0 -34
  48. package/claude-code-config/scripts/statusline/bun.lockb +0 -0
  49. package/claude-code-config/scripts/statusline/fixtures/test-input.json +0 -25
  50. package/claude-code-config/scripts/statusline/package.json +0 -19
  51. package/claude-code-config/scripts/statusline/statusline.config.ts +0 -25
  52. package/claude-code-config/scripts/statusline/test.ts +0 -20
  53. package/claude-code-config/scripts/validate-command.js +0 -712
  54. package/claude-code-config/scripts/validate-command.readme.md +0 -283
@@ -0,0 +1,591 @@
1
+ # Orchestration Patterns for Multi-Agent Systems
2
+
3
+ <core_concept>
4
+ Orchestration defines how multiple subagents coordinate to complete complex tasks.
5
+
6
+ **Single agent**: Sequential execution within one context.
7
+ **Multi-agent**: Coordination between multiple specialized agents, each with focused expertise.
8
+ </core_concept>
9
+
10
+ <pattern_catalog>
11
+
12
+
13
+ <sequential>
14
+ **Sequential pattern**: Agents chained in predefined, linear order.
15
+
16
+ <characteristics>
17
+ - Each agent processes output from previous agent
18
+ - Pipeline of specialized transformations
19
+ - Deterministic flow (A → B → C)
20
+ - Easy to reason about and debug
21
+ </characteristics>
22
+
23
+ <when_to_use>
24
+ **Ideal for**:
25
+ - Document review workflows (security → performance → style)
26
+ - Data processing pipelines (extract → transform → validate → load)
27
+ - Multi-stage reasoning (research → analyze → synthesize → recommend)
28
+
29
+ **Example**:
30
+ ```markdown
31
+ Task: Comprehensive code review
32
+
33
+ Flow:
34
+ 1. security-reviewer: Check for vulnerabilities
35
+ ↓ (security report)
36
+ 2. performance-analyzer: Identify performance issues
37
+ ↓ (performance report)
38
+ 3. test-coverage-checker: Assess test coverage
39
+ ↓ (coverage report)
40
+ 4. report-synthesizer: Combine all findings into actionable review
41
+ ```
42
+ </when_to_use>
43
+
44
+ <implementation>
45
+ ```markdown
46
+ <sequential_workflow>
47
+ Main chat orchestrates:
48
+ 1. Launch security-reviewer with code changes
49
+ 2. Wait for security report
50
+ 3. Launch performance-analyzer with code changes + security report context
51
+ 4. Wait for performance report
52
+ 5. Launch test-coverage-checker with code changes
53
+ 6. Wait for coverage report
54
+ 7. Synthesize all reports for user
55
+ </sequential_workflow>
56
+ ```
57
+
58
+ **Benefits**: Clear dependencies, each stage builds on previous.
59
+ **Drawbacks**: Slower than parallel (sequential latency), one failure blocks pipeline.
60
+ </implementation>
61
+ </sequential>
62
+
63
+ <parallel>
64
+ **Parallel/Concurrent pattern**: Multiple specialized subagents perform tasks simultaneously.
65
+
66
+ <characteristics>
67
+ - Agents execute independently and concurrently
68
+ - Outputs synthesized for final response
69
+ - Significant speed improvements
70
+ - Requires synchronization
71
+ </characteristics>
72
+
73
+ <when_to_use>
74
+ **Ideal for**:
75
+ - Independent analyses of same input (security + performance + quality)
76
+ - Processing multiple independent items (review multiple files)
77
+ - Research tasks (gather information from multiple sources)
78
+
79
+ **Performance data**: Anthropic's research system with 3-5 subagents in parallel achieved 90% time reduction.
80
+
81
+ **Example**:
82
+ ```markdown
83
+ Task: Comprehensive code review (parallel approach)
84
+
85
+ Launch simultaneously:
86
+ - security-reviewer (analyzes auth.ts)
87
+ - performance-analyzer (analyzes auth.ts)
88
+ - test-coverage-checker (analyzes auth.ts test coverage)
89
+
90
+ Wait for all three to complete → synthesize findings.
91
+
92
+ Time: max(agent_1, agent_2, agent_3) vs sequential: agent_1 + agent_2 + agent_3
93
+ ```
94
+ </when_to_use>
95
+
96
+ <implementation>
97
+ ```markdown
98
+ <parallel_workflow>
99
+ Main chat orchestrates:
100
+ 1. Launch all agents simultaneously with same context
101
+ 2. Collect outputs as they complete
102
+ 3. Synthesize results when all complete
103
+
104
+ Synchronization challenges:
105
+ - Handling different completion times
106
+ - Dealing with partial failures (some agents fail, others succeed)
107
+ - Combining potentially conflicting outputs
108
+ </parallel_workflow>
109
+ ```
110
+
111
+ **Benefits**: Massive speed improvement, efficient resource utilization.
112
+ **Drawbacks**: Increased complexity, synchronization challenges, higher cost (multiple agents running).
113
+ </implementation>
114
+ </parallel>
115
+
116
+ <hierarchical>
117
+ **Hierarchical pattern**: Agents organized in layers, higher-level agents oversee lower-level.
118
+
119
+ <characteristics>
120
+ - Tree-like structure with delegation
121
+ - Higher-level agents break down tasks
122
+ - Lower-level agents execute specific subtasks
123
+ - Master-worker relationships
124
+ </characteristics>
125
+
126
+ <when_to_use>
127
+ **Ideal for**:
128
+ - Large, complex problems requiring decomposition
129
+ - Tasks with natural hierarchy (system design → component design → implementation)
130
+ - Situations requiring oversight and quality control
131
+
132
+ **Example**:
133
+ ```markdown
134
+ Task: Implement complete authentication system
135
+
136
+ Hierarchy:
137
+ - architect (top-level): Designs overall auth system, breaks into components
138
+ ↓ delegates to:
139
+ - backend-dev: Implements API endpoints
140
+ - frontend-dev: Implements login UI
141
+ - security-reviewer: Reviews both for vulnerabilities
142
+ - test-writer: Creates integration tests
143
+ ↑ reports back to:
144
+ - architect: Integrates components, ensures coherence
145
+ ```
146
+ </when_to_use>
147
+
148
+ <implementation>
149
+ ```markdown
150
+ <hierarchical_workflow>
151
+ Top-level agent (architect):
152
+ 1. Analyze requirements
153
+ 2. Break into subtasks
154
+ 3. Delegate to specialized agents
155
+ 4. Monitor progress
156
+ 5. Integrate results
157
+ 6. Validate coherence across components
158
+
159
+ Lower-level agents:
160
+ - Receive focused subtask
161
+ - Execute with deep expertise
162
+ - Report results to coordinator
163
+ - No awareness of other agents' work
164
+ </hierarchical_workflow>
165
+ ```
166
+
167
+ **Benefits**: Handles complexity through decomposition, clear responsibility boundaries.
168
+ **Drawbacks**: Overhead in coordination, risk of misalignment between levels.
169
+ </implementation>
170
+ </hierarchical>
171
+
172
+ <coordinator>
173
+ **Coordinator pattern**: Central LLM agent routes tasks to specialized sub-agents.
174
+
175
+ <characteristics>
176
+ - Central decision-maker
177
+ - Dynamic routing (not hardcoded workflow)
178
+ - AI model orchestrates based on task characteristics
179
+ - Similar to hierarchical but focused on process flow
180
+ </characteristics>
181
+
182
+ <when_to_use>
183
+ **Ideal for**:
184
+ - Diverse task types requiring different expertise
185
+ - Dynamic workflows where next step depends on results
186
+ - User-facing systems with varied requests
187
+
188
+ **Example**:
189
+ ```markdown
190
+ Task: "Help me improve my codebase"
191
+
192
+ Coordinator analyzes request → determines relevant agents:
193
+ - code-quality-analyzer: Assess overall code quality
194
+ ↓ findings suggest security issues
195
+ - Coordinator: Route to security-reviewer
196
+ ↓ security issues found
197
+ - Coordinator: Route to auto-fixer to generate patches
198
+ ↓ patches ready
199
+ - Coordinator: Route to test-writer to create tests for fixes
200
+
201
+ - Coordinator: Synthesize all work into improvement plan
202
+ ```
203
+
204
+ **Dynamic routing** based on intermediate results, not predefined flow.
205
+ </when_to_use>
206
+
207
+ <implementation>
208
+ ```markdown
209
+ <coordinator_workflow>
210
+ Coordinator agent prompt:
211
+
212
+ <role>
213
+ You are an orchestration coordinator. Route tasks to specialized agents based on:
214
+ - Task characteristics
215
+ - Available agents and their capabilities
216
+ - Results from previous agents
217
+ - User goals
218
+ </role>
219
+
220
+ <available_agents>
221
+ - security-reviewer: Security analysis
222
+ - performance-analyzer: Performance optimization
223
+ - test-writer: Test creation
224
+ - debugger: Bug investigation
225
+ - refactorer: Code improvement
226
+ </available_agents>
227
+
228
+ <decision_process>
229
+ 1. Analyze incoming task
230
+ 2. Identify relevant agents (may be multiple)
231
+ 3. Determine execution strategy (sequential, parallel, conditional)
232
+ 4. Launch agents with appropriate context
233
+ 5. Analyze results
234
+ 6. Decide next step (more agents, synthesis, completion)
235
+ 7. Repeat until task complete
236
+ </decision_process>
237
+ ```
238
+
239
+ **Benefits**: Flexible, adaptive to task requirements, efficient agent utilization.
240
+ **Drawbacks**: Coordinator is single point of failure, complexity in routing logic.
241
+ </implementation>
242
+ </coordinator>
243
+
244
+ <orchestrator_worker>
245
+ **Orchestrator-Worker pattern**: Central orchestrator assigns tasks, manages execution.
246
+
247
+ <characteristics>
248
+ - Centralized coordination with distributed execution
249
+ - Workers focus on specific, independent tasks
250
+ - Similar to distributed computing master-worker pattern
251
+ - Clear separation of planning (orchestrator) and execution (workers)
252
+ </characteristics>
253
+
254
+ <when_to_use>
255
+ **Ideal for**:
256
+ - Batch processing (process 100 files)
257
+ - Independent tasks that can be distributed (analyze multiple API endpoints)
258
+ - Load balancing across workers
259
+
260
+ **Example**:
261
+ ```markdown
262
+ Task: Security review of 50 microservices
263
+
264
+ Orchestrator:
265
+ 1. Identifies all 50 services
266
+ 2. Breaks into batches of 5
267
+ 3. Assigns batches to worker agents
268
+ 4. Monitors progress
269
+ 5. Aggregates results
270
+
271
+ Workers (5 concurrent instances of security-reviewer):
272
+ - Each reviews assigned services
273
+ - Reports findings to orchestrator
274
+ - Independent execution (no inter-worker communication)
275
+ ```
276
+ </when_to_use>
277
+
278
+ <sonnet_haiku_orchestration>
279
+ **Sonnet 4.5 + Haiku 4.5 orchestration**: Optimal cost/performance pattern.
280
+
281
+ Research findings:
282
+ - Sonnet 4.5: "Best model in the world for agents", exceptional at planning and validation
283
+ - Haiku 4.5: "90% of Sonnet 4.5 performance", one of best coding models, fast and cost-efficient
284
+
285
+ **Pattern**:
286
+ ```markdown
287
+ 1. Sonnet 4.5 (Orchestrator):
288
+ - Analyzes task
289
+ - Creates plan
290
+ - Breaks into subtasks
291
+ - Identifies what can be parallelized
292
+
293
+ 2. Multiple Haiku 4.5 instances (Workers):
294
+ - Each completes assigned subtask
295
+ - Executes in parallel for speed
296
+ - Returns results to orchestrator
297
+
298
+ 3. Sonnet 4.5 (Orchestrator):
299
+ - Integrates results from all workers
300
+ - Validates output quality
301
+ - Ensures coherence
302
+ - Delivers final output
303
+ ```
304
+
305
+ **Cost/performance optimization**: Expensive Sonnet only for planning/validation, cheap Haiku for execution.
306
+ </sonnet_haiku_orchestration>
307
+ </orchestrator_worker>
308
+ </pattern_catalog>
309
+
310
+ <hybrid_approaches>
311
+
312
+
313
+ Real-world systems often combine patterns for different workflow phases.
314
+
315
+ <example name="sequential_then_parallel">
316
+ **Sequential for initial processing → Parallel for analysis**:
317
+
318
+ ```markdown
319
+ Task: Comprehensive feature implementation review
320
+
321
+ Sequential phase:
322
+ 1. requirements-validator: Check requirements completeness
323
+
324
+ 2. implementation-reviewer: Verify feature implemented correctly
325
+
326
+
327
+ Parallel phase (once implementation validated):
328
+ 3. Launch simultaneously:
329
+ - security-reviewer
330
+ - performance-analyzer
331
+ - accessibility-checker
332
+ - test-coverage-validator
333
+
334
+
335
+ Sequential synthesis:
336
+ 4. report-generator: Combine all findings
337
+ ```
338
+
339
+ **Rationale**: Early stages have dependencies (can't validate implementation before requirements), later stages are independent analyses.
340
+ </example>
341
+
342
+ <example name="coordinator_with_hierarchy">
343
+ **Coordinator orchestrating hierarchical teams**:
344
+
345
+ ```markdown
346
+ Top level: Coordinator receives "Build payment system"
347
+
348
+ Coordinator creates hierarchical teams:
349
+
350
+ Team 1 (Backend):
351
+ - Lead: backend-architect
352
+ - Workers: api-developer, database-designer, integration-specialist
353
+
354
+ Team 2 (Frontend):
355
+ - Lead: frontend-architect
356
+ - Workers: ui-developer, state-management-specialist
357
+
358
+ Team 3 (DevOps):
359
+ - Lead: infra-architect
360
+ - Workers: deployment-specialist, monitoring-specialist
361
+
362
+ Coordinator:
363
+ - Manages team coordination
364
+ - Resolves inter-team dependencies
365
+ - Integrates deliverables
366
+ ```
367
+
368
+ **Benefit**: Combines dynamic routing (coordinator) with team structure (hierarchy).
369
+ </example>
370
+ </hybrid_approaches>
371
+
372
+ <implementation_guidance>
373
+
374
+
375
+ <coordinator_subagent>
376
+ **Example coordinator implementation**:
377
+
378
+ ```markdown
379
+ ---
380
+ name: workflow-coordinator
381
+ description: Orchestrates multi-agent workflows. Use when task requires multiple specialized agents in coordination.
382
+ tools: all
383
+ model: sonnet
384
+ ---
385
+
386
+ <role>
387
+ You are a workflow coordinator. Analyze tasks, identify required agents, orchestrate their execution.
388
+ </role>
389
+
390
+ <available_agents>
391
+ {list of specialized agents with capabilities}
392
+ </available_agents>
393
+
394
+ <orchestration_strategies>
395
+ **Sequential**: When agents depend on each other's outputs
396
+ **Parallel**: When agents can work independently
397
+ **Hierarchical**: When task needs decomposition with oversight
398
+ **Adaptive**: Choose pattern based on task characteristics
399
+ </orchestration_strategies>
400
+
401
+ <workflow>
402
+ 1. Analyze incoming task
403
+ 2. Identify required capabilities
404
+ 3. Select agents and pattern
405
+ 4. Launch agents (sequentially or parallel as appropriate)
406
+ 5. Monitor execution
407
+ 6. Handle errors (retry, fallback, escalate)
408
+ 7. Integrate results
409
+ 8. Validate coherence
410
+ 9. Deliver final output
411
+ </workflow>
412
+
413
+ <error_handling>
414
+ If agent fails:
415
+ - Retry with refined context (1-2 attempts)
416
+ - Try alternative agent if available
417
+ - Proceed with partial results if acceptable
418
+ - Escalate to human if critical
419
+ </error_handling>
420
+ ```
421
+ </coordinator_subagent>
422
+
423
+ <handoff_protocol>
424
+ **Clean handoffs between agents**:
425
+
426
+ ```markdown
427
+ <agent_handoff_format>
428
+ From: {source_agent}
429
+ To: {target_agent}
430
+ Task: {specific task}
431
+ Context:
432
+ - What was done: {summary of prior work}
433
+ - Key findings: {important discoveries}
434
+ - Constraints: {limitations or requirements}
435
+ - Expected output: {what target agent should produce}
436
+
437
+ Attachments:
438
+ - {relevant files, data, or previous outputs}
439
+ </agent_handoff_format>
440
+ ```
441
+
442
+ **Why explicit format matters**: Prevents information loss, ensures target agent has full context, enables validation.
443
+ </handoff_protocol>
444
+
445
+ <synchronization>
446
+ **Handling parallel execution**:
447
+
448
+ ```markdown
449
+ <parallel_synchronization>
450
+ Launch pattern:
451
+ 1. Initiate all parallel agents with shared context
452
+ 2. Track which agents have completed
453
+ 3. Collect outputs as they arrive
454
+ 4. Wait for all to complete OR timeout
455
+ 5. Proceed with available results (flag missing if timeout)
456
+
457
+ Partial failure handling:
458
+ - If 1 of 3 agents fails: Proceed with 2 results, note gap
459
+ - If 2 of 3 agents fail: Consider retry or workflow failure
460
+ - Always communicate what was completed vs attempted
461
+ </parallel_synchronization>
462
+ ```
463
+ </synchronization>
464
+ </implementation_guidance>
465
+
466
+ <anti_patterns>
467
+
468
+
469
+ <anti_pattern name="over_orchestration">
470
+ ❌ Using multiple agents when single agent would suffice
471
+
472
+ **Example**: Three agents to review 10 lines of code (overkill).
473
+
474
+ **Fix**: Reserve multi-agent for genuinely complex tasks. Single capable agent often better than coordinating multiple simple agents.
475
+ </anti_pattern>
476
+
477
+ <anti_pattern name="no_coordination">
478
+ ❌ Launching multiple agents with no coordination or synthesis
479
+
480
+ **Problem**: User gets conflicting reports, no coherent output, unclear which to trust.
481
+
482
+ **Fix**: Always synthesize multi-agent outputs into coherent final result.
483
+ </anti_pattern>
484
+
485
+ <anti_pattern name="sequential_when_parallel">
486
+ ❌ Running independent analyses sequentially
487
+
488
+ **Example**: Security review → performance review → quality review (each independent, done sequentially).
489
+
490
+ **Fix**: Parallel execution for independent tasks. 3x speed improvement in this case.
491
+ </anti_pattern>
492
+
493
+ <anti_pattern name="unclear_handoffs">
494
+ ❌ Agent outputs that don't provide sufficient context for next agent
495
+
496
+ **Example**:
497
+ ```markdown
498
+ Agent 1: "Found issues"
499
+ Agent 2: Receives "Found issues" with no details on what, where, or severity
500
+ Agent 2: Can't effectively act on vague input
501
+ ```
502
+
503
+ **Fix**: Structured handoff format with complete context.
504
+ </anti_pattern>
505
+
506
+ <anti_pattern name="no_error_recovery">
507
+ ❌ Orchestration with no fallback when agent fails
508
+
509
+ **Problem**: One agent failure causes entire workflow failure.
510
+
511
+ **Fix**: Graceful degradation, retry logic, alternative agents, partial results (see [error-handling-and-recovery.md](error-handling-and-recovery.md)).
512
+ </anti_pattern>
513
+ </anti_patterns>
514
+
515
+ <best_practices>
516
+
517
+
518
+ <principle name="right_granularity">
519
+ **Agent granularity**: Not too broad, not too narrow.
520
+
521
+ Too broad: "general-purpose-helper" (defeats purpose of specialization)
522
+ Too narrow: "checks-for-sql-injection-in-nodejs-express-apps-only" (too specific)
523
+ Right: "security-reviewer specializing in web application vulnerabilities"
524
+ </principle>
525
+
526
+ <principle name="clear_responsibilities">
527
+ **Each agent should have clear, non-overlapping responsibility**.
528
+
529
+ Bad: Two agents both "review code for quality" (overlap, confusion)
530
+ Good: "security-reviewer" + "performance-analyzer" (distinct concerns)
531
+ </principle>
532
+
533
+ <principle name="minimize_handoffs">
534
+ **Minimize information loss at boundaries**.
535
+
536
+ Each handoff is opportunity for context loss. Structured handoff formats prevent this.
537
+ </principle>
538
+
539
+ <principle name="parallel_where_possible">
540
+ **Parallelize independent work**.
541
+
542
+ If agents don't depend on each other's outputs, run them concurrently.
543
+ </principle>
544
+
545
+ <principle name="coordinator_lightweight">
546
+ **Keep coordinator logic lightweight**.
547
+
548
+ Heavy coordinator = bottleneck. Coordinator should route and synthesize, not do deep work itself.
549
+ </principle>
550
+
551
+ <principle name="cost_optimization">
552
+ **Use model tiers strategically**.
553
+
554
+ - Planning/validation: Sonnet 4.5 (needs intelligence)
555
+ - Execution of clear tasks: Haiku 4.5 (fast, cheap, still capable)
556
+ - Highest stakes decisions: Sonnet 4.5
557
+ - Bulk processing: Haiku 4.5
558
+ </principle>
559
+ </best_practices>
560
+
561
+ <pattern_selection>
562
+
563
+
564
+ <decision_tree>
565
+ ```markdown
566
+ Is task decomposable into independent subtasks?
567
+ ├─ Yes: Parallel pattern (fastest)
568
+ └─ No: ↓
569
+
570
+ Do subtasks depend on each other's outputs?
571
+ ├─ Yes: Sequential pattern (clear dependencies)
572
+ └─ No: ↓
573
+
574
+ Is task large/complex requiring decomposition AND oversight?
575
+ ├─ Yes: Hierarchical pattern (structured delegation)
576
+ └─ No: ↓
577
+
578
+ Do task requirements vary dynamically?
579
+ ├─ Yes: Coordinator pattern (adaptive routing)
580
+ └─ No: Single agent sufficient
581
+ ```
582
+ </decision_tree>
583
+
584
+ <performance_vs_complexity>
585
+ **Performance**: Parallel > Hierarchical > Sequential > Coordinator (overhead)
586
+ **Complexity**: Coordinator > Hierarchical > Parallel > Sequential
587
+ **Flexibility**: Coordinator > Hierarchical > Parallel > Sequential
588
+
589
+ **Trade-off**: Choose simplest pattern that meets requirements.
590
+ </performance_vs_complexity>
591
+ </pattern_selection>