tribunal-kit 2.4.6 → 3.1.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 (250) hide show
  1. package/.agent/ARCHITECTURE.md +99 -99
  2. package/.agent/GEMINI.md +52 -52
  3. package/.agent/agents/accessibility-reviewer.md +139 -86
  4. package/.agent/agents/ai-code-reviewer.md +160 -90
  5. package/.agent/agents/backend-specialist.md +164 -127
  6. package/.agent/agents/code-archaeologist.md +115 -73
  7. package/.agent/agents/database-architect.md +130 -110
  8. package/.agent/agents/debugger.md +137 -97
  9. package/.agent/agents/dependency-reviewer.md +78 -30
  10. package/.agent/agents/devops-engineer.md +161 -118
  11. package/.agent/agents/documentation-writer.md +151 -87
  12. package/.agent/agents/explorer-agent.md +117 -99
  13. package/.agent/agents/frontend-reviewer.md +127 -47
  14. package/.agent/agents/frontend-specialist.md +169 -109
  15. package/.agent/agents/game-developer.md +28 -164
  16. package/.agent/agents/logic-reviewer.md +87 -49
  17. package/.agent/agents/mobile-developer.md +151 -103
  18. package/.agent/agents/mobile-reviewer.md +133 -50
  19. package/.agent/agents/orchestrator.md +121 -110
  20. package/.agent/agents/penetration-tester.md +103 -77
  21. package/.agent/agents/performance-optimizer.md +136 -92
  22. package/.agent/agents/performance-reviewer.md +139 -69
  23. package/.agent/agents/product-manager.md +104 -70
  24. package/.agent/agents/product-owner.md +6 -25
  25. package/.agent/agents/project-planner.md +95 -95
  26. package/.agent/agents/qa-automation-engineer.md +174 -87
  27. package/.agent/agents/security-auditor.md +133 -129
  28. package/.agent/agents/seo-specialist.md +160 -99
  29. package/.agent/agents/sql-reviewer.md +132 -44
  30. package/.agent/agents/supervisor-agent.md +137 -109
  31. package/.agent/agents/swarm-worker-contracts.md +17 -17
  32. package/.agent/agents/swarm-worker-registry.md +46 -46
  33. package/.agent/agents/test-coverage-reviewer.md +132 -53
  34. package/.agent/agents/test-engineer.md +0 -21
  35. package/.agent/agents/type-safety-reviewer.md +143 -33
  36. package/.agent/patterns/generator.md +9 -9
  37. package/.agent/patterns/inversion.md +12 -12
  38. package/.agent/patterns/pipeline.md +9 -9
  39. package/.agent/patterns/reviewer.md +13 -13
  40. package/.agent/patterns/tool-wrapper.md +9 -9
  41. package/.agent/rules/GEMINI.md +63 -63
  42. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  43. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  44. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  45. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  46. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  47. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  48. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  49. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  50. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  51. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  52. package/.agent/scripts/compress_skills.py +167 -0
  53. package/.agent/scripts/consolidate_skills.py +173 -0
  54. package/.agent/scripts/deep_compress.py +202 -0
  55. package/.agent/scripts/minify_context.py +80 -0
  56. package/.agent/scripts/security_scan.py +1 -1
  57. package/.agent/scripts/strip_tribunal.py +41 -0
  58. package/.agent/skills/agent-organizer/SKILL.md +60 -100
  59. package/.agent/skills/agentic-patterns/SKILL.md +0 -70
  60. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +108 -53
  61. package/.agent/skills/api-patterns/SKILL.md +197 -257
  62. package/.agent/skills/api-security-auditor/SKILL.md +125 -57
  63. package/.agent/skills/app-builder/SKILL.md +326 -50
  64. package/.agent/skills/app-builder/templates/SKILL.md +13 -15
  65. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +16 -16
  66. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +22 -22
  67. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +18 -18
  68. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +20 -20
  69. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +17 -17
  70. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +18 -18
  71. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +21 -21
  72. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +19 -19
  73. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +26 -26
  74. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +26 -26
  75. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +19 -19
  76. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +18 -18
  77. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +20 -20
  78. package/.agent/skills/appflow-wireframe/SKILL.md +71 -98
  79. package/.agent/skills/architecture/SKILL.md +161 -200
  80. package/.agent/skills/authentication-best-practices/SKILL.md +121 -54
  81. package/.agent/skills/bash-linux/SKILL.md +71 -166
  82. package/.agent/skills/behavioral-modes/SKILL.md +8 -69
  83. package/.agent/skills/brainstorming/SKILL.md +345 -127
  84. package/.agent/skills/building-native-ui/SKILL.md +125 -57
  85. package/.agent/skills/clean-code/SKILL.md +266 -149
  86. package/.agent/skills/code-review-checklist/SKILL.md +0 -62
  87. package/.agent/skills/config-validator/SKILL.md +73 -131
  88. package/.agent/skills/csharp-developer/SKILL.md +434 -73
  89. package/.agent/skills/database-design/SKILL.md +190 -275
  90. package/.agent/skills/deployment-procedures/SKILL.md +81 -158
  91. package/.agent/skills/devops-engineer/SKILL.md +255 -94
  92. package/.agent/skills/devops-incident-responder/SKILL.md +50 -69
  93. package/.agent/skills/doc.md +5 -5
  94. package/.agent/skills/documentation-templates/SKILL.md +19 -63
  95. package/.agent/skills/edge-computing/SKILL.md +75 -165
  96. package/.agent/skills/extract-design-system/SKILL.md +84 -58
  97. package/.agent/skills/framer-motion-expert/SKILL.md +195 -0
  98. package/.agent/skills/frontend-design/SKILL.md +151 -499
  99. package/.agent/skills/game-design-expert/SKILL.md +71 -0
  100. package/.agent/skills/game-engineering-expert/SKILL.md +88 -0
  101. package/.agent/skills/geo-fundamentals/SKILL.md +52 -178
  102. package/.agent/skills/github-operations/SKILL.md +197 -272
  103. package/.agent/skills/gsap-expert/SKILL.md +194 -0
  104. package/.agent/skills/i18n-localization/SKILL.md +60 -172
  105. package/.agent/skills/intelligent-routing/SKILL.md +123 -103
  106. package/.agent/skills/lint-and-validate/SKILL.md +8 -52
  107. package/.agent/skills/llm-engineering/SKILL.md +281 -195
  108. package/.agent/skills/local-first/SKILL.md +76 -159
  109. package/.agent/skills/mcp-builder/SKILL.md +48 -188
  110. package/.agent/skills/mobile-design/SKILL.md +213 -219
  111. package/.agent/skills/motion-engineering/SKILL.md +184 -0
  112. package/.agent/skills/nextjs-react-expert/SKILL.md +184 -203
  113. package/.agent/skills/nodejs-best-practices/SKILL.md +403 -185
  114. package/.agent/skills/observability/SKILL.md +211 -203
  115. package/.agent/skills/parallel-agents/SKILL.md +53 -146
  116. package/.agent/skills/performance-profiling/SKILL.md +171 -151
  117. package/.agent/skills/plan-writing/SKILL.md +49 -153
  118. package/.agent/skills/platform-engineer/SKILL.md +57 -103
  119. package/.agent/skills/playwright-best-practices/SKILL.md +110 -63
  120. package/.agent/skills/powershell-windows/SKILL.md +61 -179
  121. package/.agent/skills/python-patterns/SKILL.md +7 -35
  122. package/.agent/skills/python-pro/SKILL.md +273 -114
  123. package/.agent/skills/react-specialist/SKILL.md +227 -108
  124. package/.agent/skills/readme-builder/SKILL.md +15 -85
  125. package/.agent/skills/realtime-patterns/SKILL.md +216 -243
  126. package/.agent/skills/red-team-tactics/SKILL.md +10 -51
  127. package/.agent/skills/rust-pro/SKILL.md +525 -142
  128. package/.agent/skills/seo-fundamentals/SKILL.md +92 -153
  129. package/.agent/skills/server-management/SKILL.md +110 -166
  130. package/.agent/skills/shadcn-ui-expert/SKILL.md +154 -55
  131. package/.agent/skills/skill-creator/SKILL.md +18 -58
  132. package/.agent/skills/sql-pro/SKILL.md +543 -68
  133. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +28 -68
  134. package/.agent/skills/swiftui-expert/SKILL.md +124 -57
  135. package/.agent/skills/systematic-debugging/SKILL.md +49 -151
  136. package/.agent/skills/tailwind-patterns/SKILL.md +433 -149
  137. package/.agent/skills/tdd-workflow/SKILL.md +63 -169
  138. package/.agent/skills/test-result-analyzer/SKILL.md +33 -73
  139. package/.agent/skills/testing-patterns/SKILL.md +437 -130
  140. package/.agent/skills/trend-researcher/SKILL.md +30 -71
  141. package/.agent/skills/ui-ux-pro-max/SKILL.md +0 -41
  142. package/.agent/skills/ui-ux-researcher/SKILL.md +51 -91
  143. package/.agent/skills/vue-expert/SKILL.md +225 -119
  144. package/.agent/skills/vulnerability-scanner/SKILL.md +264 -226
  145. package/.agent/skills/web-accessibility-auditor/SKILL.md +141 -58
  146. package/.agent/skills/web-design-guidelines/SKILL.md +17 -61
  147. package/.agent/skills/webapp-testing/SKILL.md +71 -196
  148. package/.agent/skills/whimsy-injector/SKILL.md +58 -132
  149. package/.agent/skills/workflow-optimizer/SKILL.md +28 -68
  150. package/.agent/workflows/api-tester.md +96 -224
  151. package/.agent/workflows/audit.md +81 -122
  152. package/.agent/workflows/brainstorm.md +69 -105
  153. package/.agent/workflows/changelog.md +65 -97
  154. package/.agent/workflows/create.md +73 -88
  155. package/.agent/workflows/debug.md +80 -111
  156. package/.agent/workflows/deploy.md +119 -92
  157. package/.agent/workflows/enhance.md +80 -91
  158. package/.agent/workflows/fix.md +68 -97
  159. package/.agent/workflows/generate.md +165 -164
  160. package/.agent/workflows/migrate.md +106 -109
  161. package/.agent/workflows/orchestrate.md +103 -86
  162. package/.agent/workflows/performance-benchmarker.md +77 -268
  163. package/.agent/workflows/plan.md +120 -98
  164. package/.agent/workflows/preview.md +39 -96
  165. package/.agent/workflows/refactor.md +105 -97
  166. package/.agent/workflows/review-ai.md +63 -102
  167. package/.agent/workflows/review.md +71 -110
  168. package/.agent/workflows/session.md +53 -113
  169. package/.agent/workflows/status.md +42 -88
  170. package/.agent/workflows/strengthen-skills.md +90 -51
  171. package/.agent/workflows/swarm.md +114 -129
  172. package/.agent/workflows/test.md +125 -102
  173. package/.agent/workflows/tribunal-backend.md +60 -78
  174. package/.agent/workflows/tribunal-database.md +62 -100
  175. package/.agent/workflows/tribunal-frontend.md +62 -82
  176. package/.agent/workflows/tribunal-full.md +56 -100
  177. package/.agent/workflows/tribunal-mobile.md +65 -94
  178. package/.agent/workflows/tribunal-performance.md +62 -105
  179. package/.agent/workflows/ui-ux-pro-max.md +72 -121
  180. package/README.md +11 -15
  181. package/package.json +1 -1
  182. package/.agent/skills/api-patterns/api-style.md +0 -42
  183. package/.agent/skills/api-patterns/auth.md +0 -24
  184. package/.agent/skills/api-patterns/documentation.md +0 -26
  185. package/.agent/skills/api-patterns/graphql.md +0 -41
  186. package/.agent/skills/api-patterns/rate-limiting.md +0 -31
  187. package/.agent/skills/api-patterns/response.md +0 -37
  188. package/.agent/skills/api-patterns/rest.md +0 -40
  189. package/.agent/skills/api-patterns/security-testing.md +0 -122
  190. package/.agent/skills/api-patterns/trpc.md +0 -41
  191. package/.agent/skills/api-patterns/versioning.md +0 -22
  192. package/.agent/skills/app-builder/agent-coordination.md +0 -71
  193. package/.agent/skills/app-builder/feature-building.md +0 -53
  194. package/.agent/skills/app-builder/project-detection.md +0 -34
  195. package/.agent/skills/app-builder/scaffolding.md +0 -118
  196. package/.agent/skills/app-builder/tech-stack.md +0 -40
  197. package/.agent/skills/architecture/context-discovery.md +0 -43
  198. package/.agent/skills/architecture/examples.md +0 -94
  199. package/.agent/skills/architecture/pattern-selection.md +0 -68
  200. package/.agent/skills/architecture/patterns-reference.md +0 -50
  201. package/.agent/skills/architecture/trade-off-analysis.md +0 -77
  202. package/.agent/skills/brainstorming/dynamic-questioning.md +0 -360
  203. package/.agent/skills/database-design/database-selection.md +0 -43
  204. package/.agent/skills/database-design/indexing.md +0 -39
  205. package/.agent/skills/database-design/migrations.md +0 -48
  206. package/.agent/skills/database-design/optimization.md +0 -36
  207. package/.agent/skills/database-design/orm-selection.md +0 -30
  208. package/.agent/skills/database-design/schema-design.md +0 -56
  209. package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
  210. package/.agent/skills/framer-motion-animations/SKILL.md +0 -74
  211. package/.agent/skills/frontend-design/animation-guide.md +0 -331
  212. package/.agent/skills/frontend-design/color-system.md +0 -329
  213. package/.agent/skills/frontend-design/decision-trees.md +0 -418
  214. package/.agent/skills/frontend-design/motion-graphics.md +0 -306
  215. package/.agent/skills/frontend-design/typography-system.md +0 -363
  216. package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
  217. package/.agent/skills/frontend-design/visual-effects.md +0 -383
  218. package/.agent/skills/game-development/2d-games/SKILL.md +0 -119
  219. package/.agent/skills/game-development/3d-games/SKILL.md +0 -135
  220. package/.agent/skills/game-development/SKILL.md +0 -236
  221. package/.agent/skills/game-development/game-art/SKILL.md +0 -185
  222. package/.agent/skills/game-development/game-audio/SKILL.md +0 -190
  223. package/.agent/skills/game-development/game-design/SKILL.md +0 -129
  224. package/.agent/skills/game-development/mobile-games/SKILL.md +0 -108
  225. package/.agent/skills/game-development/multiplayer/SKILL.md +0 -132
  226. package/.agent/skills/game-development/pc-games/SKILL.md +0 -144
  227. package/.agent/skills/game-development/vr-ar/SKILL.md +0 -123
  228. package/.agent/skills/game-development/web-games/SKILL.md +0 -150
  229. package/.agent/skills/intelligent-routing/router-manifest.md +0 -65
  230. package/.agent/skills/mobile-design/decision-trees.md +0 -516
  231. package/.agent/skills/mobile-design/mobile-backend.md +0 -491
  232. package/.agent/skills/mobile-design/mobile-color-system.md +0 -420
  233. package/.agent/skills/mobile-design/mobile-debugging.md +0 -122
  234. package/.agent/skills/mobile-design/mobile-design-thinking.md +0 -357
  235. package/.agent/skills/mobile-design/mobile-navigation.md +0 -458
  236. package/.agent/skills/mobile-design/mobile-performance.md +0 -767
  237. package/.agent/skills/mobile-design/mobile-testing.md +0 -356
  238. package/.agent/skills/mobile-design/mobile-typography.md +0 -433
  239. package/.agent/skills/mobile-design/platform-android.md +0 -666
  240. package/.agent/skills/mobile-design/platform-ios.md +0 -561
  241. package/.agent/skills/mobile-design/touch-psychology.md +0 -537
  242. package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +0 -312
  243. package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +0 -240
  244. package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +0 -490
  245. package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +0 -264
  246. package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +0 -581
  247. package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +0 -432
  248. package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +0 -684
  249. package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +0 -150
  250. package/.agent/skills/vulnerability-scanner/checklists.md +0 -121
