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.
- package/.agent/ARCHITECTURE.md +99 -99
- package/.agent/GEMINI.md +52 -52
- package/.agent/agents/accessibility-reviewer.md +139 -86
- package/.agent/agents/ai-code-reviewer.md +160 -90
- package/.agent/agents/backend-specialist.md +164 -127
- package/.agent/agents/code-archaeologist.md +115 -73
- package/.agent/agents/database-architect.md +130 -110
- package/.agent/agents/debugger.md +137 -97
- package/.agent/agents/dependency-reviewer.md +78 -30
- package/.agent/agents/devops-engineer.md +161 -118
- package/.agent/agents/documentation-writer.md +151 -87
- package/.agent/agents/explorer-agent.md +117 -99
- package/.agent/agents/frontend-reviewer.md +127 -47
- package/.agent/agents/frontend-specialist.md +169 -109
- package/.agent/agents/game-developer.md +28 -164
- package/.agent/agents/logic-reviewer.md +87 -49
- package/.agent/agents/mobile-developer.md +151 -103
- package/.agent/agents/mobile-reviewer.md +133 -50
- package/.agent/agents/orchestrator.md +121 -110
- package/.agent/agents/penetration-tester.md +103 -77
- package/.agent/agents/performance-optimizer.md +136 -92
- package/.agent/agents/performance-reviewer.md +139 -69
- package/.agent/agents/product-manager.md +104 -70
- package/.agent/agents/product-owner.md +6 -25
- package/.agent/agents/project-planner.md +95 -95
- package/.agent/agents/qa-automation-engineer.md +174 -87
- package/.agent/agents/security-auditor.md +133 -129
- package/.agent/agents/seo-specialist.md +160 -99
- package/.agent/agents/sql-reviewer.md +132 -44
- package/.agent/agents/supervisor-agent.md +137 -109
- package/.agent/agents/swarm-worker-contracts.md +17 -17
- package/.agent/agents/swarm-worker-registry.md +46 -46
- package/.agent/agents/test-coverage-reviewer.md +132 -53
- package/.agent/agents/test-engineer.md +0 -21
- package/.agent/agents/type-safety-reviewer.md +143 -33
- package/.agent/patterns/generator.md +9 -9
- package/.agent/patterns/inversion.md +12 -12
- package/.agent/patterns/pipeline.md +9 -9
- package/.agent/patterns/reviewer.md +13 -13
- package/.agent/patterns/tool-wrapper.md +9 -9
- package/.agent/rules/GEMINI.md +63 -63
- package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
- package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
- package/.agent/scripts/compress_skills.py +167 -0
- package/.agent/scripts/consolidate_skills.py +173 -0
- package/.agent/scripts/deep_compress.py +202 -0
- package/.agent/scripts/minify_context.py +80 -0
- package/.agent/scripts/security_scan.py +1 -1
- package/.agent/scripts/strip_tribunal.py +41 -0
- package/.agent/skills/agent-organizer/SKILL.md +60 -100
- package/.agent/skills/agentic-patterns/SKILL.md +0 -70
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +108 -53
- package/.agent/skills/api-patterns/SKILL.md +197 -257
- package/.agent/skills/api-security-auditor/SKILL.md +125 -57
- package/.agent/skills/app-builder/SKILL.md +326 -50
- package/.agent/skills/app-builder/templates/SKILL.md +13 -15
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +16 -16
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +22 -22
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +18 -18
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +20 -20
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +17 -17
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +18 -18
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +21 -21
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +19 -19
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +26 -26
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +26 -26
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +19 -19
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +18 -18
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +20 -20
- package/.agent/skills/appflow-wireframe/SKILL.md +71 -98
- package/.agent/skills/architecture/SKILL.md +161 -200
- package/.agent/skills/authentication-best-practices/SKILL.md +121 -54
- package/.agent/skills/bash-linux/SKILL.md +71 -166
- package/.agent/skills/behavioral-modes/SKILL.md +8 -69
- package/.agent/skills/brainstorming/SKILL.md +345 -127
- package/.agent/skills/building-native-ui/SKILL.md +125 -57
- package/.agent/skills/clean-code/SKILL.md +266 -149
- package/.agent/skills/code-review-checklist/SKILL.md +0 -62
- package/.agent/skills/config-validator/SKILL.md +73 -131
- package/.agent/skills/csharp-developer/SKILL.md +434 -73
- package/.agent/skills/database-design/SKILL.md +190 -275
- package/.agent/skills/deployment-procedures/SKILL.md +81 -158
- package/.agent/skills/devops-engineer/SKILL.md +255 -94
- package/.agent/skills/devops-incident-responder/SKILL.md +50 -69
- package/.agent/skills/doc.md +5 -5
- package/.agent/skills/documentation-templates/SKILL.md +19 -63
- package/.agent/skills/edge-computing/SKILL.md +75 -165
- package/.agent/skills/extract-design-system/SKILL.md +84 -58
- package/.agent/skills/framer-motion-expert/SKILL.md +195 -0
- package/.agent/skills/frontend-design/SKILL.md +151 -499
- package/.agent/skills/game-design-expert/SKILL.md +71 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +88 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +52 -178
- package/.agent/skills/github-operations/SKILL.md +197 -272
- package/.agent/skills/gsap-expert/SKILL.md +194 -0
- package/.agent/skills/i18n-localization/SKILL.md +60 -172
- package/.agent/skills/intelligent-routing/SKILL.md +123 -103
- package/.agent/skills/lint-and-validate/SKILL.md +8 -52
- package/.agent/skills/llm-engineering/SKILL.md +281 -195
- package/.agent/skills/local-first/SKILL.md +76 -159
- package/.agent/skills/mcp-builder/SKILL.md +48 -188
- package/.agent/skills/mobile-design/SKILL.md +213 -219
- package/.agent/skills/motion-engineering/SKILL.md +184 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +184 -203
- package/.agent/skills/nodejs-best-practices/SKILL.md +403 -185
- package/.agent/skills/observability/SKILL.md +211 -203
- package/.agent/skills/parallel-agents/SKILL.md +53 -146
- package/.agent/skills/performance-profiling/SKILL.md +171 -151
- package/.agent/skills/plan-writing/SKILL.md +49 -153
- package/.agent/skills/platform-engineer/SKILL.md +57 -103
- package/.agent/skills/playwright-best-practices/SKILL.md +110 -63
- package/.agent/skills/powershell-windows/SKILL.md +61 -179
- package/.agent/skills/python-patterns/SKILL.md +7 -35
- package/.agent/skills/python-pro/SKILL.md +273 -114
- package/.agent/skills/react-specialist/SKILL.md +227 -108
- package/.agent/skills/readme-builder/SKILL.md +15 -85
- package/.agent/skills/realtime-patterns/SKILL.md +216 -243
- package/.agent/skills/red-team-tactics/SKILL.md +10 -51
- package/.agent/skills/rust-pro/SKILL.md +525 -142
- package/.agent/skills/seo-fundamentals/SKILL.md +92 -153
- package/.agent/skills/server-management/SKILL.md +110 -166
- package/.agent/skills/shadcn-ui-expert/SKILL.md +154 -55
- package/.agent/skills/skill-creator/SKILL.md +18 -58
- package/.agent/skills/sql-pro/SKILL.md +543 -68
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +28 -68
- package/.agent/skills/swiftui-expert/SKILL.md +124 -57
- package/.agent/skills/systematic-debugging/SKILL.md +49 -151
- package/.agent/skills/tailwind-patterns/SKILL.md +433 -149
- package/.agent/skills/tdd-workflow/SKILL.md +63 -169
- package/.agent/skills/test-result-analyzer/SKILL.md +33 -73
- package/.agent/skills/testing-patterns/SKILL.md +437 -130
- package/.agent/skills/trend-researcher/SKILL.md +30 -71
- package/.agent/skills/ui-ux-pro-max/SKILL.md +0 -41
- package/.agent/skills/ui-ux-researcher/SKILL.md +51 -91
- package/.agent/skills/vue-expert/SKILL.md +225 -119
- package/.agent/skills/vulnerability-scanner/SKILL.md +264 -226
- package/.agent/skills/web-accessibility-auditor/SKILL.md +141 -58
- package/.agent/skills/web-design-guidelines/SKILL.md +17 -61
- package/.agent/skills/webapp-testing/SKILL.md +71 -196
- package/.agent/skills/whimsy-injector/SKILL.md +58 -132
- package/.agent/skills/workflow-optimizer/SKILL.md +28 -68
- package/.agent/workflows/api-tester.md +96 -224
- package/.agent/workflows/audit.md +81 -122
- package/.agent/workflows/brainstorm.md +69 -105
- package/.agent/workflows/changelog.md +65 -97
- package/.agent/workflows/create.md +73 -88
- package/.agent/workflows/debug.md +80 -111
- package/.agent/workflows/deploy.md +119 -92
- package/.agent/workflows/enhance.md +80 -91
- package/.agent/workflows/fix.md +68 -97
- package/.agent/workflows/generate.md +165 -164
- package/.agent/workflows/migrate.md +106 -109
- package/.agent/workflows/orchestrate.md +103 -86
- package/.agent/workflows/performance-benchmarker.md +77 -268
- package/.agent/workflows/plan.md +120 -98
- package/.agent/workflows/preview.md +39 -96
- package/.agent/workflows/refactor.md +105 -97
- package/.agent/workflows/review-ai.md +63 -102
- package/.agent/workflows/review.md +71 -110
- package/.agent/workflows/session.md +53 -113
- package/.agent/workflows/status.md +42 -88
- package/.agent/workflows/strengthen-skills.md +90 -51
- package/.agent/workflows/swarm.md +114 -129
- package/.agent/workflows/test.md +125 -102
- package/.agent/workflows/tribunal-backend.md +60 -78
- package/.agent/workflows/tribunal-database.md +62 -100
- package/.agent/workflows/tribunal-frontend.md +62 -82
- package/.agent/workflows/tribunal-full.md +56 -100
- package/.agent/workflows/tribunal-mobile.md +65 -94
- package/.agent/workflows/tribunal-performance.md +62 -105
- package/.agent/workflows/ui-ux-pro-max.md +72 -121
- package/README.md +11 -15
- package/package.json +1 -1
- package/.agent/skills/api-patterns/api-style.md +0 -42
- package/.agent/skills/api-patterns/auth.md +0 -24
- package/.agent/skills/api-patterns/documentation.md +0 -26
- package/.agent/skills/api-patterns/graphql.md +0 -41
- package/.agent/skills/api-patterns/rate-limiting.md +0 -31
- package/.agent/skills/api-patterns/response.md +0 -37
- package/.agent/skills/api-patterns/rest.md +0 -40
- package/.agent/skills/api-patterns/security-testing.md +0 -122
- package/.agent/skills/api-patterns/trpc.md +0 -41
- package/.agent/skills/api-patterns/versioning.md +0 -22
- package/.agent/skills/app-builder/agent-coordination.md +0 -71
- package/.agent/skills/app-builder/feature-building.md +0 -53
- package/.agent/skills/app-builder/project-detection.md +0 -34
- package/.agent/skills/app-builder/scaffolding.md +0 -118
- package/.agent/skills/app-builder/tech-stack.md +0 -40
- package/.agent/skills/architecture/context-discovery.md +0 -43
- package/.agent/skills/architecture/examples.md +0 -94
- package/.agent/skills/architecture/pattern-selection.md +0 -68
- package/.agent/skills/architecture/patterns-reference.md +0 -50
- package/.agent/skills/architecture/trade-off-analysis.md +0 -77
- package/.agent/skills/brainstorming/dynamic-questioning.md +0 -360
- package/.agent/skills/database-design/database-selection.md +0 -43
- package/.agent/skills/database-design/indexing.md +0 -39
- package/.agent/skills/database-design/migrations.md +0 -48
- package/.agent/skills/database-design/optimization.md +0 -36
- package/.agent/skills/database-design/orm-selection.md +0 -30
- package/.agent/skills/database-design/schema-design.md +0 -56
- package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
- package/.agent/skills/framer-motion-animations/SKILL.md +0 -74
- package/.agent/skills/frontend-design/animation-guide.md +0 -331
- package/.agent/skills/frontend-design/color-system.md +0 -329
- package/.agent/skills/frontend-design/decision-trees.md +0 -418
- package/.agent/skills/frontend-design/motion-graphics.md +0 -306
- package/.agent/skills/frontend-design/typography-system.md +0 -363
- package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
- package/.agent/skills/frontend-design/visual-effects.md +0 -383
- package/.agent/skills/game-development/2d-games/SKILL.md +0 -119
- package/.agent/skills/game-development/3d-games/SKILL.md +0 -135
- package/.agent/skills/game-development/SKILL.md +0 -236
- package/.agent/skills/game-development/game-art/SKILL.md +0 -185
- package/.agent/skills/game-development/game-audio/SKILL.md +0 -190
- package/.agent/skills/game-development/game-design/SKILL.md +0 -129
- package/.agent/skills/game-development/mobile-games/SKILL.md +0 -108
- package/.agent/skills/game-development/multiplayer/SKILL.md +0 -132
- package/.agent/skills/game-development/pc-games/SKILL.md +0 -144
- package/.agent/skills/game-development/vr-ar/SKILL.md +0 -123
- package/.agent/skills/game-development/web-games/SKILL.md +0 -150
- package/.agent/skills/intelligent-routing/router-manifest.md +0 -65
- package/.agent/skills/mobile-design/decision-trees.md +0 -516
- package/.agent/skills/mobile-design/mobile-backend.md +0 -491
- package/.agent/skills/mobile-design/mobile-color-system.md +0 -420
- package/.agent/skills/mobile-design/mobile-debugging.md +0 -122
- package/.agent/skills/mobile-design/mobile-design-thinking.md +0 -357
- package/.agent/skills/mobile-design/mobile-navigation.md +0 -458
- package/.agent/skills/mobile-design/mobile-performance.md +0 -767
- package/.agent/skills/mobile-design/mobile-testing.md +0 -356
- package/.agent/skills/mobile-design/mobile-typography.md +0 -433
- package/.agent/skills/mobile-design/platform-android.md +0 -666
- package/.agent/skills/mobile-design/platform-ios.md +0 -561
- package/.agent/skills/mobile-design/touch-psychology.md +0 -537
- package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +0 -312
- package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +0 -240
- package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +0 -490
- package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +0 -264
- package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +0 -581
- package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +0 -432
- package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +0 -684
- package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +0 -150
- package/.agent/skills/vulnerability-scanner/checklists.md +0 -121
|
@@ -1,181 +1,88 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: parallel-agents
|
|
3
|
-
description:
|
|
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:
|
|
6
|
-
last-updated: 2026-
|
|
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
|
-
#
|
|
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
|
-
##
|
|
14
|
+
## 1. Fan-Out / Fan-In Pattern
|
|
32
15
|
|
|
33
|
-
|
|
16
|
+
The foundation of parallel multi-agent architecture.
|
|
34
17
|
|
|
35
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
##
|
|
43
|
+
## 2. Preventing Workspace Collision Risks
|
|
85
44
|
|
|
86
|
-
|
|
45
|
+
When multiple agents write to disk concurrently, catastrophic race conditions occur.
|
|
87
46
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
##
|
|
96
|
-
|
|
97
|
-
The biggest failure in parallel agent work is **inconsistency at boundaries**:
|
|
54
|
+
## 3. Reviewer Swarms (The Tribunal Principle)
|
|
98
55
|
|
|
99
|
-
|
|
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
|
-
**
|
|
104
|
-
-
|
|
105
|
-
-
|
|
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
|
-
##
|
|
64
|
+
## 4. Handling Differential Failures
|
|
111
65
|
|
|
112
|
-
|
|
66
|
+
What happens when 4 parallel tasks run, and 1 fails?
|
|
67
|
+
Does the whole pipeline crash?
|
|
113
68
|
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
```
|
|
73
|
+
// ✅ GOOD: Use Promise.allSettled to ensure resilient aggregation
|
|
74
|
+
const results = await Promise.allSettled(agentJobs);
|
|
123
75
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
|
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:
|
|
6
|
-
last-updated: 2026-
|
|
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
|
|
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
|
-
##
|
|
18
|
-
|
|
19
|
-
Every performance investigation follows the same sequence:
|
|
14
|
+
## Core Web Vitals
|
|
20
15
|
|
|
21
16
|
```
|
|
22
|
-
|
|
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
|
-
##
|
|
42
|
+
## JavaScript Profiling
|
|
30
43
|
|
|
31
|
-
###
|
|
44
|
+
### Bundle Analysis
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
+
// ❌ import { format } from "date-fns"; // may import entire library
|
|
63
|
+
// ✅ import { format } from "date-fns/format"; // specific import
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
71
|
+
```typescript
|
|
72
|
+
// React DevTools Profiler — find unnecessary re-renders
|
|
95
73
|
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
##
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
##
|
|
158
|
+
## Database Query Profiling
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
##
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
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
|
+
---
|