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.
- package/.agent/agents/accessibility-reviewer.md +220 -134
- package/.agent/agents/ai-code-reviewer.md +233 -129
- package/.agent/agents/backend-specialist.md +238 -178
- package/.agent/agents/code-archaeologist.md +181 -119
- package/.agent/agents/database-architect.md +207 -164
- package/.agent/agents/debugger.md +218 -151
- package/.agent/agents/dependency-reviewer.md +136 -55
- package/.agent/agents/devops-engineer.md +238 -175
- package/.agent/agents/documentation-writer.md +221 -137
- package/.agent/agents/explorer-agent.md +180 -142
- package/.agent/agents/frontend-reviewer.md +194 -80
- package/.agent/agents/frontend-specialist.md +237 -188
- package/.agent/agents/game-developer.md +52 -184
- package/.agent/agents/logic-reviewer.md +149 -78
- package/.agent/agents/mobile-developer.md +223 -152
- package/.agent/agents/mobile-reviewer.md +195 -79
- package/.agent/agents/orchestrator.md +211 -170
- package/.agent/agents/penetration-tester.md +174 -131
- package/.agent/agents/performance-optimizer.md +203 -139
- package/.agent/agents/performance-reviewer.md +211 -108
- package/.agent/agents/product-manager.md +162 -108
- package/.agent/agents/project-planner.md +162 -142
- package/.agent/agents/qa-automation-engineer.md +242 -138
- package/.agent/agents/security-auditor.md +194 -170
- package/.agent/agents/seo-specialist.md +213 -132
- package/.agent/agents/sql-reviewer.md +194 -73
- package/.agent/agents/supervisor-agent.md +203 -156
- package/.agent/agents/test-coverage-reviewer.md +193 -81
- package/.agent/agents/type-safety-reviewer.md +208 -65
- 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/skills/agent-organizer/SKILL.md +126 -132
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +155 -66
- package/.agent/skills/api-patterns/SKILL.md +289 -257
- package/.agent/skills/api-security-auditor/SKILL.md +172 -70
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
- package/.agent/skills/appflow-wireframe/SKILL.md +107 -100
- package/.agent/skills/architecture/SKILL.md +331 -200
- package/.agent/skills/authentication-best-practices/SKILL.md +168 -67
- package/.agent/skills/bash-linux/SKILL.md +154 -215
- package/.agent/skills/brainstorming/SKILL.md +104 -210
- package/.agent/skills/building-native-ui/SKILL.md +169 -70
- package/.agent/skills/clean-code/SKILL.md +360 -206
- package/.agent/skills/config-validator/SKILL.md +141 -165
- package/.agent/skills/csharp-developer/SKILL.md +528 -107
- package/.agent/skills/database-design/SKILL.md +455 -275
- package/.agent/skills/deployment-procedures/SKILL.md +145 -188
- package/.agent/skills/devops-engineer/SKILL.md +332 -134
- package/.agent/skills/devops-incident-responder/SKILL.md +113 -98
- package/.agent/skills/edge-computing/SKILL.md +157 -213
- package/.agent/skills/extract-design-system/SKILL.md +129 -69
- package/.agent/skills/framer-motion-expert/SKILL.md +939 -0
- package/.agent/skills/game-design-expert/SKILL.md +105 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +122 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +124 -215
- package/.agent/skills/github-operations/SKILL.md +314 -354
- package/.agent/skills/gsap-expert/SKILL.md +901 -0
- package/.agent/skills/i18n-localization/SKILL.md +138 -216
- package/.agent/skills/intelligent-routing/SKILL.md +127 -139
- package/.agent/skills/llm-engineering/SKILL.md +357 -258
- package/.agent/skills/local-first/SKILL.md +154 -203
- package/.agent/skills/mcp-builder/SKILL.md +118 -224
- package/.agent/skills/nextjs-react-expert/SKILL.md +783 -203
- package/.agent/skills/nodejs-best-practices/SKILL.md +559 -280
- package/.agent/skills/observability/SKILL.md +330 -285
- package/.agent/skills/parallel-agents/SKILL.md +122 -181
- package/.agent/skills/performance-profiling/SKILL.md +254 -197
- package/.agent/skills/plan-writing/SKILL.md +118 -188
- package/.agent/skills/platform-engineer/SKILL.md +123 -135
- package/.agent/skills/playwright-best-practices/SKILL.md +157 -76
- package/.agent/skills/powershell-windows/SKILL.md +146 -230
- package/.agent/skills/python-pro/SKILL.md +879 -114
- package/.agent/skills/react-specialist/SKILL.md +931 -108
- package/.agent/skills/realtime-patterns/SKILL.md +304 -296
- package/.agent/skills/rust-pro/SKILL.md +701 -240
- package/.agent/skills/seo-fundamentals/SKILL.md +154 -181
- package/.agent/skills/server-management/SKILL.md +190 -212
- package/.agent/skills/shadcn-ui-expert/SKILL.md +201 -68
- package/.agent/skills/sql-pro/SKILL.md +633 -104
- package/.agent/skills/swiftui-expert/SKILL.md +171 -70
- package/.agent/skills/systematic-debugging/SKILL.md +118 -186
- package/.agent/skills/tailwind-patterns/SKILL.md +576 -232
- package/.agent/skills/tdd-workflow/SKILL.md +137 -209
- package/.agent/skills/testing-patterns/SKILL.md +573 -205
- package/.agent/skills/vue-expert/SKILL.md +964 -119
- package/.agent/skills/vulnerability-scanner/SKILL.md +269 -316
- package/.agent/skills/web-accessibility-auditor/SKILL.md +188 -71
- package/.agent/skills/webapp-testing/SKILL.md +145 -236
- package/.agent/workflows/api-tester.md +151 -279
- package/.agent/workflows/audit.md +138 -168
- package/.agent/workflows/brainstorm.md +110 -146
- package/.agent/workflows/changelog.md +112 -144
- package/.agent/workflows/create.md +124 -139
- package/.agent/workflows/debug.md +189 -196
- package/.agent/workflows/deploy.md +189 -153
- package/.agent/workflows/enhance.md +151 -139
- package/.agent/workflows/fix.md +135 -143
- package/.agent/workflows/generate.md +157 -164
- package/.agent/workflows/migrate.md +160 -163
- package/.agent/workflows/orchestrate.md +168 -151
- package/.agent/workflows/performance-benchmarker.md +123 -305
- package/.agent/workflows/plan.md +173 -151
- package/.agent/workflows/preview.md +80 -137
- package/.agent/workflows/refactor.md +183 -153
- package/.agent/workflows/review-ai.md +129 -140
- package/.agent/workflows/review.md +116 -155
- package/.agent/workflows/session.md +94 -154
- package/.agent/workflows/status.md +79 -125
- package/.agent/workflows/strengthen-skills.md +139 -99
- package/.agent/workflows/swarm.md +179 -194
- package/.agent/workflows/test.md +211 -166
- package/.agent/workflows/tribunal-backend.md +113 -111
- package/.agent/workflows/tribunal-database.md +115 -132
- package/.agent/workflows/tribunal-frontend.md +118 -115
- package/.agent/workflows/tribunal-full.md +133 -136
- package/.agent/workflows/tribunal-mobile.md +119 -123
- package/.agent/workflows/tribunal-performance.md +133 -152
- package/.agent/workflows/ui-ux-pro-max.md +143 -171
- package/README.md +11 -15
- package/package.json +1 -1
- package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
- package/.agent/skills/framer-motion-animations/SKILL.md +0 -74
- 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
|
@@ -1,98 +1,113 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: devops-incident-responder
|
|
3
|
-
description:
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version:
|
|
6
|
-
last-updated: 2026-
|
|
7
|
-
applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version:
|
|
6
|
-
last-updated: 2026-
|
|
7
|
-
applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Edge Computing
|
|
11
|
-
|
|
12
|
-
> Edge is not
|
|
13
|
-
>
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Edge
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
##
|
|
38
|
-
|
|
39
|
-
The
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
+
```
|