@@ -1,181 +1,88 @@
1
1
  ---
2
2
  name: parallel-agents
3
- description: Multi-agent orchestration patterns. Use when multiple independent tasks can run with different domain expertise or when comprehensive analysis requires multiple perspectives.
3
+ description: Parallel processing coordination for multi-agent swarms. Asynchronous dispatches, merging divergent logic streams, race conditions in autonomous agents, avoiding Git conflicts in concurrent generation, and fan-out/fan-in processing patterns. Use when orchestrating multiple agents simultaneously.
4
4
  allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 1.0.0
6
- last-updated: 2026-03-12
5
+ version: 2.0.0
6
+ last-updated: 2026-04-02
7
7
  applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
8
  ---
9
9
 
10
- # Multi-Agent Orchestration
11
-
12
- > Parallel agents are faster. They are also harder to keep consistent.
13
- > Coordinate them — don't just fire them simultaneously and hope for compatible outputs.
14
-
15
- ---
16
-
17
- ## When to Use Parallel Agents
18
-
19
- Use multiple agents when:
20
- - Tasks are genuinely **independent** (output of A doesn't feed input of B)
21
- - Different tasks require **different domain expertise**
22
- - Comprehensive **review** needs multiple specialist perspectives simultaneously
23
- - Speed matters and tasks can be assigned and awaited independently
24
-
25
- Do **not** use parallel agents when:
26
- - Tasks have sequential dependencies (you need the result to start the next)
27
- - The overhead of coordination exceeds the time saved
10
+ # Parallel Agents — Concurrent Orchestration Mastery
28
11
 
29
12
  ---
30
13
 
31
- ## Orchestration Patterns
14
+ ## 1. Fan-Out / Fan-In Pattern
32
15
 
33
- ### Pattern 1 Parallel Review (Tribunal)
16
+ The foundation of parallel multi-agent architecture.
34
17
 
35
- Multiple reviewers look at the same code simultaneously, each from a different angle.
18
+ 1. **Fan-Out (Scatter):** A central Supervisor breaks an objective into isolated pieces, dispatching them concurrently across multiple independent Worker agents.
19
+ 2. **Execute:** The Workers process simultaneously without blocking one another.
20
+ 3. **Fan-In (Gather):** The Supervisor waits for ALL promises to resolve, collects the outputs, merges them logically, and assesses the final unified state.
36
21
 
37
- ```
38
- Code (input)
39
- ├── logic-reviewer → finds logic errors
40
- ├── → security-auditor → finds vulnerabilities
41
- ├── type-safety-reviewer → finds type unsafe code
42
- └── performance-reviewer finds bottlenecks
43
-
44
- All verdicts synthesize Human Gate (approve/reject/revise)
45
- ```
22
+ ```typescript
23
+ // Architectural representation (Fan-out/Fan-in)
24
+ async function executeParallelAudit(sourceCode: string) {
25
+ // Fan-Out
26
+ const promises = [
27
+ agentDispatch({ role: 'security-auditor', task: sourceCode }),
28
+ agentDispatch({ role: 'performance-profiling', task: sourceCode }),
29
+ agentDispatch({ role: 'web-accessibility-auditor', task: sourceCode })
30
+ ];
46
31
 
47
- **When:** `/tribunal-*` commands, code review before merge
32
+ // Await concurrent resolution
33
+ // If one takes 10s and another takes 2s, the total wait is max(10s)
34
+ const [securityReport, perfReport, a11yReport] = await Promise.all(promises);
48
35
 
49
- ### Pattern 2 — Domain Specialization
50
-
51
- Different specialists handle different parts of the same task simultaneously.
52
-
53
- ```
54
- "Build a user auth system" (input)
55
- ├── → backend-specialist → API routes + JWT logic
56
- ├── → frontend-specialist → Login/register UI
57
- └── → database-architect → User schema + sessions table
58
-
59
- All outputs → orchestrator synthesizes into coherent system
60
- (ensures API contract matches what frontend calls,
61
- and DB schema matches what backend queries)
62
- ```
63
-
64
- **When:** Full-stack feature builds via `/orchestrate`
65
-
66
- ### Pattern 3 — Sequential with Parallel Phases
67
-
68
- Some tasks are inherently sequential at the macro level but can parallelize within each phase.
69
-
70
- ```
71
- Phase 1 (sequential):
72
- database-architect → schema design
73
-
74
- Phase 2 (parallel, after Phase 1):
75
- backend-specialist → API uses schema from Phase 1
76
- frontend-specialist → UI uses API contract from Phase 2a (estimated)
77
-
78
- Phase 3 (sequential, after Phase 2):
79
- test-engineer → E2E tests with real API + UI
36
+ // Fan-In Synthesization
37
+ return synthesizeReports({ securityReport, perfReport, a11yReport });
38
+ }
80
39
  ```
81
40
 
82
41
  ---
83
42
 
84
- ## Orchestrator Responsibilities
43
+ ## 2. Preventing Workspace Collision Risks
85
44
 
86
- The orchestrator coordinates agents. It:
45
+ When multiple agents write to disk concurrently, catastrophic race conditions occur.
87
46
 
88
- 1. **Assigns scope** each agent gets exactly what it needs, nothing more
89
- 2. **Manages state** passes the right outputs from each agent to the next that needs them
90
- 3. **Resolves conflicts** when two agents propose incompatible solutions, the orchestrator decides or asks the user
91
- 4. **Verifies consistency** ensures that the API contract the backend builds matches what the frontend calls
47
+ **The Golden Rules of Parallel Agents:**
48
+ 1. **Never allow concurrent agents to modify the same file.** Standard Git/File lockers will fail. The last one to save entirely overwrites the changes of the others.
49
+ 2. **Read-Only Concurrency:** It is infinitely safe to run 10 agents reading and reviewing the same directory simultaneously.
50
+ 3. **Directory Isolation:** If multiple agents MUST generate code simultaneously, enforce strict boundaries. Add boundary guards instructing Agent A to stay out of the directories Agent B is designated to manipulate.
92
51
 
93
52
  ---
94
53
 
95
- ## Consistency Rules for Multi-Agent Output
96
-
97
- The biggest failure in parallel agent work is **inconsistency at boundaries**:
54
+ ## 3. Reviewer Swarms (The Tribunal Principle)
98
55
 
99
- - Backend generates `userId` but frontend calls it `user_id`
100
- - Database schema has `user_email` but backend queries `email`
101
- - Agent A designs one error shape; Agent B assumes a different one
56
+ The Tribunal uses parallel processing exclusively for the review phase to drastically speed up output validation without slowing down the user.
102
57
 
103
- **Prevention:**
104
- - Establish contracts (types, schemas, API shapes) **before** parallel work begins
105
- - Each agent receives the shared contract as context
106
- - Orchestrator reviews all outputs for boundary consistency before presenting to user
58
+ - **The Maker:** Generates code (Sequential, isolated).
59
+ - **The Reviewers:** 4x Reviewer Agents analyze the Maker's generated code simultaneously from independent angles (Security, Typing, Logic, Performance).
60
+ - **The Gate:** The outputs merge into a synthesis report for human approval.
107
61
 
108
62
  ---
109
63
 
110
- ## Communication Format Between Agents
64
+ ## 4. Handling Differential Failures
111
65
 
112
- When one agent's output feeds another:
66
+ What happens when 4 parallel tasks run, and 1 fails?
67
+ Does the whole pipeline crash?
113
68
 
114
- ```
115
- [AGENT: backend-specialist OUTPUT]
116
- API Contract:
117
- POST /api/users → { id: string, email: string, createdAt: string }
118
- POST /api/auth/login → { token: string, expiresAt: string }
69
+ ```typescript
70
+ // ❌ BAD: Promise.all fails instantly if ANY sub-agent crashes or hallucinates
71
+ const results = await Promise.all(agentJobs);
119
72
 
120
- [AGENT: frontend-specialist RECEIVES]
121
- Use the above API contract. Build the UI to match these exact request/response shapes.
122
- ```
73
+ // ✅ GOOD: Use Promise.allSettled to ensure resilient aggregation
74
+ const results = await Promise.allSettled(agentJobs);
123
75
 
