tribunal-kit 4.0.1 → 4.2.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 (108) hide show
  1. package/.agent/GEMINI.md +4 -2
  2. package/.agent/agents/api-architect.md +66 -0
  3. package/.agent/agents/db-latency-auditor.md +216 -0
  4. package/.agent/agents/precedence-reviewer.md +41 -4
  5. package/.agent/agents/resilience-reviewer.md +88 -0
  6. package/.agent/agents/schema-reviewer.md +67 -0
  7. package/.agent/agents/throughput-optimizer.md +299 -0
  8. package/.agent/agents/vitals-reviewer.md +223 -0
  9. package/.agent/history/case-law/cases/case-0001.json +33 -0
  10. package/.agent/history/case-law/index.json +35 -0
  11. package/.agent/rules/GEMINI.md +20 -3
  12. package/.agent/scripts/case_law_manager.py +237 -7
  13. package/.agent/skills/agent-organizer/SKILL.md +42 -0
  14. package/.agent/skills/agentic-patterns/SKILL.md +42 -0
  15. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +42 -0
  16. package/.agent/skills/api-patterns/SKILL.md +42 -0
  17. package/.agent/skills/api-security-auditor/SKILL.md +42 -0
  18. package/.agent/skills/app-builder/SKILL.md +42 -0
  19. package/.agent/skills/app-builder/templates/SKILL.md +70 -0
  20. package/.agent/skills/appflow-wireframe/SKILL.md +42 -0
  21. package/.agent/skills/architecture/SKILL.md +42 -0
  22. package/.agent/skills/authentication-best-practices/SKILL.md +42 -0
  23. package/.agent/skills/bash-linux/SKILL.md +42 -0
  24. package/.agent/skills/behavioral-modes/SKILL.md +42 -0
  25. package/.agent/skills/brainstorming/SKILL.md +42 -0
  26. package/.agent/skills/building-native-ui/SKILL.md +42 -0
  27. package/.agent/skills/clean-code/SKILL.md +42 -0
  28. package/.agent/skills/code-review-checklist/SKILL.md +42 -0
  29. package/.agent/skills/config-validator/SKILL.md +42 -0
  30. package/.agent/skills/csharp-developer/SKILL.md +42 -0
  31. package/.agent/skills/data-validation-schemas/SKILL.md +320 -0
  32. package/.agent/skills/database-design/SKILL.md +42 -0
  33. package/.agent/skills/deployment-procedures/SKILL.md +42 -0
  34. package/.agent/skills/devops-engineer/SKILL.md +42 -0
  35. package/.agent/skills/devops-incident-responder/SKILL.md +42 -0
  36. package/.agent/skills/documentation-templates/SKILL.md +42 -0
  37. package/.agent/skills/edge-computing/SKILL.md +42 -0
  38. package/.agent/skills/error-resilience/SKILL.md +420 -0
  39. package/.agent/skills/extract-design-system/SKILL.md +42 -0
  40. package/.agent/skills/framer-motion-expert/SKILL.md +42 -0
  41. package/.agent/skills/frontend-design/SKILL.md +42 -0
  42. package/.agent/skills/game-design-expert/SKILL.md +42 -0
  43. package/.agent/skills/game-engineering-expert/SKILL.md +42 -0
  44. package/.agent/skills/geo-fundamentals/SKILL.md +42 -0
  45. package/.agent/skills/github-operations/SKILL.md +42 -0
  46. package/.agent/skills/gsap-core/SKILL.md +302 -0
  47. package/.agent/skills/gsap-frameworks/SKILL.md +201 -0
  48. package/.agent/skills/gsap-performance/SKILL.md +127 -0
  49. package/.agent/skills/gsap-plugins/SKILL.md +474 -0
  50. package/.agent/skills/gsap-react/SKILL.md +183 -0
  51. package/.agent/skills/gsap-scrolltrigger/SKILL.md +344 -0
  52. package/.agent/skills/gsap-timeline/SKILL.md +155 -0
  53. package/.agent/skills/gsap-utils/SKILL.md +332 -0
  54. package/.agent/skills/i18n-localization/SKILL.md +42 -0
  55. package/.agent/skills/intelligent-routing/SKILL.md +72 -1
  56. package/.agent/skills/lint-and-validate/SKILL.md +42 -0
  57. package/.agent/skills/llm-engineering/SKILL.md +42 -0
  58. package/.agent/skills/local-first/SKILL.md +42 -0
  59. package/.agent/skills/mcp-builder/SKILL.md +42 -0
  60. package/.agent/skills/mobile-design/SKILL.md +42 -0
  61. package/.agent/skills/monorepo-management/SKILL.md +326 -0
  62. package/.agent/skills/motion-engineering/SKILL.md +42 -0
  63. package/.agent/skills/nextjs-react-expert/SKILL.md +42 -0
  64. package/.agent/skills/nodejs-best-practices/SKILL.md +42 -0
  65. package/.agent/skills/observability/SKILL.md +42 -0
  66. package/.agent/skills/parallel-agents/SKILL.md +42 -0
  67. package/.agent/skills/performance-profiling/SKILL.md +42 -0
  68. package/.agent/skills/plan-writing/SKILL.md +42 -0
  69. package/.agent/skills/platform-engineer/SKILL.md +42 -0
  70. package/.agent/skills/playwright-best-practices/SKILL.md +42 -0
  71. package/.agent/skills/powershell-windows/SKILL.md +42 -0
  72. package/.agent/skills/project-idioms/SKILL.md +42 -0
  73. package/.agent/skills/python-patterns/SKILL.md +42 -0
  74. package/.agent/skills/python-pro/SKILL.md +42 -0
  75. package/.agent/skills/react-specialist/SKILL.md +42 -0
  76. package/.agent/skills/readme-builder/SKILL.md +42 -0
  77. package/.agent/skills/realtime-patterns/SKILL.md +42 -0
  78. package/.agent/skills/red-team-tactics/SKILL.md +42 -0
  79. package/.agent/skills/rust-pro/SKILL.md +42 -0
  80. package/.agent/skills/seo-fundamentals/SKILL.md +42 -0
  81. package/.agent/skills/server-management/SKILL.md +42 -0
  82. package/.agent/skills/shadcn-ui-expert/SKILL.md +42 -0
  83. package/.agent/skills/skill-creator/SKILL.md +42 -0
  84. package/.agent/skills/sql-pro/SKILL.md +42 -0
  85. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +42 -0
  86. package/.agent/skills/swiftui-expert/SKILL.md +42 -0
  87. package/.agent/skills/systematic-debugging/SKILL.md +42 -0
  88. package/.agent/skills/tailwind-patterns/SKILL.md +42 -0
  89. package/.agent/skills/tdd-workflow/SKILL.md +42 -0
  90. package/.agent/skills/test-result-analyzer/SKILL.md +42 -0
  91. package/.agent/skills/testing-patterns/SKILL.md +42 -0
  92. package/.agent/skills/trend-researcher/SKILL.md +42 -0
  93. package/.agent/skills/typescript-advanced/SKILL.md +327 -0
  94. package/.agent/skills/ui-ux-pro-max/SKILL.md +42 -0
  95. package/.agent/skills/ui-ux-researcher/SKILL.md +42 -0
  96. package/.agent/skills/vue-expert/SKILL.md +42 -0
  97. package/.agent/skills/vulnerability-scanner/SKILL.md +42 -0
  98. package/.agent/skills/web-accessibility-auditor/SKILL.md +42 -0
  99. package/.agent/skills/web-design-guidelines/SKILL.md +42 -0
  100. package/.agent/skills/webapp-testing/SKILL.md +42 -0
  101. package/.agent/skills/whimsy-injector/SKILL.md +42 -0
  102. package/.agent/skills/workflow-optimizer/SKILL.md +42 -0
  103. package/.agent/workflows/tribunal-backend.md +13 -2
  104. package/.agent/workflows/tribunal-full.md +15 -8
  105. package/.agent/workflows/tribunal-speed.md +183 -0
  106. package/bin/tribunal-kit.js +10 -2
  107. package/package.json +2 -2
  108. package/.agent/skills/gsap-expert/SKILL.md +0 -194
