@givolt/i3-composer-agent 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/.agents/plugins/marketplace.json +23 -0
  2. package/.claude/commands/build.md +44 -0
  3. package/.claude/commands/code-simplify.md +22 -0
  4. package/.claude/commands/constraints.md +32 -0
  5. package/.claude/commands/plan.md +18 -0
  6. package/.claude/commands/review.md +16 -0
  7. package/.claude/commands/ship.md +72 -0
  8. package/.claude/commands/spec.md +17 -0
  9. package/.claude/commands/test.md +19 -0
  10. package/.claude/commands/webperf.md +32 -0
  11. package/.claude-plugin/marketplace.json +27 -0
  12. package/.claude-plugin/plugin.json +19 -0
  13. package/.codex-plugin/plugin.json +28 -0
  14. package/.gemini/commands/build.toml +43 -0
  15. package/.gemini/commands/code-simplify.toml +22 -0
  16. package/.gemini/commands/constraints.toml +32 -0
  17. package/.gemini/commands/planning.toml +18 -0
  18. package/.gemini/commands/review.toml +16 -0
  19. package/.gemini/commands/ship.toml +72 -0
  20. package/.gemini/commands/spec.toml +17 -0
  21. package/.gemini/commands/test.toml +19 -0
  22. package/.gemini/commands/webperf.toml +32 -0
  23. package/CHANGELOG.md +23 -0
  24. package/LICENSE +21 -0
  25. package/NOTICE.md +9 -0
  26. package/README.md +117 -2
  27. package/agents/code-reviewer.md +102 -0
  28. package/agents/security-auditor.md +112 -0
  29. package/agents/test-engineer.md +95 -0
  30. package/agents/web-performance-auditor.md +184 -0
  31. package/bin/i3-composer-agent.cjs +122 -0
  32. package/commands/build.toml +43 -0
  33. package/commands/code-simplify.toml +22 -0
  34. package/commands/constraints.toml +32 -0
  35. package/commands/planning.toml +18 -0
  36. package/commands/review.toml +16 -0
  37. package/commands/ship.toml +72 -0
  38. package/commands/spec.toml +17 -0
  39. package/commands/test.toml +19 -0
  40. package/commands/webperf.toml +32 -0
  41. package/docs/adoption-guide.md +129 -0
  42. package/docs/advanced-per-agent-configuration.md +70 -0
  43. package/docs/agents.md +123 -0
  44. package/docs/antigravity-setup.md +128 -0
  45. package/docs/codebuddy-setup.md +41 -0
  46. package/docs/codex-setup.md +34 -0
  47. package/docs/commandcode-setup.md +69 -0
  48. package/docs/comparison.md +131 -0
  49. package/docs/copilot-cli-setup.md +64 -0
  50. package/docs/copilot-setup.md +162 -0
  51. package/docs/cursor-setup.md +225 -0
  52. package/docs/developer-onboarding.md +116 -0
  53. package/docs/gemini-cli-setup.md +133 -0
  54. package/docs/getting-started.md +208 -0
  55. package/docs/opencode-setup.md +259 -0
  56. package/docs/other-hosts.md +7 -0
  57. package/docs/skill-anatomy.md +203 -0
  58. package/docs/windsurf-setup.md +48 -0
  59. package/evals/README.md +101 -0
  60. package/evals/cases/api-and-interface-design.json +45 -0
  61. package/evals/cases/browser-testing-with-devtools.json +44 -0
  62. package/evals/cases/ci-cd-and-automation.json +45 -0
  63. package/evals/cases/code-review-and-quality.json +49 -0
  64. package/evals/cases/code-simplification.json +45 -0
  65. package/evals/cases/constraint-driven-development.json +79 -0
  66. package/evals/cases/context-engineering.json +44 -0
  67. package/evals/cases/debugging-and-error-recovery.json +58 -0
  68. package/evals/cases/deprecation-and-migration.json +52 -0
  69. package/evals/cases/documentation-and-adrs.json +44 -0
  70. package/evals/cases/doubt-driven-development.json +43 -0
  71. package/evals/cases/frontend-ui-engineering.json +52 -0
  72. package/evals/cases/git-workflow-and-versioning.json +47 -0
  73. package/evals/cases/idea-refine.json +43 -0
  74. package/evals/cases/incremental-implementation.json +57 -0
  75. package/evals/cases/interview-me.json +42 -0
  76. package/evals/cases/observability-and-instrumentation.json +44 -0
  77. package/evals/cases/performance-optimization.json +53 -0
  78. package/evals/cases/planning-and-task-breakdown.json +45 -0
  79. package/evals/cases/security-and-hardening.json +53 -0
  80. package/evals/cases/shipping-and-launch.json +56 -0
  81. package/evals/cases/source-driven-development.json +44 -0
  82. package/evals/cases/spec-driven-development.json +72 -0
  83. package/evals/cases/test-driven-development.json +73 -0
  84. package/evals/cases/using-agent-skills.json +44 -0
  85. package/evals/fixtures/api-and-interface-design/service-brief.md +19 -0
  86. package/evals/fixtures/browser-testing-with-devtools/README.md +5 -0
  87. package/evals/fixtures/browser-testing-with-devtools/index.html +24 -0
  88. package/evals/fixtures/browser-testing-with-devtools/server.js +15 -0
  89. package/evals/fixtures/ci-cd-and-automation/package.json +8 -0
  90. package/evals/fixtures/ci-cd-and-automation/src/slug.js +3 -0
  91. package/evals/fixtures/ci-cd-and-automation/test/slug.test.js +9 -0
  92. package/evals/fixtures/code-review-and-quality/user-search.diff +16 -0
  93. package/evals/fixtures/code-simplification/config-parser.js +46 -0
  94. package/evals/fixtures/code-simplification/config-parser.test.js +15 -0
  95. package/evals/fixtures/context-engineering/context-audit.md +15 -0
  96. package/evals/fixtures/debugging-and-error-recovery/pagination.js +8 -0
  97. package/evals/fixtures/debugging-and-error-recovery/pagination.test.js +9 -0
  98. package/evals/fixtures/debugging-and-error-recovery/time-pressure.md +6 -0
  99. package/evals/fixtures/deprecation-and-migration/api-inventory.md +9 -0
  100. package/evals/fixtures/documentation-and-adrs/decision-context.md +16 -0
  101. package/evals/fixtures/doubt-driven-development/migration-plan.md +19 -0
  102. package/evals/fixtures/frontend-ui-engineering/Button.tsx +7 -0
  103. package/evals/fixtures/frontend-ui-engineering/design-system.md +11 -0
  104. package/evals/fixtures/git-workflow-and-versioning/.eval/working-tree.patch +21 -0
  105. package/evals/fixtures/git-workflow-and-versioning/app.js +7 -0
  106. package/evals/fixtures/git-workflow-and-versioning/app.test.js +9 -0
  107. package/evals/fixtures/incremental-implementation/reports.js +7 -0
  108. package/evals/fixtures/incremental-implementation/reports.test.js +12 -0
  109. package/evals/fixtures/incremental-implementation/tasks/plan.md +8 -0
  110. package/evals/fixtures/incremental-implementation-pressure/draft-export.js +17 -0
  111. package/evals/fixtures/incremental-implementation-pressure/scenario.md +9 -0
  112. package/evals/fixtures/observability-and-instrumentation/operations.md +11 -0
  113. package/evals/fixtures/observability-and-instrumentation/payment-retry.js +14 -0
  114. package/evals/fixtures/performance-optimization/benchmark.js +15 -0
  115. package/evals/fixtures/performance-optimization/products.js +14 -0
  116. package/evals/fixtures/planning-and-task-breakdown/notifications-spec.md +18 -0
  117. package/evals/fixtures/security-and-hardening/webhook.js +11 -0
  118. package/evals/fixtures/security-and-hardening/webhook.test.js +13 -0
  119. package/evals/fixtures/shipping-and-launch/authority-pressure.md +6 -0
  120. package/evals/fixtures/shipping-and-launch/launch-status.md +11 -0
  121. package/evals/fixtures/source-driven-development/framework-task.md +10 -0
  122. package/evals/fixtures/spec-driven-development/billing-brief.md +16 -0
  123. package/evals/fixtures/spec-driven-development-decomposition/portal-brief.md +22 -0
  124. package/evals/fixtures/test-driven-development/BUG.md +10 -0
  125. package/evals/fixtures/test-driven-development/README.md +28 -0
  126. package/evals/fixtures/test-driven-development/package.json +9 -0
  127. package/evals/fixtures/test-driven-development/src/split.js +8 -0
  128. package/evals/fixtures/test-driven-development/test/split.test.js +13 -0
  129. package/evals/fixtures/test-driven-development-ecosystem/README.md +9 -0
  130. package/evals/fixtures/test-driven-development-ecosystem/ledger.py +15 -0
  131. package/evals/fixtures/test-driven-development-ecosystem/test_ledger.py +19 -0
  132. package/evals/fixtures/using-agent-skills/incident.md +6 -0
  133. package/evals/plugin/code-review-fires/graders/off-by-one.md +7 -0
  134. package/evals/plugin/code-review-fires/graders/severity-labels.md +4 -0
  135. package/evals/plugin/code-review-fires/graders/skill-fired.md +5 -0
  136. package/evals/plugin/code-review-fires/prompt.md +31 -0
  137. package/evals/plugin/code-review-stays-quiet/graders/not-fired.md +8 -0
  138. package/evals/plugin/code-review-stays-quiet/graders/tdd-fired.md +6 -0
  139. package/evals/plugin/code-review-stays-quiet/prompt.md +8 -0
  140. package/evals/plugin/code-review-stays-quiet-on-commit-message/graders/not-fired.md +8 -0
  141. package/evals/plugin/code-review-stays-quiet-on-commit-message/prompt.md +25 -0
  142. package/evals/skill-impact.md +6 -0
  143. package/hooks/SDD-CACHE.md +167 -0
  144. package/hooks/SIMPLIFY-IGNORE.md +91 -0
  145. package/hooks/sdd-cache-post.sh +135 -0
  146. package/hooks/sdd-cache-pre.sh +106 -0
  147. package/hooks/sdd-cache-test.sh +246 -0
  148. package/hooks/session-start-test.sh +47 -0
  149. package/hooks/session-start.sh +33 -0
  150. package/hooks/simplify-ignore-test.sh +476 -0
  151. package/hooks/simplify-ignore.sh +352 -0
  152. package/package.json +89 -4
  153. package/plugin.json +7 -0
  154. package/rebrand/MAINTENANCE.md +112 -0
  155. package/rebrand/NOTICE.md +9 -0
  156. package/rebrand/PR-WORKFLOW.md +34 -0
  157. package/rebrand/UNIFICATION-SPEC.md +33 -0
  158. package/rebrand/VALIDATION.md +28 -0
  159. package/rebrand/VERSIONING.md +32 -0
  160. package/rebrand/apply.cjs +194 -0
  161. package/rebrand/brand.json +13 -0
  162. package/rebrand/catalog.cjs +56 -0
  163. package/rebrand/fork-patches.json +12 -0
  164. package/rebrand/overlay/.github/workflows/test-plugin-install.yml +177 -0
  165. package/rebrand/overlay/CHANGELOG.md +23 -0
  166. package/rebrand/overlay/bin/i3-composer-agent.cjs +122 -0
  167. package/rebrand/overlay/scripts/validate-brand.cjs +44 -0
  168. package/rebrand/overlay/tests/bundle.test.cjs +85 -0
  169. package/rebrand/package.template.json +82 -0
  170. package/rebrand/rebrand.sh +4 -0
  171. package/rebrand/record-upstream.cjs +37 -0
  172. package/rebrand/templates/README.md +86 -0
  173. package/rebrand/templates/codebuddy-setup.md +41 -0
  174. package/rebrand/templates/codex-setup.md +34 -0
  175. package/rebrand/tests/pipeline.test.cjs +185 -0
  176. package/rebrand/upstream.json +171 -0
  177. package/references/accessibility-checklist.md +160 -0
  178. package/references/definition-of-done.md +67 -0
  179. package/references/observability-checklist.md +92 -0
  180. package/references/orchestration-patterns.md +370 -0
  181. package/references/performance-checklist.md +236 -0
  182. package/references/security-checklist.md +248 -0
  183. package/references/testing-patterns.md +235 -0
  184. package/scripts/floor-guard-reference-test.js +291 -0
  185. package/scripts/lib/skill-lint-test.js +650 -0
  186. package/scripts/lib/skill-lint.js +584 -0
  187. package/scripts/run-evals-test.js +623 -0
  188. package/scripts/run-evals.js +638 -0
  189. package/scripts/validate-artifact-paths-test.js +179 -0
  190. package/scripts/validate-artifact-paths.js +128 -0
  191. package/scripts/validate-brand.cjs +44 -0
  192. package/scripts/validate-commands-test.js +216 -0
  193. package/scripts/validate-commands.js +222 -0
  194. package/scripts/validate-reference-links-test.js +495 -0
  195. package/scripts/validate-reference-links.js +187 -0
  196. package/scripts/validate-skills.js +69 -0
  197. package/scripts/validate-versions-test.js +32 -0
  198. package/scripts/validate-versions.js +35 -0
  199. package/skills/api-and-interface-design/SKILL.md +367 -0
  200. package/skills/browser-testing-with-devtools/SKILL.md +317 -0
  201. package/skills/ci-cd-and-automation/SKILL.md +390 -0
  202. package/skills/code-review-and-quality/SKILL.md +398 -0
  203. package/skills/code-simplification/SKILL.md +331 -0
  204. package/skills/constraint-driven-development/SKILL.md +311 -0
  205. package/skills/constraint-driven-development/references/floor-guard.md +182 -0
  206. package/skills/context-engineering/SKILL.md +353 -0
  207. package/skills/debugging-and-error-recovery/SKILL.md +300 -0
  208. package/skills/deprecation-and-migration/SKILL.md +247 -0
  209. package/skills/documentation-and-adrs/SKILL.md +288 -0
  210. package/skills/doubt-driven-development/SKILL.md +243 -0
  211. package/skills/frontend-ui-engineering/SKILL.md +340 -0
  212. package/skills/git-workflow-and-versioning/SKILL.md +355 -0
  213. package/skills/idea-refine/SKILL.md +178 -0
  214. package/skills/idea-refine/examples.md +238 -0
  215. package/skills/idea-refine/frameworks.md +99 -0
  216. package/skills/idea-refine/refinement-criteria.md +113 -0
  217. package/skills/idea-refine/scripts/idea-refine.sh +15 -0
  218. package/skills/incremental-implementation/SKILL.md +249 -0
  219. package/skills/interview-me/SKILL.md +235 -0
  220. package/skills/observability-and-instrumentation/SKILL.md +238 -0
  221. package/skills/performance-optimization/SKILL.md +267 -0
  222. package/skills/performance-optimization/references/optimization-patterns.md +250 -0
  223. package/skills/planning-and-task-breakdown/SKILL.md +257 -0
  224. package/skills/security-and-hardening/SKILL.md +216 -0
  225. package/skills/security-and-hardening/references/hardening-patterns.md +324 -0
  226. package/skills/shipping-and-launch/SKILL.md +330 -0
  227. package/skills/source-driven-development/SKILL.md +216 -0
  228. package/skills/spec-driven-development/SKILL.md +259 -0
  229. package/skills/test-driven-development/SKILL.md +398 -0
  230. package/skills/using-agent-skills/SKILL.md +192 -0
  231. package/tests/bundle.test.cjs +85 -0