124
- ---
125
-
126
- ## Output Format
127
-
128
- When this skill completes a task, structure your output as:
129
-
130
- ```
131
- ━━━ Parallel Agents Output ━━━━━━━━━━━━━━━━━━━━━━━━
132
- Task: [what was performed]
133
- Result: [outcome summary — one line]
134
- ─────────────────────────────────────────────────
135
- Checks: ✅ [N passed] · ⚠️ [N warnings] · ❌ [N blocked]
136
- VBC status: PENDING → VERIFIED
137
- Evidence: [link to terminal output, test result, or file diff]
76
+ for (const result of results) {
77
+ if (result.status === 'fulfilled') {
78
+ aggregatedOutput.push(result.value);
79
+ } else {
80
+ // 1 agent failed (e.g. rate limit, or runtime crash)
81
+ // The supervisor can retry just this branch, or proceed with partial success
82
+ logger.warn(`Sub-agent sequence failed: ${result.reason}`);
83
+ flagForHumanReview(result.reason);
84
+ }
85
+ }
138
86
  ```
139
87
 
140
-
141
-
142
- ---
143
-
144
- ## 🤖 LLM-Specific Traps
145
-
146
- AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
147
-
148
- 1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
149
- 2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
150
- 3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
151
- 4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
152
- 5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
153
-
154
88
  ---