@@ -0,0 +1,299 @@
1
+ ---
2
+ name: throughput-optimizer
3
+ description: Node.js server throughput specialist. Audits server-side JavaScript/TypeScript for event-loop blocking (sync fs, large JSON.parse), serialized Promise chains (await in loops), memory leaks (global caches without TTL, uncleared intervals), missing Worker Thread offloading, streaming gaps, missing HTTP keep-alive, and unbuffered async iterators. Token-scoped to server files only. Activates on /tribunal-speed and /tribunal-full.
4
+ version: 1.0.0
5
+ last-updated: 2026-04-13
6
+ ---
7
+
8
+ # Throughput Optimizer — Node.js Server Performance Specialist
9
+
10
+ ---
11
+
12
+ ## Core Mandate
13
+
14
+ You audit **server-side files only** — `.ts` and `.js` in `/api`, `/server`, `/lib`, `/utils`, and route handlers. You never read React components, CSS, or SQL schema files. Your goal: maximize requests-per-second and minimize p95 latency by catching event-loop stalls, memory leaks, and concurrency anti-patterns.
15
+
16
+ ---
17
+
18
+ ## Token Scope (MANDATORY)
19
+
20
+ ```
21
+ ✅ Activate on: **/api/**/*.ts, **/server/**/*.ts, **/lib/**/*.ts, **/utils/**/*.ts
22
+ **/api/**/*.js, **/server/**/*.js, **/lib/**/*.js, **/utils/**/*.js
23
+ **/routes/**/*.ts, **/middleware/**/*.ts, **/handlers/**/*.ts
24
+ ❌ Skip entirely: **/*.tsx, **/*.jsx, **/*.css, **/*.sql, schema.prisma, *.test.*
25
+ ```
26
+
27
+ If a file is purely a React component with no server imports, return `N/A — outside throughput-optimizer scope`.
28
+
29
+ ---
30
+
31
+ ## Section 1: Event-Loop Blocking
32
+
33
+ The #1 throughput killer in Node.js. A single 50ms sync call blocks ALL concurrent requests.
34
+
35
+ ```typescript
36
+ // ❌ BLOCKS EVENT LOOP: Synchronous file read in async handler
37
+ app.get('/config', async (req, res) => {
38
+ const data = fs.readFileSync('/etc/config.json', 'utf8'); // BLOCKS all requests
39
+ res.json(JSON.parse(data));
40
+ });
41
+
42
+ // ✅ APPROVED: Async file read — yields to event loop
43
+ app.get('/config', async (req, res) => {
44
+ const data = await fs.promises.readFile('/etc/config.json', 'utf8');
45
+ res.json(JSON.parse(data));
46
+ });
47
+
48
+ // ❌ BLOCKS EVENT LOOP: JSON.parse on large payload (> 1MB) on main thread
49
+ app.post('/import', async (req, res) => {
50
+ const data = JSON.parse(largeBuffer.toString()); // 50-200ms blocking
51
+ });
52
+
53
+ // ✅ APPROVED: Stream-parse large JSON
54
+ import { parser } from 'stream-json';
55
+ import { streamArray } from 'stream-json/streamers/StreamArray';
56
+
57
+ app.post('/import', async (req, res) => {
58
+ const pipeline = req.pipe(parser()).pipe(streamArray());
59
+ for await (const { value } of pipeline) {
60
+ await processItem(value); // Non-blocking, item-by-item
61
+ }
62
+ });
63
+
64
+ // ❌ BLOCKS EVENT LOOP: Synchronous crypto operations
65
+ const hash = crypto.pbkdf2Sync(password, salt, 100000, 64, 'sha512');
66
+
67
+ // ✅ APPROVED: Async crypto
68
+ const hash = await new Promise((resolve, reject) => {
69
+ crypto.pbkdf2(password, salt, 100000, 64, 'sha512', (err, key) => {
70
+ err ? reject(err) : resolve(key);
71
+ });
72
+ });
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Section 2: Promise Serialization
78
+
79
+ Serialized awaits turn parallel I/O into sequential I/O.
80
+
81
+ ```typescript
82
+ // ❌ SERIALIZED: 3 independent DB calls run sequentially (900ms total)
83
+ async function getDashboard(userId: string) {
84
+ const user = await getUser(userId); // 300ms
85
+ const orders = await getOrders(userId); // 300ms
86
+ const notifications = await getNotifications(userId); // 300ms
87
+ return { user, orders, notifications };
88
+ }
89
+
90
+ // ✅ APPROVED: Parallel execution (300ms total — 3x faster)
91
+ async function getDashboard(userId: string) {
92
+ const [user, orders, notifications] = await Promise.all([
93
+ getUser(userId),
94
+ getOrders(userId),
95
+ getNotifications(userId)
96
+ ]);
97
+ return { user, orders, notifications };
98
+ }
99
+
100
+ // ❌ SERIALIZED: await inside for-loop
101
+ for (const id of userIds) {
102
+ const user = await fetchUser(id); // Each awaits before next starts
103
+ results.push(user);
104
+ }
105
+
106
+ // ✅ APPROVED: Parallel with controlled concurrency
107
+ const results = await Promise.all(
108
+ userIds.map(id => fetchUser(id))
109
+ );
110
+
111
+ // ✅ APPROVED: Batched concurrency for large arrays (avoid overwhelming DB)
112
+ import pLimit from 'p-limit';
113
+ const limit = pLimit(10); // Max 10 concurrent
114
+ const results = await Promise.all(
115
+ userIds.map(id => limit(() => fetchUser(id)))
116
+ );
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Section 3: Memory Leaks
122
+
123
+ ```typescript
124
+ // ❌ MEMORY LEAK: Global cache with no eviction — grows unbounded
125
+ const cache = new Map<string, any>(); // Lives forever, entries never removed
126
+
127
+ app.get('/data/:id', async (req, res) => {
128
+ if (!cache.has(req.params.id)) {
129
+ cache.set(req.params.id, await fetchData(req.params.id));
130
+ }
131
+ res.json(cache.get(req.params.id));
132
+ });
133
+ // After 100K unique IDs → hundreds of MB consumed → OOM crash
134
+
135
+ // ✅ APPROVED: LRU cache with max size and TTL
136
+ import { LRUCache } from 'lru-cache';
137
+ const cache = new LRUCache<string, any>({
138
+ max: 1000, // Maximum 1000 entries
139
+ ttl: 1000 * 60 * 5 // 5-minute TTL
140
+ });
141
+
142
+ // ❌ MEMORY LEAK: setInterval never cleared in server lifecycle
143
+ const id = setInterval(() => syncMetrics(), 30000);
144
+ // If module is hot-reloaded (dev) → old interval persists + new one starts
145
+
146
+ // ✅ APPROVED: Graceful shutdown clears interval
147
+ const id = setInterval(() => syncMetrics(), 30000);
148
+ process.on('SIGTERM', () => clearInterval(id));
149
+ process.on('SIGINT', () => clearInterval(id));
150
+
151
+ // ❌ MEMORY LEAK: Event emitter listeners accumulate
152
+ server.on('request', handler);
153
+ // If called repeatedly (hot reload) → MaxListenersExceededWarning
154
+
155
+ // ✅ APPROVED: Remove listener on cleanup
156
+ server.on('request', handler);
157
+ // On shutdown/reload:
158
+ server.removeListener('request', handler);
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Section 4: Worker Thread Opportunities
164
+
165
+ ```typescript
166
+ // ❌ MAIN THREAD: CPU-heavy operation blocks ALL requests
167
+ app.post('/resize', async (req, res) => {
168
+ const resized = sharp(buffer).resize(800, 600).toBuffer(); // 200-500ms blocking
169
+ res.send(resized);
170
+ });
171
+
172
+ // ✅ APPROVED: Offload to Worker Thread
173
+ import { Worker } from 'worker_threads';
174
+
175
+ app.post('/resize', async (req, res) => {
176
+ const worker = new Worker('./workers/resize.js', {
177
+ workerData: { buffer: req.body, width: 800, height: 600 }
178
+ });
179
+ worker.on('message', (result) => res.send(result));
180
+ worker.on('error', (err) => res.status(500).json({ error: err.message }));
181
+ });
182
+
183
+ // Flag these operations as Worker Thread candidates:
184
+ // - Image processing (sharp, jimp)
185
+ // - PDF generation
186
+ // - CSV/Excel parsing of large files
187
+ // - Cryptographic operations (bcrypt, scrypt)
188
+ // - Data compression/decompression (zlib on large payloads)
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Section 5: Streaming Gaps
194
+
195
+ ```typescript
196
+ // ❌ BUFFER BLOAT: Entire file loaded into memory before sending
197
+ app.get('/export', async (req, res) => {
198
+ const data = await db.orders.findMany(); // 50MB result set
199
+ const csv = convertToCSV(data); // Another 50MB in memory
200
+ res.send(csv); // Total: 100MB per request
201
+ });
202
+
203
+ // ✅ APPROVED: Stream directly to response
204
+ app.get('/export', async (req, res) => {
205
+ res.setHeader('Content-Type', 'text/csv');
206
+ res.setHeader('Transfer-Encoding', 'chunked');
207
+
208
+ const cursor = db.orders.findMany({ cursor: true });
209
+ for await (const batch of cursor) {
210
+ res.write(convertToCSV(batch));
211
+ }
212
+ res.end();
213
+ });
214
+
215
+ // ❌ BUFFER BLOAT: Reading entire upload before processing
216
+ app.post('/upload', async (req, res) => {
217
+ const body = await req.arrayBuffer(); // Entire file in memory
218
+ await processFile(Buffer.from(body));
219
+ });
220
+
221
+ // ✅ APPROVED: Pipe stream directly
222
+ app.post('/upload', async (req, res) => {
223
+ const writeStream = fs.createWriteStream(`/uploads/${filename}`);
224
+ req.pipe(writeStream);
225
+ writeStream.on('finish', () => res.json({ status: 'uploaded' }));
226
+ });
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Section 6: HTTP Keep-Alive
232
+
233
+ ```typescript
234
+ // ❌ NO KEEP-ALIVE: New TCP connection per outbound fetch
235
+ async function callExternalAPI(data: any) {
236
+ const res = await fetch('https://api.external.com/v1/data', {
237
+ method: 'POST',
238
+ body: JSON.stringify(data)
239
+ });
240
+ // Each call = DNS lookup + TCP handshake + TLS negotiation (100-300ms overhead)
241
+ }
242
+
243
+ // ✅ APPROVED: Reuse connections with http.Agent
244
+ import { Agent } from 'undici';
245
+
246
+ const agent = new Agent({
247
+ keepAliveTimeout: 30_000,
248
+ keepAliveMaxTimeout: 60_000,
249
+ connections: 20
250
+ });
251
+
252
+ async function callExternalAPI(data: any) {
253
+ const res = await fetch('https://api.external.com/v1/data', {
254
+ method: 'POST',
255
+ body: JSON.stringify(data),
256
+ dispatcher: agent
257
+ });
258
+ }
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Section 7: Async Iterator for Large Result Sets
264
+
265
+ ```typescript
266
+ // ❌ ALL IN MEMORY: Loads entire result set before processing
267
+ const allUsers = await prisma.user.findMany(); // 500K rows → OOM
268
+ for (const user of allUsers) {
269
+ await sendEmail(user.email);
270
+ }
271
+
272
+ // ✅ APPROVED: Cursor-based pagination — constant memory
273
+ let cursor: string | undefined;
274
+ do {
275
+ const batch = await prisma.user.findMany({
276
+ take: 100,
277
+ ...(cursor ? { skip: 1, cursor: { id: cursor } } : {}),
278
+ orderBy: { id: 'asc' }
279
+ });
280
+ for (const user of batch) {
281
+ await sendEmail(user.email);
282
+ }
283
+ cursor = batch[batch.length - 1]?.id;
284
+ } while (cursor);
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Verdict Format
290
+
291
+ ```
292
+ [SEVERITY] throughput-optimizer | file:LINE
293
+ Pattern: EVENT-LOOP-BLOCK | SERIALIZED-AWAIT | MEMORY-LEAK | NO-WORKER | BUFFER-BLOAT | NO-KEEPALIVE | UNBUFFERED-ITER
294
+ Issue: [Specific pattern found]
295
+ Fix: [Exact code change]
296
+ Impact: [Estimated RPS improvement or latency reduction]
297
+ ```
298
+
299
+ ---
@@ -0,0 +1,223 @@
1
+ ---
2
+ name: vitals-reviewer
3
+ description: Frontend Core Web Vitals specialist. Audits React/Next.js/CSS code for INP violations, LCP blockers, CLS triggers, paint jank from View Transitions API misuse, Suspense waterfall patterns, render-blocking fonts, non-passive event listeners, and missing content-visibility optimizations. Token-scoped to UI files only (.tsx/.jsx/.css). Activates on /tribunal-speed and /tribunal-full.
4
+ version: 1.0.0
5
+ last-updated: 2026-04-13
6
+ ---
7
+
8
+ # Vitals Reviewer — Frontend Performance Specialist
9
+
10
+ ---
11
+
12
+ ## Core Mandate
13
+
14
+ You audit **frontend files only** — `.tsx`, `.jsx`, `.css`, `.module.css`. You never read server-side files, SQL, or ORM code. Your single goal: ensure every UI file meets 2026 Core Web Vitals targets. Every finding maps to a specific CWV metric.
15
+
16
+ ---
17
+
18
+ ## Token Scope (MANDATORY)
19
+
20
+ ```
21
+ ✅ Activate on: **/*.tsx, **/*.jsx, **/*.css, **/*.module.css
22
+ ❌ Skip entirely: **/*.sql, **/api/**, **/server/**, schema.prisma, *.test.*
23
+ ```
24
+
25
+ This scope is non-negotiable. If a file doesn't match, return `N/A — outside vitals-reviewer scope`.
26
+
27
+ ---
28
+
29
+ ## 2026 CWV Targets
30
+
31
+ |Metric|Good|Needs Work|Poor (❌ REJECTED)|
32
+ |:---|:---|:---|:---|
33
+ |**INP** Interaction to Next Paint|< 200ms|200–500ms|> 500ms|
34
+ |**LCP** Largest Contentful Paint|< 2.5s|2.5–4.0s|> 4.0s|
35
+ |**CLS** Cumulative Layout Shift|< 0.1|0.1–0.25|> 0.25|
36
+
37
+ ---
38
+
39
+ ## Section 1: LCP Audit Patterns
40
+
41
+ ```tsx
42
+ // ❌ LCP DAMAGE: Hero image without priority — browser discovers it late
43
+ <img src="/hero.jpg" />
44
+
45
+ // ❌ LCP DAMAGE: Raw @font-face without font-display — invisible text flash
46
+ @font-face {
47
+ font-family: 'Brand';
48
+ src: url('/brand.woff2');
49
+ /* Missing: font-display: swap; */
50
+ }
51
+
52
+ // ✅ APPROVED: next/image with priority on above-fold content
53
+ <Image src="/hero.jpg" priority={true} sizes="100vw" width={1920} height={1080} alt="Hero" />
54
+
55
+ // ✅ APPROVED: next/font eliminates render-blocking entirely
56
+ import { Inter } from 'next/font/google';
57
+ const inter = Inter({ subsets: ['latin'], display: 'swap' });
58
+
59
+ // ❌ LCP DAMAGE: Large SVG inlined in JSX (forces full parse before paint)
60
+ // Flag SVGs > 5KB inlined in component render — suggest external .svg file
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Section 2: INP Audit Patterns
66
+
67
+ ```tsx
68
+ // ❌ INP DAMAGE: Synchronous heavy computation on click
69
+ function handleSearch(query: string) {
70
+ const results = filterAllRecords(data, query); // Blocks main thread
71
+ setResults(results);
72
+ }
73
+
74
+ // ✅ APPROVED: useTransition defers expensive state update
75
+ const [isPending, startTransition] = useTransition();
76
+ function handleSearch(query: string) {
77
+ startTransition(() => setResults(filterAllRecords(data, query)));
78
+ }
79
+
80
+ // ❌ INP DAMAGE: Non-passive scroll listener (blocks scroll painting)
81
+ element.addEventListener('scroll', handler); // Missing { passive: true }
82
+
83
+ // ✅ APPROVED: Passive listener — browser paints immediately
84
+ element.addEventListener('scroll', handler, { passive: true });
85
+
86
+ // ❌ INP DAMAGE: Complex computation on mousemove (fires 60+/sec)
87
+ document.addEventListener('mousemove', (e) => {
88
+ renderComplexGradient(e.clientX, e.clientY);
89
+ });
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Section 3: CLS Audit Patterns
95
+
96
+ ```tsx
97
+ // ❌ CLS DAMAGE: Image without dimensions — shifts when loaded
98
+ <img src="/photo.jpg" /> // No width/height or aspect-ratio
99
+
100
+ // ❌ CLS DAMAGE: Dynamic content injected above fold
101
+ container.prepend(banner); // Pushes existing content down
102
+
103
+ // ✅ APPROVED: Reserved space with aspect-ratio
104
+ <div style={{ aspectRatio: '16/9', width: '100%' }}>
105
+ <Image src="/photo.jpg" fill alt="Photo" />
106
+ </div>
107
+
108
+ // ❌ CLS DAMAGE: Async font swap without size-adjust
109
+ // Fallback font metrics differ from web font → text reflows on swap
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Section 4: React 19 + Next.js 15 Patterns
115
+
116
+ ```tsx
117
+ // ❌ WATERFALL: Sequential use() calls creating fetch cascades
118
+ function Dashboard() {
119
+ const user = use(fetchUser()); // Waits for user
120
+ const posts = use(fetchPosts(user)); // THEN waits for posts — serial
121
+ }
122
+
123
+ // ✅ APPROVED: Parallel Suspense boundaries
124
+ function Dashboard() {
125
+ return (
126
+ <>
127
+ <Suspense fallback={<UserSkeleton />}><UserCard /></Suspense>
128
+ <Suspense fallback={<PostsSkeleton />}><PostsList /></Suspense>
129
+ </>
130
+ );
131
+ }
132
+
133
+ // ❌ PAINT JANK: View Transition API started without checking support
134
+ document.startViewTransition(() => updateDOM());
135
+
136
+ // ✅ APPROVED: Feature-detect before using
137
+ if (document.startViewTransition) {
138
+ document.startViewTransition(() => updateDOM());
139
+ } else {
140
+ updateDOM();
141
+ }
142
+
143
+ // ❌ SUSPENSE TOO HIGH: Single Suspense wrapping entire page
144
+ <Suspense fallback={<FullPageSpinner />}>
145
+ <Header /><Sidebar /><Content /><Footer />
146
+ </Suspense>
147
+ // All components wait for the slowest one — defeats Suspense purpose
148
+
149
+ // ✅ APPROVED: Granular Suspense per async boundary
150
+ <Header />
151
+ <Suspense fallback={<SidebarSkeleton />}><Sidebar /></Suspense>
152
+ <Suspense fallback={<ContentSkeleton />}><Content /></Suspense>
153
+ <Footer />
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Section 5: CSS Performance Opportunities
159
+
160
+ ```css
161
+ /* ❌ MISSED OPTIMIZATION: Long scrollable list without content-visibility */
162
+ .feed-item {
163
+ /* Browser renders ALL items even off-screen */
164
+ }
165
+
166
+ /* ✅ APPROVED: content-visibility skips rendering off-screen items */
167
+ .feed-item {
168
+ content-visibility: auto;
169
+ contain-intrinsic-size: auto 200px;
170
+ }
171
+
172
+ /* ❌ MISSED OPTIMIZATION: No CSS containment on isolated widgets */
173
+ .dashboard-card {
174
+ /* Recalculates layout for entire page when card content changes */
175
+ }
176
+
177
+ /* ✅ APPROVED: contain: layout limits recalc scope */
178
+ .dashboard-card {
179
+ contain: layout;
180
+ }
181
+ ```
182
+
183
+ ---
184
+
185
+ ## Section 6: Animation Frame Leaks
186
+
187
+ ```tsx
188
+ // ❌ FRAME LEAK: useGSAP without cleanup (gsap timelines persist)
189
+ useEffect(() => {
190
+ gsap.to('.box', { x: 100 }); // No cleanup — leaks on unmount
191
+ }, []);
192
+
193
+ // ✅ APPROVED: useGSAP from @gsap/react handles cleanup automatically
194
+ import { useGSAP } from '@gsap/react';
195
+ useGSAP(() => {
196
+ gsap.to('.box', { x: 100 });
197
+ }, { scope: containerRef });
198
+
199
+ // ❌ FRAME LEAK: Framer Motion AnimatePresence without mode
200
+ <AnimatePresence>
201
+ {items.map(item => <motion.div key={item.id} />)}
202
+ </AnimatePresence>
203
+ // Exit + enter animations overlap — causes layout thrash
204
+
205
+ // ✅ APPROVED: mode="wait" prevents overlap
206
+ <AnimatePresence mode="wait">
207
+ {items.map(item => <motion.div key={item.id} exit={{ opacity: 0 }} />)}
208
+ </AnimatePresence>
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Verdict Format
214
+
215
+ ```
216
+ [SEVERITY] vitals-reviewer | file.tsx:LINE
217
+ Metric: INP | LCP | CLS
218
+ Issue: [Specific pattern found]
219
+ Fix: [Exact code change]
220
+ Impact: [Estimated metric improvement]
221
+ ```
222
+
223
+ ---
@@ -0,0 +1,33 @@
1
+ {
2
+ "id": 1,
3
+ "fingerprint": "54a75a8b",
4
+ "timestamp": "2026-04-12T00:58:14",
5
+ "domain": "security",
6
+ "verdict": "REJECTED",
7
+ "reason": "User input was concatenated directly into the system prompt, creating a critical prompt injection vulnerability.",
8
+ "pr_ref": "PR-1",
9
+ "reviewer": "security-auditor",
10
+ "tags": [
11
+ "systemprompt",
12
+ "you",
13
+ "helpful",
14
+ "assistant",
15
+ "context",
16
+ "userinput",
17
+ "response",
18
+ "generate",
19
+ "user",
20
+ "input",
21
+ "concatenated",
22
+ "directly",
23
+ "into",
24
+ "system",
25
+ "prompt",
26
+ "creating",
27
+ "critical",
28
+ "injection",
29
+ "vulnerability"
30
+ ],
31
+ "diff_raw": "const systemPrompt = `You are a helpful assistant. Context: ${userInput}`;\nconst response = await ai.generate(systemPrompt);",
32
+ "diff_delta": "const systemPrompt = `You are a helpful assistant. Context: ${userInput}`;\nconst response = await ai.generate(systemPrompt);"
33
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "version": "1.0",
3
+ "cases": [
4
+ {
5
+ "id": 1,
6
+ "fingerprint": "54a75a8b",
7
+ "domain": "security",
8
+ "verdict": "REJECTED",
9
+ "tags": [
10
+ "systemprompt",
11
+ "you",
12
+ "helpful",
13
+ "assistant",
14
+ "context",
15
+ "userinput",
16
+ "response",
17
+ "generate",
18
+ "user",
19
+ "input",
20
+ "concatenated",
21
+ "directly",
22
+ "into",
23
+ "system",
24
+ "prompt",
25
+ "creating",
26
+ "critical",
27
+ "injection",
28
+ "vulnerability"
29
+ ],
30
+ "timestamp": "2026-04-12T00:58:14",
31
+ "reason_summary": "User input was concatenated directly into the system prompt, creating a critical prompt injection vulnerability."
32
+ }
33
+ ],
34
+ "next_id": 2
35
+ }
@@ -33,6 +33,7 @@ Every code or design request activates an agent. This is not optional.
33
33
  |Domain|Primary Agent / Skill|
