tribunal-kit 2.4.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/.agent/agents/accessibility-reviewer.md +220 -134
  2. package/.agent/agents/ai-code-reviewer.md +233 -129
  3. package/.agent/agents/backend-specialist.md +238 -178
  4. package/.agent/agents/code-archaeologist.md +181 -119
  5. package/.agent/agents/database-architect.md +207 -164
  6. package/.agent/agents/debugger.md +218 -151
  7. package/.agent/agents/dependency-reviewer.md +136 -55
  8. package/.agent/agents/devops-engineer.md +238 -175
  9. package/.agent/agents/documentation-writer.md +221 -137
  10. package/.agent/agents/explorer-agent.md +180 -142
  11. package/.agent/agents/frontend-reviewer.md +194 -80
  12. package/.agent/agents/frontend-specialist.md +237 -188
  13. package/.agent/agents/game-developer.md +52 -184
  14. package/.agent/agents/logic-reviewer.md +149 -78
  15. package/.agent/agents/mobile-developer.md +223 -152
  16. package/.agent/agents/mobile-reviewer.md +195 -79
  17. package/.agent/agents/orchestrator.md +211 -170
  18. package/.agent/agents/penetration-tester.md +174 -131
  19. package/.agent/agents/performance-optimizer.md +203 -139
  20. package/.agent/agents/performance-reviewer.md +211 -108
  21. package/.agent/agents/product-manager.md +162 -108
  22. package/.agent/agents/project-planner.md +162 -142
  23. package/.agent/agents/qa-automation-engineer.md +242 -138
  24. package/.agent/agents/security-auditor.md +194 -170
  25. package/.agent/agents/seo-specialist.md +213 -132
  26. package/.agent/agents/sql-reviewer.md +194 -73
  27. package/.agent/agents/supervisor-agent.md +203 -156
  28. package/.agent/agents/test-coverage-reviewer.md +193 -81
  29. package/.agent/agents/type-safety-reviewer.md +208 -65
  30. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  31. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  32. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  33. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  34. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  35. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  36. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  37. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  38. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  39. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  40. package/.agent/skills/agent-organizer/SKILL.md +126 -132
  41. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +155 -66
  42. package/.agent/skills/api-patterns/SKILL.md +289 -257
  43. package/.agent/skills/api-security-auditor/SKILL.md +172 -70
  44. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  45. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  46. package/.agent/skills/appflow-wireframe/SKILL.md +107 -100
  47. package/.agent/skills/architecture/SKILL.md +331 -200
  48. package/.agent/skills/authentication-best-practices/SKILL.md +168 -67
  49. package/.agent/skills/bash-linux/SKILL.md +154 -215
  50. package/.agent/skills/brainstorming/SKILL.md +104 -210
  51. package/.agent/skills/building-native-ui/SKILL.md +169 -70
  52. package/.agent/skills/clean-code/SKILL.md +360 -206
  53. package/.agent/skills/config-validator/SKILL.md +141 -165
  54. package/.agent/skills/csharp-developer/SKILL.md +528 -107
  55. package/.agent/skills/database-design/SKILL.md +455 -275
  56. package/.agent/skills/deployment-procedures/SKILL.md +145 -188
  57. package/.agent/skills/devops-engineer/SKILL.md +332 -134
  58. package/.agent/skills/devops-incident-responder/SKILL.md +113 -98
  59. package/.agent/skills/edge-computing/SKILL.md +157 -213
  60. package/.agent/skills/extract-design-system/SKILL.md +129 -69
  61. package/.agent/skills/framer-motion-expert/SKILL.md +939 -0
  62. package/.agent/skills/game-design-expert/SKILL.md +105 -0
  63. package/.agent/skills/game-engineering-expert/SKILL.md +122 -0
  64. package/.agent/skills/geo-fundamentals/SKILL.md +124 -215
  65. package/.agent/skills/github-operations/SKILL.md +314 -354
  66. package/.agent/skills/gsap-expert/SKILL.md +901 -0
  67. package/.agent/skills/i18n-localization/SKILL.md +138 -216
  68. package/.agent/skills/intelligent-routing/SKILL.md +127 -139
  69. package/.agent/skills/llm-engineering/SKILL.md +357 -258
  70. package/.agent/skills/local-first/SKILL.md +154 -203
  71. package/.agent/skills/mcp-builder/SKILL.md +118 -224
  72. package/.agent/skills/nextjs-react-expert/SKILL.md +783 -203
  73. package/.agent/skills/nodejs-best-practices/SKILL.md +559 -280
  74. package/.agent/skills/observability/SKILL.md +330 -285
  75. package/.agent/skills/parallel-agents/SKILL.md +122 -181
  76. package/.agent/skills/performance-profiling/SKILL.md +254 -197
  77. package/.agent/skills/plan-writing/SKILL.md +118 -188
  78. package/.agent/skills/platform-engineer/SKILL.md +123 -135
  79. package/.agent/skills/playwright-best-practices/SKILL.md +157 -76
  80. package/.agent/skills/powershell-windows/SKILL.md +146 -230
  81. package/.agent/skills/python-pro/SKILL.md +879 -114
  82. package/.agent/skills/react-specialist/SKILL.md +931 -108
  83. package/.agent/skills/realtime-patterns/SKILL.md +304 -296
  84. package/.agent/skills/rust-pro/SKILL.md +701 -240
  85. package/.agent/skills/seo-fundamentals/SKILL.md +154 -181
  86. package/.agent/skills/server-management/SKILL.md +190 -212
  87. package/.agent/skills/shadcn-ui-expert/SKILL.md +201 -68
  88. package/.agent/skills/sql-pro/SKILL.md +633 -104
  89. package/.agent/skills/swiftui-expert/SKILL.md +171 -70
  90. package/.agent/skills/systematic-debugging/SKILL.md +118 -186
  91. package/.agent/skills/tailwind-patterns/SKILL.md +576 -232
  92. package/.agent/skills/tdd-workflow/SKILL.md +137 -209
  93. package/.agent/skills/testing-patterns/SKILL.md +573 -205
  94. package/.agent/skills/vue-expert/SKILL.md +964 -119
  95. package/.agent/skills/vulnerability-scanner/SKILL.md +269 -316
  96. package/.agent/skills/web-accessibility-auditor/SKILL.md +188 -71
  97. package/.agent/skills/webapp-testing/SKILL.md +145 -236
  98. package/.agent/workflows/api-tester.md +151 -279
  99. package/.agent/workflows/audit.md +138 -168
  100. package/.agent/workflows/brainstorm.md +110 -146
  101. package/.agent/workflows/changelog.md +112 -144
  102. package/.agent/workflows/create.md +124 -139
  103. package/.agent/workflows/debug.md +189 -196
  104. package/.agent/workflows/deploy.md +189 -153
  105. package/.agent/workflows/enhance.md +151 -139
  106. package/.agent/workflows/fix.md +135 -143
  107. package/.agent/workflows/generate.md +157 -164
  108. package/.agent/workflows/migrate.md +160 -163
  109. package/.agent/workflows/orchestrate.md +168 -151
  110. package/.agent/workflows/performance-benchmarker.md +123 -305
  111. package/.agent/workflows/plan.md +173 -151
  112. package/.agent/workflows/preview.md +80 -137
  113. package/.agent/workflows/refactor.md +183 -153
  114. package/.agent/workflows/review-ai.md +129 -140
  115. package/.agent/workflows/review.md +116 -155
  116. package/.agent/workflows/session.md +94 -154
  117. package/.agent/workflows/status.md +79 -125
  118. package/.agent/workflows/strengthen-skills.md +139 -99
  119. package/.agent/workflows/swarm.md +179 -194
  120. package/.agent/workflows/test.md +211 -166
  121. package/.agent/workflows/tribunal-backend.md +113 -111
  122. package/.agent/workflows/tribunal-database.md +115 -132
  123. package/.agent/workflows/tribunal-frontend.md +118 -115
  124. package/.agent/workflows/tribunal-full.md +133 -136
  125. package/.agent/workflows/tribunal-mobile.md +119 -123
  126. package/.agent/workflows/tribunal-performance.md +133 -152
  127. package/.agent/workflows/ui-ux-pro-max.md +143 -171
  128. package/README.md +11 -15
  129. package/package.json +1 -1
  130. package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
  131. package/.agent/skills/framer-motion-animations/SKILL.md +0 -74
  132. package/.agent/skills/game-development/2d-games/SKILL.md +0 -119
  133. package/.agent/skills/game-development/3d-games/SKILL.md +0 -135
  134. package/.agent/skills/game-development/SKILL.md +0 -236
  135. package/.agent/skills/game-development/game-art/SKILL.md +0 -185
  136. package/.agent/skills/game-development/game-audio/SKILL.md +0 -190
  137. package/.agent/skills/game-development/game-design/SKILL.md +0 -129
  138. package/.agent/skills/game-development/mobile-games/SKILL.md +0 -108
  139. package/.agent/skills/game-development/multiplayer/SKILL.md +0 -132
  140. package/.agent/skills/game-development/pc-games/SKILL.md +0 -144
  141. package/.agent/skills/game-development/vr-ar/SKILL.md +0 -123
  142. package/.agent/skills/game-development/web-games/SKILL.md +0 -150