155
-
156
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
157
-
158
- **Slash command: `/review` or `/tribunal-full`**
159
- **Active reviewers: `logic-reviewer` · `security-auditor`**
160
-
161
- ### ❌ Forbidden AI Tropes
162
-
163
- 1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
164
- 2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
165
- 3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
166
-
167
- ### ✅ Pre-Flight Self-Audit
168
-
169
- Review these questions before confirming output:
170
- ```
171
- ✅ Did I rely ONLY on real, verified tools and methods?
172
- ✅ Is this solution appropriately scoped to the user's constraints?
173
- ✅ Did I handle potential failure modes and edge cases?
174
- ✅ Have I avoided generic boilerplate that doesn't add value?
175
- ```
176
-
177
- ### 🛑 Verification-Before-Completion (VBC) Protocol
178
-
179
- **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
180
- - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
181
- - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
@@ -1,197 +1,217 @@
1
1
  ---
2
2
  name: performance-profiling
3
- description: Performance profiling principles. Measurement, analysis, and optimization techniques.
3
+ description: Performance profiling mastery. Core Web Vitals (LCP, CLS, INP), Lighthouse auditing, JavaScript profiling, React rendering optimization, bundle analysis, memory leak detection, database query profiling (EXPLAIN ANALYZE), load testing, and performance budgets. Use when optimizing performance, debugging slow pages, or establishing performance standards.
4
4
  allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 1.0.0