@@ -0,0 +1,370 @@
1
+ # Orchestration Patterns
2
+
3
+ Reference catalog of agent orchestration patterns this repo endorses, plus anti-patterns to avoid. Read this before adding a new slash command that coordinates multiple personas, or before introducing a new persona that "wraps" existing ones.
4
+
5
+ The governing rule: **the user (or a slash command) is the orchestrator. Personas do not invoke other personas.** Skills are mandatory hops inside a persona's workflow.
6
+
7
+ ---
8
+
9
+ ## Endorsed patterns
10
+
11
+ ### 1. Direct invocation (no orchestration)
12
+
13
+ Single persona, single perspective, single artifact. The default and the cheapest option.
14
+
15
+ ```
16
+ user → code-reviewer → report → user
17
+ ```
18
+
19
+ **Use when:** the work is one perspective on one artifact and you can describe it in one sentence.
20
+
21
+ **Examples:**
22
+ - "Review this PR" → `code-reviewer`
23
+ - "Find security issues in `auth.ts`" → `security-auditor`
24
+ - "What tests are missing for the checkout flow?" → `test-engineer`
25
+
26
+ **Cost:** one round trip. The baseline you should always compare orchestrated patterns against.
27
+
28
+ ---
29
+
30
+ ### 2. Single-persona slash command
31
+
32
+ A slash command that wraps one persona with the project's skills. Saves the user from re-explaining the workflow every time.
33
+
34
+ ```
35
+ /review → code-reviewer (with code-review-and-quality skill) → report
36
+ ```
37
+
38
+ **Use when:** the same single-persona invocation happens repeatedly with the same setup.
39
+
40
+ **Examples in this repo:** `/review`, `/test`, `/code-simplify`.
41
+
42
+ **Cost:** same as direct invocation. The slash command is just a saved prompt.
43
+
44
+ **Anti-signal:** if the slash command's body is mostly "decide which persona to call," delete it and let the user call the persona directly.
45
+
46
+ ---
47
+
48
+ ### 3. Parallel fan-out with merge
49
+
50
+ Multiple personas operate on the same input concurrently, each producing an independent report. A merge step (in the main agent's context) synthesizes them into a single decision.
51
+
52
+ ```
53
+ ┌─→ code-reviewer ─┐
54
+ /ship → fan out ───┼─→ security-auditor ─┤→ merge → go/no-go + rollback
55
+ └─→ test-engineer ─┘
56
+ ```
57
+
58
+ **Use when:**
59
+ - The sub-tasks are genuinely independent (no shared mutable state, no ordering dependency)
60
+ - Each sub-agent benefits from its own context window
61
+ - The merge step is small enough to stay in the main context
62
+ - Wall-clock latency matters
63
+
64
+ **Examples in this repo:** `/ship`.
65
+
66
+ **Cost:** N parallel sub-agent contexts + one merge turn. Higher than direct invocation, but faster wall-clock and produces better reports because each sub-agent stays focused on its single perspective.
67
+
68
+ **Validation checklist before adopting this pattern:**
69
+ - [ ] Can I run all sub-agents at the same time without ordering issues?
70
+ - [ ] Does each persona produce a different *kind* of finding, not just the same finding from a different angle?
71
+ - [ ] Will the merge step fit in the main agent's remaining context?
72
+ - [ ] Is the user's wait time long enough that parallelism is actually noticeable?
73
+
74
+ If any answer is "no," fall back to direct invocation or a single-persona command.
75
+
76
+ ---
77
+
78
+ ### 4. Sequential pipeline as user-driven slash commands
79
+
80
+ The user runs slash commands in a defined order, carrying context (or commit history) between them. There is no orchestrator agent — the user IS the orchestrator.
81
+
82
+ ```
83
+ user runs: /spec → /plan → /build → /test → /review → /ship
84
+ ```
85
+
86
+ **Use when:** the workflow has dependencies (each step needs the previous step's output) and human judgment between steps adds value.
87
+
88
+ **Examples in this repo:** the entire DEFINE → PLAN → BUILD → VERIFY → REVIEW → SHIP lifecycle.
89
+
90
+ **Cost:** one sub-agent context per step. Free for the orchestration layer because there is no orchestrator agent.
91
+
92
+ **Why not automate it:** an LLM "lifecycle orchestrator" would (a) lose nuance between steps because it has to summarize for hand-off, (b) skip the human checkpoints that catch wrong-direction work early, and (c) double the token cost via paraphrasing turns.
93
+
94
+ ---
95
+
96
+ ### 5. Research isolation (context preservation)
97
+
98
+ When a task requires reading large amounts of material that shouldn't pollute the main context, spawn a research sub-agent that returns only a digest.
99
+
100
+ ```
101
+ main agent → research sub-agent (reads 50 files) → digest → main agent continues
102
+ ```
103
+
104
+ **Use when:**
105
+ - The main session needs to stay focused on a downstream task
106
+ - The investigation result is much smaller than the input it consumes
107
+ - The decision quality benefits from the main agent having room to think after
108
+
109
+ **Examples:** "Find every call site of this deprecated API across the monorepo," "Summarize what these 30 ADRs say about caching."
110
+
111
+ **Cost:** one isolated sub-agent context. Worth it any time the alternative is loading hundreds of files into the main context.
112
+
113
+ **On Claude Code, use the built-in `Explore` subagent** rather than defining a custom research persona. `Explore` runs on Haiku, is denied write/edit tools, and is purpose-built for this pattern. Define a custom research subagent only when `Explore` doesn't fit (e.g. you need a domain-specific system prompt the model wouldn't infer).
114
+
115
+ ---
116
+
117
+ ## Claude Code compatibility
118
+
119
+ This catalog is harness-agnostic, but most readers will run it on Claude Code. Here's how each pattern maps onto Claude Code's primitives — and where the platform enforces our rules for us.
120
+
121
+ ### Where personas live
122
+
123
+ Plugin subagents go in `agents/` at the plugin root. This repo is a plugin (`.claude-plugin/plugin.json`), so `agents/code-reviewer.md`, `agents/security-auditor.md`, and `agents/test-engineer.md` are auto-discovered when the plugin is enabled. No path configuration needed.
124
+
125
+ ### Subagents vs. Agent Teams
126
+
127
+ Claude Code has two parallelism primitives. Pattern 3 (parallel fan-out with merge) maps to **subagents**. If you need teammates that talk to each other, use **Agent Teams** instead.
128
+
129
+ | | Subagents | Agent Teams |
130
+ |--|-----------|-------------|
131
+ | Coordination | Main agent fans out, sub-agents only report back | Teammates message each other, share a task list |
132
+ | Context | Own context window per subagent | Own context window per teammate |
133
+ | When to use | Independent tasks producing reports | Collaborative work needing discussion |
134
+ | Status | Stable | Experimental — requires `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` |
135
+ | Cost | Lower | Higher — each teammate is a separate Claude instance |
136
+
137
+ **The personas in this repo work in both modes.** When spawned as subagents (e.g. by `/ship`), they report findings to the main session. When spawned as teammates (`Spawn a teammate using the security-auditor agent type…`), they can challenge each other's findings directly. The persona definition is the same; only the spawning context changes.
138
+
139
+ One subtlety: the `skills` and `mcpServers` frontmatter fields in a persona are honored when it runs as a subagent but **ignored when it runs as a teammate** — teammates load skills and MCP servers from your project and user settings, the same as a regular session. If a persona depends on a specific skill or MCP server being loaded, configure it at the session level so it's available in both modes.
140
+
141
+ ### Platform-enforced rules
142
+
143
+ Two rules in this catalog aren't just convention — Claude Code enforces them:
144
+
145
+ - **"Subagents cannot spawn other subagents"** (verbatim from the docs). Anti-pattern B (persona-calls-persona) and Anti-pattern D (deep persona trees) cannot exist on Claude Code by construction.
146
+ - **"No nested teams"** — teammates cannot spawn their own teams. Same anti-patterns blocked at the team level.
147
+
148
+ This means you can adopt the patterns in this catalog without worrying about contributors accidentally building the anti-patterns. They'll just fail to load.
149
+
150
+ ### Built-in subagents to know about
151
+
152
+ Before defining a custom subagent, check whether one of these covers the role:
153
+
154
+ | Built-in | Purpose |
155
+ |----------|---------|
156
+ | `Explore` | Read-only codebase search and analysis. Use this for Pattern 5 (research isolation). |
157
+ | `Plan` | Read-only research during plan mode. |
158
+ | `general-purpose` | Multi-step tasks needing both exploration and modification. |
159
+
160
+ Don't redefine these. Layer your specialist personas (code-reviewer, security-auditor, test-engineer) on top of them.
161
+
162
+ ### Frontmatter restrictions for plugin agents
163
+
164
+ Plugin subagents do **not** support the `hooks`, `mcpServers`, or `permissionMode` frontmatter fields — these are silently ignored. If a future persona needs any of those, the user must copy the file into `.claude/agents/` or `~/.claude/agents/` instead.
165
+
166
+ The fields that DO work in plugin agents are: `name`, `description`, `tools`, `disallowedTools`, `model`, `maxTurns`, `skills`, `memory`, `background`, `effort`, `isolation`, `color`, `initialPrompt`. Use `model` per-persona if you want to optimize cost (e.g. Haiku for `test-engineer` coverage scans, Sonnet for `code-reviewer`, Opus for `security-auditor`).
167
+
168
+ ### Spawning multiple subagents in parallel
169
+
170
+ In Claude Code, parallel fan-out (Pattern 3) requires issuing **multiple Agent tool calls in a single assistant turn**. Sequential turns serialize execution. `/ship` calls this out explicitly. Any new orchestrator command should do the same.
171
+
172
+ ---
173
+
174
+ ## Worked example: Agent Teams for competing-hypothesis debugging
175
+
176
+ This example shows when to reach for **Agent Teams** instead of `/ship`'s subagent fan-out. The two patterns look similar from a distance — both spawn the same three personas — but the value comes from a different place.
177
+
178
+ ### The scenario
179
+
180
+ > *Checkout occasionally hangs for ~30 seconds before completing. It happens roughly once every 50 sessions. No errors in logs. Started after last week's release.*
181
+
182
+ Plausible root causes (mutually exclusive, all fit the symptoms):
183
+
184
+ 1. A race condition in the new payment-confirmation flow
185
+ 2. An auth check that occasionally falls through to a slow synchronous network call
186
+ 3. A missing index on a query that scales with cart size
187
+ 4. A flaky third-party API where the SDK retries silently before timing out
188
+
189
+ A single agent will pick the first plausible theory and stop investigating. A `/ship`-style subagent fan-out would have each persona report independently — but their reports never meet, so nothing rules out the wrong theories.
190
+
191
+ This is exactly the case the Agent Teams docs describe: *"With multiple independent investigators actively trying to disprove each other, the theory that survives is much more likely to be the actual root cause."*
192
+
193
+ ### Why this is *not* a `/ship` job
194
+
195
+ | | `/ship` (subagents) | Agent Teams |
196
+ |--|--------------------|-------------|
197
+ | Sub-agents see | The same diff, different lenses | A shared task list, each other's messages |
198
+ | Output | Three independent reports → one merge | Adversarial debate → consensus root cause |
199
+ | Right when | You want a verdict on a known artifact | You want to *find* the artifact among hypotheses |
200
+
201
+ `/ship` is a verdict; Agent Teams is an investigation.
202
+
203
+ ### Setup (one-time, per-environment)
204
+
205
+ Agent Teams is experimental. In `~/.claude/settings.json`:
206
+
207
+ ```json
208
+ {
209
+ "env": {
210
+ "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
211
+ }
212
+ }
213
+ ```
214
+
215
+ Requires Claude Code v2.1.32 or later. The personas in this repo are picked up automatically — no team-config files to author by hand.
216
+
217
+ ### The trigger prompt
218
+
219
+ Type into the lead session, in natural language:
220
+
221
+ ```
222
+ Users report checkout hangs for ~30 seconds intermittently after last
223
+ week's release. No errors in logs.
224
+
225
+ Create an agent team to debug this with competing hypotheses. Spawn
226
+ three teammates using the existing agent types:
227
+
228
+ - code-reviewer — investigate race conditions and blocking calls
229
+ in the checkout code path
230
+ - security-auditor — investigate auth checks, session handling,
231
+ and any synchronous network calls added recently
232
+ - test-engineer — propose tests that would distinguish between the
233
+ hypotheses and check coverage gaps in checkout
234
+
235
+ Have them message each other directly to challenge each other's
236
+ theories. Update findings as consensus emerges. Only converge when
237
+ two teammates agree they can disprove the others'.
238
+ ```
239
+
240
+ The lead spawns three teammates referencing the existing persona names. The persona body is **appended** to each teammate's system prompt as additional instructions (on top of the team-coordination instructions the lead installs); the trigger prompt above becomes their task.
241
+
242
+ ### What happens
243
+
244
+ 1. Each teammate runs in its own context window, exploring the codebase from its own lens.
245
+ 2. Teammates use `message` to send findings to each other directly. The lead doesn't have to relay.
246
+ 3. The shared task list shows who's investigating what — visible at any time with `Ctrl+T` (in-process mode) or in a tmux pane (split mode).
247
+ 4. When `code-reviewer` finds a `Promise.all` that should be sequential, it messages `security-auditor` to confirm the auth call isn't part of the race. `security-auditor` checks and replies — either confirming the race is the real issue or producing counter-evidence.
248
+ 5. `test-engineer` proposes a focused integration test for whichever theory is winning, which the team uses to verify before declaring consensus.
249
+ 6. The lead synthesizes the converged finding and presents it to you.
250
+
251
+ You can interrupt at any teammate by cycling with `Shift+Down` and typing — useful for redirecting an investigator who's gone down a wrong path.
252
+
253
+ ### When to clean up
254
+
255
+ When the investigation lands on a root cause, tell the lead:
256
+
257
+ ```
258
+ Clean up the team
259
+ ```
260
+
261
+ Always cleanup through the lead, not a teammate (per the docs: teammates lack full team context for cleanup).
262
+
263
+ ### Cost expectation
264
+
265
+ Three Sonnet teammates running for ~10–15 minutes of investigation costs noticeably more than the same three personas spawned as subagents by `/ship`. The justification is *quality of conclusion* — for production debugging where the wrong fix is expensive, the extra tokens are a bargain. For a routine PR review, stick with `/ship`.
266
+
267
+ ### Anti-pattern in this scenario
268
+
269
+ Do **not** rebuild this as a `/debug` slash command that fans out subagents. Subagents can't message each other — you'd lose the adversarial debate that makes the pattern work. If a workflow keeps coming up, document the trigger prompt above as a snippet rather than wrapping it in a slash command that misuses subagents.
270
+
271
+ ### When *not* to use Agent Teams
272
+
273
+ - Production-bound verdict on a known diff → use `/ship` (subagents).
274
+ - One specialist perspective on one artifact → direct persona invocation.
275
+ - Sequential lifecycle (spec → plan → build) → user-driven slash commands (Pattern 4).
276
+ - Read-heavy research with a small digest → built-in `Explore` subagent.
277
+
278
+ Reach for Agent Teams only when teammates **need** to challenge each other to produce the right answer.
279
+
280
+ ---
281
+
282
+ ## Anti-patterns
283
+
284
+ ### A. Router persona ("meta-orchestrator")
285
+
286
+ A persona whose job is to decide which other persona to call.
287
+
288
+ ```
289
+ /work → router-persona → "this needs a review" → code-reviewer → router (paraphrases) → user
290
+ ```
291
+
292
+ **Why it fails:**
293
+ - Pure routing layer with no domain value
294
+ - Adds two paraphrasing hops → information loss + roughly 2× token cost
295
+ - The user already knew they wanted a review; they could have called `/review` directly
296
+ - Replicates the work that slash commands and intent mapping in `AGENTS.md` already do
297
+
298
+ **What to do instead:** add or refine slash commands. Document intent → command mapping in `AGENTS.md`.
299
+
300
+ ---
301
+
302
+ ### B. Persona that calls another persona
303
+
304
+ A `code-reviewer` that internally invokes `security-auditor` when it sees auth code.
305
+
306
+ **Why it fails:**
307
+ - Personas were designed to produce a single perspective; chaining them defeats that
308
+ - The summary the calling persona passes loses context the called persona needs
309
+ - Failure modes multiply (which persona's output format wins? whose rules apply?)
310
+ - Hides cost from the user
311
+
312
+ **What to do instead:** have the calling persona *recommend* a follow-up audit in its report. The user or a slash command runs the second pass.
313
+
314
+ ---
315
+
316
+ ### C. Sequential orchestrator that paraphrases
317
+
318
+ An agent that calls `/spec`, then `/plan`, then `/build`, etc. on the user's behalf.
319
+
320
+ **Why it fails:**
321
+ - Loses the human checkpoints that catch wrong-direction work
322
+ - Each hand-off summarizes context — accumulated drift over a long pipeline
323
+ - Doubles token cost: orchestrator turn + sub-agent turn for every step
324
+ - Removes user agency at exactly the points where judgment matters most
325
+
326
+ **What to do instead:** keep the user as the orchestrator. Document the recommended sequence in `README.md` and let users invoke it.
327
+
328
+ ---
329
+
330
+ ### D. Deep persona trees
331
+
332
+ `/ship` calls a `pre-ship-coordinator` that calls a `quality-coordinator` that calls `code-reviewer`.
333
+
334
+ **Why it fails:**
335
+ - Each layer adds latency and tokens with no decision value
336
+ - Debugging becomes a multi-level investigation
337
+ - The leaf personas lose context to multiple summarization steps
338
+
339
+ **What to do instead:** keep the orchestration depth at most 1 (slash command → personas). The merge happens in the main agent.
340
+
341
+ ---
342
+
343
+ ## Decision flow
344
+
345
+ When considering a new orchestrated workflow, walk this flow:
346
+
347
+ ```
348
+ Is the work one perspective on one artifact?
349
+ ├── Yes → Direct invocation. Stop.
350
+ └── No → Will the same composition repeat?
351
+ ├── No → Direct invocation, ad hoc. Stop.
352
+ └── Yes → Are sub-tasks independent?
353
+ ├── No → Sequential slash commands run by user (Pattern 4).
354
+ └── Yes → Parallel fan-out with merge (Pattern 3).
355
+ Validate against the checklist above.
356
+ If any check fails → fall back to single-persona command (Pattern 2).
357
+ ```
358
+
359
+ ---
360
+
361
+ ## When to add a new pattern to this catalog
362
+
363
+ Add a new entry only after:
364
+
365
+ 1. You've used the pattern at least twice in real work
366
+ 2. You can name a concrete artifact in this repo that demonstrates it
367
+ 3. You can explain why an existing pattern wouldn't have worked
368
+ 4. You can describe its anti-pattern shadow (what people will mistakenly build instead)
369
+
370
+ Premature catalog entries become aspirational documentation that no one follows.
@@ -0,0 +1,236 @@
1
+ # Performance Checklist
2
+
3
+ Quick reference checklist for web application performance. Use alongside the `performance-optimization` skill.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Core Web Vitals Targets](#core-web-vitals-targets)
8
+ - [TTFB Diagnosis](#ttfb-diagnosis)
9
+ - [Frontend Checklist](#frontend-checklist)
10
+ - [Backend Checklist](#backend-checklist)
11
+ - [Caching Strategies](#caching-strategies)
12
+ - [Measurement Commands](#measurement-commands)
13
+ - [Common Anti-Patterns](#common-anti-patterns)
14
+
15
+ ## Core Web Vitals Targets
16
+
17
+ | Metric | Good | Needs Work | Poor |
18
+ |--------|------|------------|------|
19
+ | LCP (Largest Contentful Paint) | ≤ 2.5s | ≤ 4.0s | > 4.0s |
20
+ | INP (Interaction to Next Paint) | ≤ 200ms | ≤ 500ms | > 500ms |
21
+ | CLS (Cumulative Layout Shift) | ≤ 0.1 | ≤ 0.25 | > 0.25 |
22
+
23
+ ## TTFB Diagnosis
24
+
25
+ When TTFB is slow (> 800ms), check each component in DevTools Network waterfall:
26
+
27
+ - [ ] **DNS resolution** slow → add `<link rel="dns-prefetch">` or `<link rel="preconnect">` for known origins
28
+ - [ ] **TCP/TLS handshake** slow → enable HTTP/2, consider edge deployment, verify keep-alive
29
+ - [ ] **Server processing** slow → profile backend, check slow queries, add caching
30
+
31
+ ## Frontend Checklist
32
+
33
+ ### Images
34
+ - [ ] Images use modern formats (WebP, AVIF)
35
+ - [ ] Images are responsively sized (`srcset` and `sizes`)
36
+ - [ ] Images and `<source>` elements have explicit `width` and `height` (prevents CLS in art direction)
37
+ - [ ] Below-the-fold images use `loading="lazy"` and `decoding="async"`
38
+ - [ ] Hero/LCP images use `fetchpriority="high"` and no lazy loading
39
+
40
+ ### JavaScript
41
+ - [ ] Bundle size under 200KB gzipped (initial load)
42
+ - [ ] Code splitting with dynamic `import()` for routes and heavy features
43
+ - [ ] Tree shaking enabled (verify dependency ships ESM and marks `sideEffects: false`)
44
+ - [ ] No blocking JavaScript in `<head>` (use `defer` or `async`)
45
+ - [ ] Heavy computation offloaded to Web Workers (if applicable)
46
+ - [ ] `React.memo()` on expensive components that re-render with same props
47
+ - [ ] `useMemo()` / `useCallback()` only where profiling shows benefit
48
+ - [ ] Long tasks (> 50ms) broken up to keep the main thread available — main lever for INP
49
+ - [ ] `yieldToMain` pattern used inside long-running loops so input events can run between chunks
50
+ - [ ] Modern scheduling APIs used where available: `scheduler.yield()` (preferred), `scheduler.postTask()` with priorities, `isInputPending()` to yield only when needed
51
+ - [ ] `requestIdleCallback` for deferrable, non-urgent work (analytics flush, prefetch, warmup)
52
+ - [ ] Non-critical work deferred out of event handlers (e.g. analytics, logging) so the response to the interaction is not delayed
53
+ - [ ] Third-party scripts loaded with `async` / `defer`, audited for size, and fronted by a facade when heavy (chat widgets, embeds)
54
+
55
+ ### CSS
56
+ - [ ] Critical CSS inlined or preloaded
57
+ - [ ] No render-blocking CSS for non-critical styles
58
+ - [ ] No CSS-in-JS runtime cost in production (use extraction)
59
+
60
+ ### Fonts
61
+ - [ ] Limited to 2–3 font families, 2–3 weights each (every additional weight is another request)
62
+ - [ ] WOFF2 format only (smallest, universal support — skip WOFF/TTF/EOT)
63
+ - [ ] Self-hosted when possible (third-party font CDNs add DNS + TCP + TLS round-trips)
64
+ - [ ] LCP-critical fonts preloaded: `<link rel="preload" as="font" type="font/woff2" crossorigin>`
65
+ - [ ] `font-display: swap` (or `optional` for non-critical) to avoid FOIT blocking render
66
+ - [ ] Subsetted via `unicode-range` to ship only the glyphs each page needs
67
+ - [ ] Variable fonts considered when multiple weights/styles are required (one file replaces many)
68
+ - [ ] Fallback font metrics adjusted with `size-adjust`, `ascent-override`, `descent-override` to reduce CLS on font swap
69
+ - [ ] System font stack considered before any custom font
70
+
71
+ ### Network
72
+ - [ ] Static assets cached with long `max-age` + content hashing
73
+ - [ ] API responses cached where appropriate (`Cache-Control`)
74
+ - [ ] HTTP/2 or HTTP/3 enabled
75
+ - [ ] Resources preconnected (`<link rel="preconnect">`) for known origins
76
+ - [ ] `fetchpriority` used on critical non-image resources (e.g., key `<link rel="preload">`, above-the-fold `<script>`) — not only on `<img>`
77
+ - [ ] No unnecessary redirects
78
+
79
+ ### Rendering
80
+ - [ ] No layout thrashing (forced synchronous layouts)
81
+ - [ ] Animations use `transform` and `opacity` (GPU-accelerated)
82
+ - [ ] Long lists use virtualization (e.g., `react-window`)
83
+ - [ ] No unnecessary full-page re-renders
84
+ - [ ] Off-screen sections use `content-visibility: auto` with `contain-intrinsic-size` to skip layout/paint of non-visible areas
85
+ - [ ] No `unload` event handlers and no `Cache-Control: no-store` on HTML responses — preserves back/forward cache (bfcache) eligibility
86
+
87
+ ## Backend Checklist
88
+
89
+ ### Database
90
+ - [ ] No N+1 query patterns (use eager loading / joins)
91
+ - [ ] Queries have appropriate indexes
92
+ - [ ] List endpoints paginated (never `SELECT * FROM table`)
93
+ - [ ] Connection pooling configured
94
+ - [ ] Slow query logging enabled
95
+
96
+ #### Query plans
97
+ - [ ] `EXPLAIN ANALYZE` captured **before** the fix, not just after — it is the baseline
98
+ - [ ] `Seq Scan` on a large table understood: index missing, unusable, or genuinely not worth it
99
+ - [ ] Estimated vs actual `rows=` within an order of magnitude (if not, refresh statistics before touching indexes)
100
+ - [ ] No `Sort` node that a composite index could absorb
101
+ - [ ] Plan re-checked after the change — an index that did not change the plan gets reverted
102
+
103
+ #### Index strategy
104
+ - [ ] Composite index column order is equality first, then range/sort
105
+ - [ ] Index covers the query shape (filter + sort), not just one column in isolation
106
+ - [ ] Covering index considered for hot read paths (index-only scan avoids the heap fetch)
107
+ - [ ] Not indexing low-selectivity columns *for the dominant value*; a partial index still serves the rare-value query (`WHERE status = 'failed'`)
108
+ - [ ] Expression index used where the query applies a function (`lower(email)`)
109
+ - [ ] Full-text or trigram index used for leading-wildcard search, not a B-tree
110
+ - [ ] Write cost measured on write-heavy tables (every index taxes every `INSERT`/`UPDATE`)
111
+ - [ ] Unused and duplicate indexes dropped (they cost writes and buy nothing)
112
+
113
+ #### Connection pooling
114
+ - [ ] One pool per process, not per request or per module
115
+ - [ ] `instances × pool max` stays under the database's `max_connections`
116
+ - [ ] `connectionTimeoutMillis` set so exhaustion fails fast instead of queueing forever
117
+ - [ ] Exhaustion diagnosed before resizing: find what holds connections (long transactions, missing `await`, leaked clients)
118
+ - [ ] Serverless / autoscaling fronted by a multiplexing proxy (pgbouncer, RDS Proxy) rather than a larger pool
119
+
120
+ ### API
121
+ - [ ] Response times < 200ms (p95)
122
+ - [ ] No synchronous heavy computation in request handlers
123
+ - [ ] Bulk operations instead of loops of individual calls
124
+ - [ ] Response compression (gzip/brotli)
125
+ - [ ] Appropriate caching (in-memory, Redis, CDN)
126
+
127
+ ### Infrastructure
128
+ - [ ] CDN for static assets
129
+ - [ ] Server located close to users (or edge deployment)
130
+ - [ ] Horizontal scaling configured (if needed)
131
+ - [ ] Health check endpoint for load balancer
132
+
133
+ ## Caching Strategies
134
+
135
+ The decision material (which layer, which invalidation strategy, what never to cache) lives in the `performance-optimization` skill. This section covers the read/write patterns and the checklist.
136
+
137
+ ### Read and write patterns
138
+
139
+ | Pattern | How it works | Use when | Watch out for |
140
+ |---|---|---|---|
141
+ | **Cache-aside** (lazy) | App checks cache, on miss reads origin and populates | Default choice; read-heavy, tolerant of a cold first hit | Every miss hits the origin, so it needs stampede protection |
142
+ | **Read-through** | Cache layer itself loads on miss | You want the load path in one place, not at every call site | Hides origin latency; a slow origin looks like a slow cache |
143
+ | **Write-through** | Write goes to cache and origin together, synchronously | Reads must never see a stale value after a write | Adds cache latency to every write |
144
+ | **Write-behind** (write-back) | Write hits cache, origin updated asynchronously | Write-heavy, and the origin is the bottleneck | Data loss window if the cache dies before the flush. Needs durability you can defend |
145
+
146
+ ### Negative caching
147
+
148
+ Cache the *absence* of a result too. A key that misses on every lookup (a nonexistent user ID probed in a loop, a 404 asset) sends every request to the origin, which is a cache that only protects the happy path.
149
+
150
+ - Store an explicit "not found" sentinel with a **shorter** TTL than positive entries
151
+ - Keep the negative TTL short enough that a newly created record appears promptly
152
+ - Never let an origin *error* become a negative cache entry, or one failing minute becomes many
153
+
154
+ ### Request coalescing (stampede protection)
155
+
156
+ One recompute, N waiters. Prevents a hot key's expiry from delivering the full concurrent load to the origin:
157
+
158
+ ```typescript
159
+ const inFlight = new Map<string, Promise<unknown>>();
160
+
161
+ function loadOnce<T>(key: string, fetcher: () => Promise<T>): Promise<T> {
162
+ const existing = inFlight.get(key) as Promise<T> | undefined;
163
+ if (existing) return existing;
164
+ const p = fetcher().finally(() => inFlight.delete(key));
165
+ inFlight.set(key, p);
166
+ return p;
167
+ }
168
+ ```
169
+
170
+ For a shared cache, the same idea needs a distributed lock, or `stale-while-revalidate` so waiters serve the stale value instead of blocking.
171
+
172
+ ### Cache checklist
173
+ - [ ] The cached call was measured as expensive first (caching a fast call adds a hop and buys nothing)
174
+ - [ ] Read/write ratio justifies the cache (re-read far more often than written)
175
+ - [ ] Cache key includes every input the response varies on: tenant, viewer, locale, permissions, feature flags
176
+ - [ ] No per-user data cached under a key that does not identify the user
177
+ - [ ] One invalidation strategy chosen (TTL, event/tag, or versioned keys), not an accidental mix
178
+ - [ ] Acceptable staleness window written down, not implied by whatever TTL was typed
179
+ - [ ] Stampede protection on hot keys (coalescing, lock, or `stale-while-revalidate`)
180
+ - [ ] Negative results cached with a shorter TTL; origin errors never cached
181
+ - [ ] Eviction policy and memory ceiling set (an unbounded cache is a memory leak)
182
+ - [ ] Hit rate monitored — a cache nobody measures is an assumption, and a low hit rate is pure overhead
183
+ - [ ] Nothing cached whose staleness is a correctness bug (balances, permissions, inventory at checkout)
184
+
185
+ ## Measurement Commands
186
+
187
+ ### INP field data and DevTools workflow
188
+
189
+ 1. **Field data first** — check [CrUX Vis](https://developer.chrome.com/docs/crux/vis) or your RUM tool for real-user INP before optimising
190
+ 2. **Identify slow interactions** — open DevTools → Performance panel → record while interacting; look for long tasks triggered by clicks/keystrokes
191
+ 3. **Test on mid-range Android** — INP issues often only surface on slower hardware; use a real device or DevTools CPU throttling (4×–6× slowdown)
192
+
193
+ ```bash
194
+ # Lighthouse CLI
195
+ npx lighthouse https://localhost:3000 --output json --output-path ./report.json
196
+
197
+ # Bundle analysis
198
+ npx webpack-bundle-analyzer stats.json
199
+ # or for Vite:
200
+ npx vite-bundle-visualizer
201
+
202
+ # Check bundle size
203
+ npx bundlesize
204
+
205
+ # Web Vitals in code
206
+ import { onLCP, onINP, onCLS } from 'web-vitals';
207
+ onLCP(console.log);
208
+ onINP(console.log);
209
+ onCLS(console.log);
210
+
211
+ # INP with interaction-level detail (attribution build)
212
+ import { onINP } from 'web-vitals/attribution';
213
+ onINP(({ value, attribution }) => {
214
+ const { interactionTarget, inputDelay, processingDuration, presentationDelay } = attribution;
215
+ console.log({ value, interactionTarget, inputDelay, processingDuration, presentationDelay });
216
+ });
217
+ ```
218
+
219
+ ## Common Anti-Patterns
220
+
221
+ | Anti-Pattern | Impact | Fix |
222
+ |---|---|---|
223
+ | N+1 queries | Linear DB load growth | Use joins, includes, or batch loading |
224
+ | Unbounded queries | Memory exhaustion, timeouts | Always paginate, add LIMIT |
225
+ | Missing indexes | Slow reads as data grows | Add indexes for filtered/sorted columns |
226
+ | Indexing without reading the plan | Write cost paid, read gain unproven | `EXPLAIN ANALYZE` before and after; revert if the plan is unchanged |
227
+ | Redundant / unused indexes | Every write pays for them | Audit usage stats, drop what nothing reads |
228
+ | Connection pool per request | Exhausts `max_connections` under load | One pool per process; proxy for serverless |
229
+ | Cache key missing the viewer | One user's data served to another | Key on tenant, viewer, locale, permissions |
230
+ | Unbounded cache | Memory leak wearing an optimization's clothing | Set eviction policy and a memory ceiling |
231
+ | Cache stampede on a hot key | Origin takes full concurrent load at expiry | Coalesce misses, or `stale-while-revalidate` |
232
+ | Layout thrashing | Jank, dropped frames | Batch DOM reads, then batch writes |
233
+ | Unoptimized images | Slow LCP, wasted bandwidth | Use WebP, responsive sizes, lazy load |
234
+ | Large bundles | Slow Time to Interactive | Code split, tree shake, audit deps |
235
+ | Blocking main thread | Poor INP, unresponsive UI | Chunk long tasks with `scheduler.yield()` / `yieldToMain`, offload to Web Workers |
236
+ | Memory leaks | Growing memory, eventual crash | Clean up listeners, intervals, refs |