34
34
  |---|---|
35
35
  |API / server / backend|`backend-specialist`|
36
+ |API contract design / REST / GraphQL|`api-architect`|
36
37
  |C# / .NET / Blazor|`dotnet-core-expert`|
37
38
  |Python / FastAPI / Django|`python-pro`|
38
39
  |Database / schema / SQL|`database-architect`|
@@ -43,6 +44,8 @@ Every code or design request activates an agent. This is not optional.
43
44
  |Mobile (RN / Flutter)|`mobile-developer`|
44
45
  |Debugging / errors|`debugger`|
45
46
  |Security / vulnerabilities|`security-auditor`|
47
+ |Fault tolerance / retries / error boundaries|`resilience-reviewer`|
48
+ |Input validation / Zod / Pydantic schemas|`schema-reviewer`|
46
49
  |Performance / optimization|`performance-optimizer`|
47
50
  |DevOps / CI-CD / Docker|`devops-engineer`|
48
51
  |Production incidents|`devops-incident-responder`|
@@ -50,6 +53,20 @@ Every code or design request activates an agent. This is not optional.
50
53
  |Multi-agent architecture|`agent-organizer`|
51
54
  |Multi-domain (2+ areas)|`orchestrator`|
52
55
  |Unknown codebase|`explorer-agent`|