6
- last-updated: 2026-03-12
5
+ version: 2.0.0
6
+ last-updated: 2026-04-01
7
7
  applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
8
  ---
9
9
 
10
- # Performance Profiling Principles
11
-
12
- > Never optimize code you haven't measured.
13
- > The bottleneck is almost never where you expect it to be.
10
+ # Performance Profiling — Measurement-Driven Optimization
14
11
 
15
12
  ---
16
13
 
17
- ## The Measurement-First Rule
18
-
19
- Every performance investigation follows the same sequence:
14
+ ## Core Web Vitals
20
15
 
21
16
  ```
22
- Measure Identify hotspotForm hypothesis → Change one thing → Measure again
17
+ LCP (Largest Contentful Paint)Loading speed
18
+ ✅ Good: ≤ 2.5s │ ⚠️ Needs work: 2.5-4s │ ❌ Poor: > 4s
19
+ What: Time until the largest visible element renders
20
+ Fix: Optimize images, preload fonts, reduce server time
21
+
22
+ INP (Interaction to Next Paint) → Responsiveness
23
+ ✅ Good: ≤ 200ms │ ⚠️ Needs work: 200-500ms │ ❌ Poor: > 500ms
24
+ What: Delay between user interaction and visual response
25
+ Fix: Break long tasks, use web workers, defer non-critical JS
26
+
27
+ CLS (Cumulative Layout Shift) → Visual stability
28
+ ✅ Good: ≤ 0.1 │ ⚠️ Needs work: 0.1-0.25 │ ❌ Poor: > 0.25
29
+ What: How much the page layout shifts unexpectedly
30
+ Fix: Set explicit dimensions on images/ads, font-display: swap
31
+
32
+ TTFB (Time to First Byte) → Server responsiveness
33
+ ✅ Good: ≤ 800ms
34
+ Fix: CDN, caching, optimize database queries, use edge
35
+
36
+ // ❌ HALLUCINATION TRAP: FID is deprecated. Use INP (Interaction to Next Paint).
37
+ // FID only measured the FIRST interaction. INP measures ALL interactions.
23
38
  ```