@@ -1,98 +1,113 @@
1
- ---
2
- name: devops-incident-responder
3
- description: Senior DevOps incident responder with expertise in managing critical production incidents, performing rapid diagnostics, and implementing permanent fixes. Reduces MTTR and builds resilient systems.
4
- allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 1.0.0
6
- last-updated: 2026-03-12
7
- applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
- ---
9
-
10
- # Devops Incident Responder - Claude Code Sub-Agent
11
-
12
- You are a senior DevOps incident responder with expertise in managing critical production incidents, performing rapid diagnostics, and implementing permanent fixes. Your focus spans incident detection, response coordination, root cause analysis, and continuous improvement with emphasis on reducing MTTR and building resilient systems.
13
-
14
- ## Configuration & Context Assessment
15
- When invoked:
16
- 1. Query context manager for system architecture and incident history
17
- 2. Review monitoring setup, alerting rules, and response procedures
18
- 3. Analyze incident patterns, response times, and resolution effectiveness
19
- 4. Implement solutions improving detection, response, and prevention
20
-
21
- ---
22
-
23
- ## The Response Excellence Checklist
24
- - MTTD < 5 minutes achieved
25
- - MTTA < 5 minutes maintained
26
- - MTTR < 30 minutes sustained
27
- - Postmortem within 48 hours completed
28
- - Action items tracked systematically
29
- - Runbook coverage > 80% verified
30
- - On-call rotation automated fully
31
- - Learning culture established
32
-
33
- ---
34
-
35
- ## Core Architecture Decision Framework
36
-
37
- ### Incident Detection & Rapid Diagnosis
38
- * **Monitoring Strategy:** Alert configuration, Anomaly detection, Synthetic monitoring.
39
- * **Rapid Triage:** Impact assessment, Service dependencies, Performance metrics, Log analysis, Distributed tracing.
40
- * **Tooling Mastery:** APM platforms, Log aggregators, Metric systems, Alert managers.
41
-
42
- ### Emergency Response & Coordination
43
- * **Coordination:** Incident commander, Stakeholder updates, War room setup, External communication.
44
- * **Emergency Procedures:** Rollback strategies, Circuit breakers, Traffic rerouting, Database failover, Emergency scaling.
45
- * **Chaos Engineering:** Failure injection, Game day exercises, Blast radius control.
46
-
47
- ### Root Cause Analysis & Prevention
48
- * **Root Cause:** Timeline construction, Five whys analysis, Correlation analysis, Reproduction attempts.
49
- * **Postmortem Process:** Blameless culture, Timeline creation, Action item definition, Process improvement.
50
- * **Automation Development:** Auto-remediation scripts, Recovery triggers, Validation scripts.
51
-
52
- ---
53
-
54
- ## Output Format
55
-
56
- When this skill completes a task, structure your output as:
57
-
58
- ```
59
- ━━━ Devops Incident Responder Output ━━━━━━━━━━━━━━━━━━━━━━━━
60
- Task: [what was performed]
61
- Result: [outcome summary — one line]
62
- ─────────────────────────────────────────────────
63
- Checks: ✅ [N passed] · ⚠️ [N warnings] · ❌ [N blocked]
64
- VBC status: PENDING VERIFIED
65
- Evidence: [link to terminal output, test result, or file diff]
66
- ```
67
-
68
-
69
- ---
70
-
71
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
72
-
73
- **Slash command: `/tribunal-backend`**
74
- **Active reviewers: `logic` · `security`**
75
-
76
- ### Forbidden AI Tropes in Incident Response
77
- 1. **Restarting Without Evidence** never suggest blindly restarting services without capturing a memory dump or analyzing logs first, as evidence will be destroyed.
78
- 2. **Ignoring User Impact** never close an incident or stop communicating before validating that full end-user functionality is restored.
79
- 3. **Blaming Individuals** never draft incident postmortems using names or assigning blame; always focus on systemic, blameless failures.
80
- 4. **Modifying Production Unsafely** never generate scripts that drop production data or forcefully terminate critical processes without safe fallback plans.
81
- 5. **Drowning in Alerts** — do not configure alerting systems to alert linearly on every minor spike; require runbooks to enforce signal-to-noise ratio optimization.
82
-
83
- ### ✅ Pre-Flight Self-Audit
84
-
85
- Review these questions before generating incident response plans or runbooks:
86
- ```text
87
- Did I include a clear mitigation strategy to quickly restore service before deep-diving the root cause?
88
- Are specific metrics and logs identified to validate the issue?
89
- Does the postmortem outline actionable, systemic fixes rather than human-error conclusions?
90
- Is the response script/automation safe, including a rollback mechanism?
91
- Are all communication steps mapped clearly across engineering and stakeholder channels?
92
- ```
93
-
94
- ### 🛑 Verification-Before-Completion (VBC) Protocol
95
-
96
- **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
97
- - ❌ **Forbidden:** Declaring an incident mitigated or a fix deployed based solely on running a script without checking the aftermath.
98
- - ✅ **Required:** You are explicitly forbidden from completing an incident response task without providing **concrete terminal/system evidence** (e.g., passing health check logs, restored metric readouts, or successful deployment logs) proving the service is fully restored.
1
+ ---
2
+ name: devops-incident-responder
3
+ description: Production incident response mastery. MTTR (Mean Time to Recovery) reduction, blameless post-mortems, rapid triaging, halting systemic cascading failures, isolating problematic deployments, and evidence-based forensic analysis. Use when stabilizing broken systems, fighting active production fires, or conducting root-cause post-mortems.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 2.0.0
6
+ last-updated: 2026-04-02
7
+ applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
+ ---
9
+
10
+ # Incident Responder Production Stabilization Mastery
11
+
12
+ > Time is blood. The goal of an incident response is Mitigation first, Resolution second.
13
+ > DO NOT investigate the root cause while the building is burning. Put out the fire (Rollback), then investigate the ashes.
14
+
15
+ ---
16
+
17
+ ## 1. The Prime Directive (Stop the Bleeding)
18
+
19
+ When an outage is declared (e.g., 502 Bad Gateway across the entire primary cluster), do not ask the developer to check the database logs to figure out why the code crashed.
20
+
21
+ **Immediate Action Pipeline:**
22
+ 1. **Identify the Trigger:** What changed in the last 15 minutes? (90% of outages are caused by deployments).
23
+ 2. **Revert the Change:** Execute the emergency rollback pipeline instantly. Revert the Git commit, swap the Docker tag, or disable the Feature Flag.
24
+ 3. **Verify Stabilization:** Ensure metrics return to healthy thresholds.
25
+ 4. **Communicate:** "Mitigation complete. Services restored. Root cause investigation underway."
26
+
27
+ ---
28
+
29
+ ## 2. Isolating Cascading Failures
30
+
31
+ A cascading failure occurs when Service A dies, causing Service B to overload with retries, which kills Service B, which kills the database.
32
+
33
+ **The Circuit Breaker Protocol:**
34
+ If a downstream dependency is dead, sever it immediately to save the rest of the ecosystem.
35
+
36
+ ```javascript
37
+ // VULNERABLE: Infinite Retry Death Spiral
38
+ async function fetchUser(id) {
39
+ while(true) {
40
+ try { return await api.get(`/user/${id}`); }
41
+ catch { await sleep(100); } // Hundreds of containers doing this will execute a DDoSing attack on the API
42
+ }
43
+ }
44
+
45
+ // RESILIENT: Circuit Breaking / Fallbacks
46
+ const breaker = new CircuitBreaker(fetchUser, {
47
+ errorThresholdPercentage: 50, // If 50% of requests fail...
48
+ resetTimeout: 30000 // Open the circuit (stop sending requests) for 30s
49
+ });
50
+
51
+ breaker.fallback(() => ({ id: "cached-user", status: "degraded" }));
52
+ ```
53
+
54
+ **Heavy Mitigation Tactics:**
55
+ - **Shed Load:** Aggressively drop non-critical traffic (e.g., disable background syncs, temporarily ban aggressive scraping IPs).
56
+ - **Scale Out (Band-Aid):** If the memory leak is crashing nodes every 10 minutes, scale the nodes up 3x to buy yourself 30 minutes of runway to find the actual bug.
57
+
58
+ ---
59
+
60
+ ## 3. The Investigative Triage Routine
61
+
62
+ Once the bleeding is stopped (or if you are investigating a non-fatal anomaly), follow the data strictly:
63
+
64
+ 1. **Metrics (The "What"):** Look at the Dashboards. Did latency spike? Did CPU pin at 100%? Did Database active connections max out?
65
+ 2. **Traces (The "Where"):** Look at OpenTelemetry/Datadog traces. Which specific microservice is the bottleneck?
66
+ 3. **Logs (The "Why"):** Query the centralized logs (Splunk/Elastic/CloudWatch) exactly around the timestamp the trace spiked.
67
+
68
+ ---
69
+
70
+ ## 4. The Blameless Post-Mortem
71
+
72
+ Incident response does not end when the system recovers. It ends when the system is architected to survive the same failure tomorrow automatically.
73
+
74
+ **A Professional Post-Mortem Must Include:**
75
+ 1. **The Timeline:** Chronological factual representation of the event to the minute.
76
+ 2. **Root Cause Analysis (The 5 Whys):**
77
+ - *Why did the site go down?* DB exhausted connections.
78
+ - *Why did it exhaust?* The new background worker didn't pool connections.
79
+ - *Why did the worker deploy?* It bypassed CI tests for speed.
80
+ 3. **Action Items:** Tangible Jira tickets preventing recurrence (e.g., "Implement PgBouncer connection limits", "Enforce CI checks block on all branches").
81
+
82
+ ---
83
+
84
+ ## 🤖 LLM-Specific Traps (Incident Response)
85
+
86
+ 1. **Investigating the Fire:** Identifying a crash and immediately demanding the user rewrite the deeply nested API logic while the site remains completely offline to customers. Always prescribe an instant Rollback first.
87
+ 2. **Shotgun Reboots:** Telling the user to just restart all the servers blindly. This destroys all volatile memory evidence (Heap Dumps, core dumps) required to actually solve the root cause.
88
+ 3. **Restart Loops:** The AI identifies an OOM (Out Of Memory) crash and writes a bash loop to infinitely restart the system every time it crashes, actively masking the fatal memory leak from architectural review.
89
+ 4. **Ignoring Network Geometries:** Trying to debug an API failure for 20 minutes by analyzing Node.js code, while totally forgetting to check if the AWS Security Group / Firewall simply blocked the port.
90
+ 5. **Assuming Code is Flawless:** Recommending complex database re-indexing strategies because queries got slow, without recognizing that the recent Git Commit deployed an N+1 query loop. Assume recent deployments are guilty until proven innocent.
91
+ 6. **No Circuit Breakers:** Fixing a timeout bug by suggesting the user increase the global HTTP timeout from 10s to 60s, guaranteeing the entire thread pool becomes exhausted instantly during the next network fluctuation.
92
+ 7. **The Blame Game:** Writing analysis reports that focus heavily on the individual developer who pushed the bad code, rather than identifying the systemic CI/CD pipeline failure that *allowed* the bad code to merge.
93
+ 8. **Logging in Production:** Advising the user to `console.log` massive payloads to track an error in production environments, massively polluting logs and potentially leaking PII compliance data.
94
+ 9. **Tunnel Vision:** Debugging Application A intensely, failing to realize Application A failed because the underlying global Redis cache failed completely, affecting all services simultaneously. Focus on shared infrastructure metrics first.
95
+ 10. **The Unverifiable Fix:** Proposing an intricate solution and skipping the final critical step: "How will we prove this actually fixed the problem under load?". Deploy without telemetry monitoring is flying blind.
96
+
97
+ ---
98
+
99
+ ## 🏛️ Tribunal Integration
100
+
101
+ ### ✅ Pre-Flight Self-Audit
102
+ ```
103
+ ✅ Was immediate Mitigation/Rollback explicitly ordered prior to initiating Root Cause Analysis?
104
+ ✅ Did I enforce strategies to break cascading failures (e.g., Circuit Breakers, load shedding)?
105
+ ✅ Are diagnostic analyses tracing specific metrics to explicit log anomalies?
106
+ ✅ Ensure that system reboots did not intentionally destroy critical volatile diagnostic evidence.
107
+ ✅ Have recent deployments/git-commits been flagged as the primary initial vector of suspicion?
108
+ ✅ Did I avoid masking problems by extending timeout thresholds, opting instead to fix blocking execution?
109
+ ✅ Is the incident Post-Mortem methodology completely focused on systemic flaws rather than human error?
110
+ ✅ Were cross-service infrastructure layers (DBs, Redis, Load Balancers) cleared before deep-diving into local code?
111
+ ✅ Has an action item been established verifying how future iterations of this failure will be programmatically blocked?
112
+ ✅ Are there explicit mechanisms checking for PII leakage before increasing diagnostic logging verbosity in production?
113
+ ```
@@ -1,213 +1,157 @@
1
- ---
2
- name: edge-computing
3
- description: Edge function design principles. Cloudflare Workers, Durable Objects, edge-compatible data patterns, cold start elimination, and global data locality. Use when designing latency-sensitive features, AI inference at the edge, or globally distributed applications.
4
- allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 1.0.0
6
- last-updated: 2026-03-12
7
- applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
- ---
9
-
10
- # Edge Computing Principles
11
-
12
- > Edge is not "just serverless but faster."
13
- > It's a fundamentally different execution model with different constraints.
14
-
15
- ---
16
-
17
- ## Edge vs Serverless vs Server
18
-
19
- Before choosing edge, understand what you're getting and what you're giving up:
20
-
21
- | Property | Traditional Server | Serverless (Lambda) | Edge (Workers) |
22
- |---|---|---|---|
23
- | Cold start | None | 100ms–2s | < 5ms (V8 isolates) |
24
- | Runtime | Full Node.js | Full Node.js | ⚠️ Subset of Web APIs only |
25
- | Latency to user | One region | One region | < 30ms globally |
26
- | Max CPU time | Unlimited | 15 min | 30ms–1s per request |
27
- | `fs` module | | | No filesystem |
28
- | `child_process` | | ✅ | ❌ No subprocess |
29
- | Memory | GB+ | 128MB–3GB | 128MB |
30
- | Persistent state | DB + disk | DB only | Durable Objects / KV |
31
- | Cost model | Fixed | Per invocation | Per invocation (cheaper) |
32
-
33
- **Rule: Choose edge when latency is the primary constraint and you can work within its API restrictions.**
34
-
35
- ---
36
-
37
- ## Edge Runtime Constraints
38
-
39
- The edge runtime implements **Web Platform APIs**, not Node.js APIs. This causes the most hallucinations:
40
-
41
- ```ts
42
- // Node.js APIs not available at the edge
43
- import fs from 'fs'; // No filesystem
44
- import { createHash } from 'crypto'; // No Node crypto module
45
- import { exec } from 'child_process'; // No subprocess
46
- import path from 'path'; // No path module
47
- const __dirname = path.dirname(fileURLToPath(import.meta.url)); // No __dirname
48
-
49
- // Web Platform APIs — available everywhere at the edge
50
- const hash = await crypto.subtle.digest('SHA-256', Buffer.from(input));
51
- const response = await fetch('https://api.example.com/data');
52
- const encoded = btoa(jsonString);
53
- const parsed = JSON.parse(body);
54
- ```
55
-
56
- ---
57
-
58
- ## Cloudflare Workers Patterns
59
-
60
- ### Basic Worker Structure
61
-
62
- ```ts
63
- // src/index.ts — Cloudflare Workers (Hono framework recommended)
64
- import { Hono } from 'hono';
65
-
66
- const app = new Hono<{ Bindings: Env }>();
67
-
68
- app.get('/api/hello', async (c) => {
69
- // Access environment variables via c.env — not process.env
70
- const apiKey = c.env.API_KEY;
71
- return c.json({ message: 'Hello from the edge' });
72
- });
73
-
74
- export default app;
75
- ```
76
-
77
- ### Durable Objects Stateful Edge
78
-
79
- Durable Objects provide a single-threaded, globally-unique actor model for stateful workloads at the edge (think: per-room chat state, rate limiters, presence):
80
-
81
- ```ts
82
- // Durable Object each instance is a unique stateful actor
83
- export class RoomState {
84
- private state: DurableObjectState;
85
- private users = new Set<WebSocket>();
86
-
87
- constructor(state: DurableObjectState) {
88
- this.state = state;
89
- // Restore state across hibernation
90
- this.state.getWebSockets().forEach(ws => this.users.add(ws));
91
- }
92
-
93
- async fetch(request: Request): Promise<Response> {
94
- if (request.headers.get('Upgrade') === 'websocket') {
95
- const [client, server] = Object.values(new WebSocketPair());
96
- this.state.acceptWebSocket(server);
97
- this.users.add(server);
98
- return new Response(null, { status: 101, webSocket: client });
99
- }
100
- return new Response('Not a WebSocket', { status: 400 });
101
- }
102
- }
103
- ```
104
-
105
- ---
106
-
107
- ## Edge-Compatible Data Patterns
108
-
109
- The edge has no local disk. Data access must be network-based and ultra-low-latency:
110
-
111
- | Data Type | Edge Solution | Do Not Use |
112
- |---|---|---|
113
- | Key-value | Cloudflare KV, Upstash Redis (HTTP) | Redis TCP (not HTTP) |
114
- | Relational | Turso (libSQL over HTTP), Neon (HTTP) | PostgreSQL TCP connection |
115
- | Blob / files | Cloudflare R2, S3 (via HTTP) | Local disk |
116
- | Session / cache | Cloudflare KV | In-memory (dies per request) |
117
- | Vector search | Vectorize (Cloudflare), Pinecone HTTP | pgvector (TCP) |
118
-
119
- ```ts
120
- // ✅ Turso — SQLite at the edge via HTTP API
121
- import { createClient } from '@libsql/client/http';
122
-
123
- const db = createClient({
124
- url: env.TURSO_DATABASE_URL,
125
- authToken: env.TURSO_AUTH_TOKEN,
126
- });
127
-
128
- const { rows } = await db.execute('SELECT * FROM users WHERE id = ?', [userId]);
129
- ```
130
-
131
- ---
132
-
133
- ## Cold Start Design
134
-
135
- The main advantage of edge (V8 isolates) is cold starts under 5ms vs Lambda's 100ms+. But you can still waste this advantage:
136
-
137
- ```ts
138
- // Heavy initialization in module scope runs on every cold start
139
- import { HeavyDependency } from 'huge-library'; // 50KB parse time
140
- const expensiveClient = new HeavyDependency({ ... }); // Slow init
141
-
142
- // ✅ Lazy initialization — only create when needed
143
- let client: HeavyClient | null = null;
144
- function getClient(env: Env) {
145
- if (!client) client = new HeavyClient({ apiKey: env.OPENAI_API_KEY });
146
- return client;
147
- }
148
- ```
149
-
150
- ---
151
-
152
- ## Data Locality & GDPR Compliance
153
-
154
- ```
155
- Problem: User in Germany hits edge node in Singapore data can't leave EU.
156
-
157
- Solution: Cloudflare Smart Placement + regional routing
158
-
159
- // wrangler.toml — restrict processing to EU jurisdiction
160
- [placement]
161
- mode = "smart"
162
-
163
- // Or explicit routing: route EU traffic to EU DOs only
164
- const id = env.ROOM.idFromName(`eu:${roomId}`);
165
- ```
166
-
167
- ---
168
-
169
- ## Output Format
170
-
171
- When this skill produces or reviews code, structure your output as follows:
172
-
173
- ```
174
- ━━━ Edge Computing Report ━━━━━━━━━━━━━━━━━━━━━━━━
175
- Skill: Edge Computing
176
- Language: [detected language / framework]
177
- Scope: [N files · N functions]
178
- ─────────────────────────────────────────────────
179
- ✅ Passed: [checks that passed, or "All clean"]
180
- ⚠️ Warnings: [non-blocking issues, or "None"]
181
- ❌ Blocked: [blocking issues requiring fix, or "None"]
182
- ─────────────────────────────────────────────────
183
- VBC status: PENDING → VERIFIED
184
- Evidence: [test output / lint pass / compile success]
185
- ```
186
-
187
- **VBC (Verification-Before-Completion) is mandatory.**
188
- Do not mark status as VERIFIED until concrete terminal evidence is provided.
189
-
190
-
191
- ---
192
-
193
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
194
-
195
- **Slash command: `/tribunal-backend`**
196
- **Active reviewers: `logic` · `security` · `dependency`**
197
-
198
- ### ❌ Forbidden AI Tropes in Edge Computing
199
-
200
- 1. **Importing Node.js built-ins** — `fs`, `path`, `crypto` (Node), `child_process` are not available at the edge. The edge runtime is Web Platform APIs only.
201
- 2. **`process.env` at the edge** — Cloudflare Workers use `env` parameter (binding), not `process.env`. Wrangler `vars` are accessed via `c.env.VAR_NAME`.
202
- 3. **TCP database connections** — standard PostgreSQL TCP connections don't work from edge. Use HTTP-based drivers (Neon serverless, Turso libSQL, PlanetScale HTTP).
203
- 4. **Any in-request state persistence** — edge workers are stateless per request. Use Durable Objects for state, KV for cache.
204
-
205
- ### ✅ Pre-Flight Self-Audit
206
-
207
- ```
208
- ✅ Does this code use only Web Platform APIs (fetch, crypto.subtle, btoa, etc.)?
209
- ✅ Are all database connections via HTTP drivers, not TCP (no pg.Pool at the edge)?
210
- ✅ Are environment variables accessed via the env binding, not process.env?
211
- ✅ Is any stateful data stored in KV or Durable Objects, not in-memory variables?
212
- ✅ Are heavy module imports lazy-loaded to avoid unnecessary cold start delays?
213
- ```
1
+ ---
2
+ name: edge-computing
3
+ description: Edge computing mastery. Cloudflare Workers, Vercel Edge Functions, Durable Objects, edge-compatible data patterns, cold start elimination, caching policies (Stale-While-Revalidate), and global data locality. Use when designing globally distributed, extreme low-latency applications architectures.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 2.0.0
6
+ last-updated: 2026-04-02
7
+ applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
+ ---
9
+
10
+ # Edge Computing — Global Latency Mastery
11
+
12
+ > The Edge is not just a faster server. It fundamentally changes the computing model.
13
+ > You cannot put compute on the Edge and leave the database in Virginia. V8 isolates enforce new rules.
14
+
15
+ ---
16
+
17
+ ## 1. The Edge Model (V8 Isolates vs Node.js)
18
+
19
+ Edge functions (Cloudflare Workers, Vercel Edge) run on V8 Isolates, NOT standard Node.js environments.
20
+
21
+ **What This Means:**
22
+ 1. Extremely fast cold starts (< 5ms) because there is no underlying OS process bootup.
23
+ 2. Hard memory/time limits per request (e.g., 50ms CPU time max).
24
+ 3. **NO NATIVE NODE MODULES.** You cannot use `fs`, `child_process`, or heavy native C++ binaries (e.g., standard `bcrypt`, `sharp`).
25
+
26
+ ```typescript
27
+ // BAD: Attempting to use Node native core modules
28
+ import fs from "fs";
29
+ import bcrypt from "bcrypt"; // Has C++ bindings, will instantly crash on V8 edge
30
+
31
+ // GOOD: Utilizing standard Web APIs (Fetch, CryptoKey)
32
+ const hashBuffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(password));
33
+ ```
34
+
35
+ ---
36
+
37
+ ## 2. Advanced Route Caching (Stale-While-Revalidate)
38
+
39
+ The highest value proposition of the edge is intercepting requests *before* they cross the ocean.
40
+
41
+ ```typescript
42
+ // Standard Edge Proxy request handling
43
+ export default {
44
+ async fetch(request, env, ctx) {
45
+ const url = new URL(request.url);
46
+
47
+ // 1. Cache API responses at the edge
48
+ const cache = caches.default;
49
+ let response = await cache.match(request);
50
+
51
+ if (!response) {
52
+ // 2. Fetch Origin (The real server in Virginia)
53
+ response = await fetch(request);
54
+
55
+ // 3. Mutate Headers for SWR (Stale-While-Revalidate)
56
+ // Instructs the Edge CDN: Serve the stale version instantly to the user,
57
+ // but fire an async request in the background to update the cache for the next user.
58
+ response = new Response(response.body, response);
59
+ response.headers.set('Cache-Control', 's-maxage=60, stale-while-revalidate=86400');
60
+
61
+ // 4. Store in Cache asynchronously (do not block the user response)
62
+ ctx.waitUntil(cache.put(request, response.clone()));
63
+ }
64
+
65
+ return response;
66
+ }
67
+ };
68
+ ```
69
+
70
+ ---
71
+
72
+ ## 3. Edge Data Locality (The Database Problem)
73
+
74
+ Running logic globally while querying a monolithic database in `us-east-1` is counter-productive. The latency of establishing a connection across the Atlantic will negate any Edge benefits.
75
+
76
+ ### Solutions:
77
+ 1. **Edge KV Stores**: (Cloudflare KV, Vercel KV) Eventually consistent, highly localized read-latency configs suitable for configuration routing, user sessions, or feature flags.
78
+ 2. **Distributed SQLite**: (Cloudflare D1, Turso) Replicas distributed to edge nodes automatically.
79
+ 3. **Connection Pooling**: Use an HTTP/Connection Pool proxy strictly (e.g., Prisma Accelerate, Supabase Edge Pooler). You cannot establish TCP `pg://` connections directly from millions of spinning V8 isolates, you will OOM crash the database.
80
+
81
+ ```typescript
82
+ // Turso / LibSQL (Distributed Edge DB) usage:
83
+ import { createClient } from "@libsql/client/web";
84
+
85
+ const client = createClient({
86
+ url: env.TURSO_DATABASE_URL,
87
+ authToken: env.TURSO_AUTH_TOKEN,
88
+ });
89
+
90
+ const result = await client.execute("SELECT * FROM users WHERE id = ?", [userId]);
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 4. WebSockets at the Edge (Durable Objects)
96
+
97
+ Standard Edge functions are stateless. To hold persistent state (like a live multiplayer gaming room, or a chat room's WebSocket connections across multiple users), you must funnel those connections into a single point of state: a Durable Object.
98
+
99
+ ```typescript
100
+ // A Durable Object serves as a single source of truth that users globally connect into
101
+ export class ChatRoom {
102
+ constructor(state, env) {
103
+ this.state = state;
104
+ this.sessions = [];
105
+ }
106
+
107
+ async fetch(request) {
108
+ // Upgrade standard HTTP to WebSocket
109
+ const pair = new WebSocketPair();
110
+
111
+ // Accept connection, store it globally
112
+ this.sessions.push(pair.server);
113
+ pair.server.accept();
114
+
115
+ // Handle incoming Chat messages
116
+ pair.server.addEventListener("message", msg => {
117
+ // Broadcast to all other connected edge users
118
+ this.sessions.forEach(session => session.send(msg.data));
119
+ });
120
+
121
+ return new Response(null, { status: 101, webSocket: pair.client });
122
+ }
123
+ }
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 🤖 LLM-Specific Traps (Edge Computing)
129
+
130
+ 1. **Node Core Assumption:** The AI imports `fs`, `path`, or `child_process` directly into Cloudflare Workers / Next.js Edge Middleware. V8 isolates lack file system access. Use native Web APIs (`ReadableStream`, `Blob`).
131
+ 2. **Heavy Dependency Usage:** The AI imports massive NPM libraries (like `lodash` or `moment`) which crush the 1MB Edge script-size limits. Code for the Edge must be micro-optimized.
132
+ 3. **TCP Database Connections:** Generating `const client = new Client({ connectionString: "postgres://..." })` inside an Edge runtime. The edge requires HTTP/WebSocket driven database architectures, or a managed connection pooler to prevent TCP exhaustion.
133
+ 4. **State Fallacy:** Designing a global variable `let activeUsers = 0` inside an edge script and assuming it will sync. V8 Isolates boot and die globally in milliseconds. They share no memory.
134
+ 5. **Ignoring `ctx.waitUntil`:** Mutating databases or logging metrics synchronously before returning the web response, slowing down the user. All side-effects on the Edge must be deferred via `ctx.waitUntil(promise)`.
135
+ 6. **Non-Web Crypto:** Trying to use Node's `crypto` module. Standardize on the universally browser-compatible `crypto.subtle` Web Crypto API.
136
+ 7. **Environment Variable Bleed:** Using `process.env.SECRET` instead of passing the standard `env` injection parameter into the V8 fetch handler.
137
+ 8. **Missing CORS Origins:** Forgetting to dynamically append heavy CORS allow headers on the outgoing Edge proxy response manipulation.
138
+ 9. **Synchronous Loops:** Designing a large `forEach` data map inside the worker request block, tripping the strict 50ms CPU execution limits resulting in generic 1102 Worker Errors.
139
+ 10. **WebSocket Orphanages:** Opening a WebSocket inside a standard Edge function without bridging it into a Durable Object, causing the WS connection to terminate immediately when the isolate tears down.
140
+
141
+ ---
142
+
143
+ ## 🏛️ Tribunal Integration
144
+
145
+ ### Pre-Flight Self-Audit
146
+ ```
147
+ ✅ Have I completely avoided using native Node.js core modules (`fs`, `path`, `crypto`)?
148
+ ✅ Am I leveraging standard Web APIs (Fetch, Streams, Web Crypto)?
149
+ ✅ Have database interactions utilized HTTP clients (or connection poolers) instead of direct TCP?
150
+ ✅ Has `ctx.waitUntil()` been used for all background analytics/caching updates?
151
+ ✅ Are environment variables injected via `env.VAR` rather than `process.env`?
152
+ Is localized global state (chat rooms, live editing) explicitly deferred to Durable Objects?
153
+ ✅ Did I define strict `s-maxage` and `stale-while-revalidate` directives for caching performance?
154
+ ✅ Are third-party library imports audited for their V8 isolate compatibility footprint?
155
+ Is JSON parsing happening inside `try/catch` to avoid 500ing early isolates?
156
+ ✅ Did I avoid deploying massive >1MB bundle payloads to the Edge routing layer?
157
+ ```