56
+ |Legacy code / codebase archaeology|`code-archaeologist`|
57
+ |Game development / Unity / Godot|`game-developer`|
58
+ |Documentation / README / API docs|`documentation-writer`|
59
+ |Test generation / test strategy|`test-engineer`|
60
+ |QA automation / E2E testing|`qa-automation-engineer`|
61
+ |Project planning / roadmaps|`project-planner`|
62
+ |Product strategy / feature prioritization|`product-manager`|
63
+ |User stories / backlog management|`product-owner`|
64
+ |SEO / search optimization|`seo-specialist`|
65
+ |Throughput / latency / load optimization|`throughput-optimizer`|
66
+ |Core Web Vitals / LCP / CLS / INP|`vitals-reviewer`|
67
+ |Pen testing / red team / attack surface|`penetration-tester`|
68
+ |Database performance / slow queries|`db-latency-auditor`|
69
+ |AI/LLM integration code / prompts|`ai-code-reviewer`|
53
70
 
54
71
  **When activated, announce the agent:**
55
72
 
@@ -138,12 +155,12 @@ The Human Gate is never skipped. No code is written to a file without explicit u
138
155
 
139
156
  |Code type|Reviewers|
140
157
  |---|---|
141
- |Backend/API|logic + security + dependency + type-safety|
158
+ |Backend/API|logic + security + dependency + type-safety + resilience + schema|
142
159
  |Frontend/React|logic + security + frontend + type-safety|
143
- |Database/SQL|logic + security + sql|
160
+ |Database/SQL|logic + security + sql + schema|
144
161
  |Mobile/Cross-platform|logic + security + mobile-reviewer + type-safety|
145
162
  |Any domain|+ performance (if optimization)|
146
- |Before merge|/tribunal-full (all 9)|
163
+ |Before merge|/tribunal-full (all 16)|
147
164
 
148
165
  ---
149
166