24
39
 
25
- Breaking this sequence — jumping straight to "fix" — wastes time and creates new problems.
26
-
27
40
  ---
28
41
 
29
- ## What to Measure
42
+ ## JavaScript Profiling
30
43
 
31
- ### Backend
44
+ ### Bundle Analysis
32
45
 
33
- | Metric | Tool | Target |
34
- |---|---|---|
35
- | Request throughput | ab, k6, wrk | Baseline + stress test |
36
- | P50/P95/P99 latency | DataDog, Grafana, k6 | P99 < SLA threshold |
37
- | Memory usage | `process.memoryUsage()`, heap snapshot | Stable under load (no growth) |
38
- | CPU usage | clinic.js flame chart | Identify blocking operations |
39
- | Database query time | Query logs, pg_stat_statements | No query > 100ms without index |
46
+ ```bash
47
+ # Analyze what's in your JavaScript bundle
48
+ npx vite-bundle-visualizer # Vite
49
+ npx @next/bundle-analyzer # Next.js
40
50
 
41
- ### Frontend
42
-
43
- | Metric | Tool | Target (2025 Core Web Vitals) |
44
- |---|---|---|
45
- | LCP (Largest Contentful Paint) | Lighthouse, CrUX | < 2.5s |
46
- | INP (Interaction to Next Paint) | Lighthouse, Web Vitals | < 200ms |
47
- | CLS (Cumulative Layout Shift) | Lighthouse | < 0.1 |
48
- | Bundle size (JS) | `npm run build` + analyzer | < 200kB initial JS |
49
-
50
- ---
51
-
52
- ## Common Backend Bottlenecks
53
-
54
- ### N+1 Queries (most common)
55
-
56
- ```ts
57
- // ❌ 1 + N queries
58
- const posts = await db.post.findMany();
59
- for (const post of posts) {
60
- post.author = await db.user.findUnique({ where: { id: post.authorId } });
61
- }
62
-
63
- // ✅ 2 queries total
64
- const posts = await db.post.findMany({ include: { author: true } });
51
+ # Key targets:
52
+ # Total JS < 200KB (gzipped) for initial load
53
+ # No single dependency > 50KB (gzipped)
54
+ # Tree-shaking working (no dead code)
65
55
  ```
66
56
 
67
- **Detection:** Enable query logging. Repeated identical queries differing only by ID = N+1.
57
+ ```typescript
58
+ // Common bundle bloat sources:
59
+ // ❌ import _ from "lodash"; // 72KB — imports everything
60
+ // ✅ import debounce from "lodash/debounce"; // 1KB — specific import
68
61
 
69
- ### Missing Database Indexes
62
+ // import { format } from "date-fns"; // may import entire library
63
+ // ✅ import { format } from "date-fns/format"; // specific import
70
64
 
71
- ```sql
72
- -- EXPLAIN ANALYZE tells you if a query is doing a sequential scan
73
- EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = $1;
74
-
75
- -- Sequential scan on large table → add index
76
- CREATE INDEX idx_orders_user_id ON orders(user_id);
77
- ```
78
-
79
- ### Blocking the Event Loop (Node.js)
80
-
81
- ```ts
82
- // ❌ Synchronous CPU work blocks all requests
83
- const result = JSON.parse(fs.readFileSync('huge.json', 'utf8'));
84
-
85
- // ✅ Non-blocking
86
- const content = await fs.promises.readFile('huge.json', 'utf8');
87
- const result = JSON.parse(content); // still sync but no disk I/O blocking
65
+ // ❌ import moment from "moment"; // 67KB + locales
66
+ // Use native Intl.DateTimeFormat or date-fns (tree-shakeable)
88
67
  ```
89
68
 
90
- ---
91
-
92
- ## Common Frontend Bottlenecks
69
+ ### React Rendering Profiling
93
70
 
94
- ### Bundle Size
71
+ ```typescript
72
+ // React DevTools Profiler — find unnecessary re-renders
95
73
 
96
- - Identify large packages with `npx vite-bundle-visualizer` or `@next/bundle-analyzer`
97
- - Replace heavy packages with lighter alternatives (e.g., `date-fns` instead of `moment`)
98
- - Code-split routes — don't ship all JavaScript on first load
74
+ // 1. Why Did You Render (development tool)
75
+ // npm i @welldone-software/why-did-you-render -D
99
76
 
100
- ### Render Performance
77
+ // 2. Manual render tracking
78
+ const RenderCounter = ({ label }: { label: string }) => {
79
+ const renderCount = useRef(0);
80
+ renderCount.current++;
81
+ console.log(`[${label}] rendered ${renderCount.current} times`);
82
+ return null;
83
+ };
101
84
 
102
- ```ts
103
- // Recalculates on every render
104
- function ExpensiveList({ items }) {
105
- const sorted = items.sort((a, b) => a.name.localeCompare(b.name));
106
- return sorted.map(item => <Item key={item.id} item={item} />);
107
- }
85
+ // 3. React.memo — prevent re-renders when props haven't changed
86
+ const ExpensiveList = React.memo(function ExpensiveList({ items }: Props) {
87
+ return items.map((item) => <ListItem key={item.id} {...item} />);
88
+ });
108
89
 
109
- // Recalculates only when items change
110
- function ExpensiveList({ items }) {
111
- const sorted = useMemo(
112
- () => [...items].sort((a, b) => a.name.localeCompare(b.name)),
113
- [items]
114
- );
115
- return sorted.map(item => <Item key={item.id} item={item} />);
116
- }
90
+ // 4. useMemo / useCallback memoize expensive computations
91
+ const sortedItems = useMemo(
92
+ () => items.toSorted((a, b) => a.name.localeCompare(b.name)),
93
+ [items],
94
+ );
117
95
  ```
118
96
 
119
- ---
120
-
121
- ## Profiling Tools
122
-
123
- | Tool | Platform | Best For |
124
- |---|---|---|
125
- | `clinic.js` (`clinic doctor`) | Node.js | CPU flame charts, memory leaks |
126
- | Chrome DevTools → Performance | Browser | JS execution, paint, layout |
127
- | `EXPLAIN ANALYZE` | PostgreSQL | Query plan analysis |
128
- | Lighthouse | Web | Full Core Web Vitals audit |
129
- | `k6` | Backend load testing | Throughput and latency under load |
130
-
131
- ---
132
-
133
- ## Scripts
134
-
135
- | Script | Purpose | Run With |
136
- |---|---|---|
137
- | `scripts/lighthouse_audit.py` | Lighthouse performance audit | `python scripts/lighthouse_audit.py <url>` |
97
+ ### Memory Leak Detection
98
+
99
+ ```typescript
100
+ // Common memory leaks in JavaScript:
101
+ // 1. Event listeners not cleaned up
102
+ useEffect(() => {
103
+ const handler = () => console.log("resize");
104
+ window.addEventListener("resize", handler);
105
+ return () => window.removeEventListener("resize", handler); // cleanup
106
+ }, []);
107
+
108
+ // 2. Timers not cleared
109
+ useEffect(() => {
110
+ const interval = setInterval(pollData, 5000);
111
+ return () => clearInterval(interval); // ✅ cleanup
112
+ }, []);
113
+
114
+ // 3. AbortController not used for fetch
115
+ useEffect(() => {
116
+ const controller = new AbortController();
117
+ fetch("/api/data", { signal: controller.signal })
118
+ .then((res) => res.json())
119
+ .then(setData)
120
+ .catch((e) => { if (e.name !== "AbortError") throw e; });
121
+ return () => controller.abort(); // ✅ cancel on unmount
122
+ }, []);
123
+
124
+ // Detection: Chrome DevTools → Memory → Heap Snapshot
125
+ // Take snapshot, perform action, take another, compare growth
126
+ ```
138
127
 
139
128
  ---
140
129
 
141
- ## Output Format
142
-
143
- When this skill produces a recommendation or design decision, structure your output as:
144
-
145
- ```
146
- ━━━ Performance Profiling Recommendation ━━━━━━━━━━━━━━━━
147
- Decision: [what was chosen / proposed]
148
- Rationale: [why one concise line]
149
- Trade-offs: [what is consciously accepted]
150
- Next action: [concrete next step for the user]
151
- ─────────────────────────────────────────────────
152
- Pre-Flight: ✅ All checks passed
153
- or ❌ [blocking item that must be resolved first]
130
+ ## Image Optimization
131
+
132
+ ```html
133
+ <!-- Modern image loading -->
134
+ <img
135
+ src="hero.webp"
136
+ srcset="hero-480.webp 480w, hero-768.webp 768w, hero-1200.webp 1200w"
137
+ sizes="(max-width: 768px) 100vw, 50vw"
138
+ width="1200"
139
+ height="800"
140
+ loading="lazy"
141
+ decoding="async"
142
+ alt="Product hero"
143
+ fetchpriority="high"
144
+ />
145
+
146
+ <!-- Rules:
147
+ - ALWAYS set width and height (prevents CLS)
148
+ - Use WebP/AVIF (30-50% smaller than JPEG)
149
+ - loading="lazy" for below-the-fold images
150
+ - fetchpriority="high" for LCP image
151
+ - Use srcset for responsive images
152
+ - Serve from CDN with auto-format negotiation
153
+ -->
154
154
  ```
155
155
 
156
-
157
-
158
156
  ---
159
157
 
160
- ## 🤖 LLM-Specific Traps
158
+ ## Database Query Profiling
161
159
 
162
- AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
163
-
164
- 1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
165
- 2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
166
- 3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
167
- 4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
168
- 5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
160
+ ```sql
161
+ -- Always EXPLAIN before optimizing
162
+ EXPLAIN ANALYZE SELECT u.*, COUNT(p.id) AS post_count
163
+ FROM users u
164
+ LEFT JOIN posts p ON p.author_id = u.id
165
+ WHERE u.is_active = true
166
+ GROUP BY u.id
167
+ ORDER BY post_count DESC
168
+ LIMIT 20;
169
+
170
+ -- Look for:
171
+ -- Seq Scan → needs an index (on large tables)
172
+ -- Nested Loop → consider index or different join strategy
173
+ -- Sort → can an index provide sorted data?
174
+ -- execution time > 100ms → optimize
175
+
176
+ -- Common fixes:
177
+ -- Add index: CREATE INDEX idx_posts_author ON posts (author_id);
178
+ -- Use partial index: CREATE INDEX idx_active_users ON users (id) WHERE is_active;
179
+ -- Avoid SELECT *: SELECT only needed columns
180
+ -- Paginate with cursor: WHERE id > $cursor ORDER BY id LIMIT 20
181
+ ```
169
182
 
170
183
  ---
171
184
 
172
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
173
-
174
- **Slash command: `/review` or `/tribunal-full`**
175
- **Active reviewers: `logic-reviewer` · `security-auditor`**
176
-
177
- ### Forbidden AI Tropes
178
-
179
- 1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
180
- 2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
181
- 3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
182
-
183
- ### Pre-Flight Self-Audit
185
+ ## Performance Budgets
186
+
187
+ ```javascript
188
+ // Lighthouse CI budget
189
+ // lighthouserc.js
190
+ module.exports = {
191
+ ci: {
192
+ assert: {
193
+ assertions: {
194
+ "categories:performance": ["error", { minScore: 0.9 }],
195
+ "first-contentful-paint": ["error", { maxNumericValue: 1500 }],
196
+ "largest-contentful-paint": ["error", { maxNumericValue: 2500 }],
197
+ "cumulative-layout-shift": ["error", { maxNumericValue: 0.1 }],
198
+ "total-byte-weight": ["error", { maxNumericValue: 500000 }],
199
+ },
200
+ },
201
+ },
202
+ };
203
+ ```
184
204
 
185
- Review these questions before confirming output:
186
205
  ```
187
- Did I rely ONLY on real, verified tools and methods?
188
- Is this solution appropriately scoped to the user's constraints?
189
- Did I handle potential failure modes and edge cases?
190
- Have I avoided generic boilerplate that doesn't add value?
206
+ Performance budget targets:
207
+ Total JS (gzipped): < 200KB
208
+ Total CSS (gzipped): < 50KB
209
+ Total page weight: < 500KB
210
+ LCP: < 2.5s
211
+ INP: < 200ms
212
+ CLS: < 0.1
213
+ TTFB: < 800ms
214
+ Time to Interactive: < 3.8s
191
215
  ```
192
216
 
193
- ### 🛑 Verification-Before-Completion (VBC) Protocol
194
-
195
- **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
196
- - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
197
- - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
217
+ ---