tribunal-kit 4.2.0 → 4.3.1

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 (186) hide show
  1. package/.agent/ARCHITECTURE.md +21 -14
  2. package/.agent/agents/swarm-worker-contracts.md +5 -5
  3. package/.agent/agents/ui-ux-auditor.md +292 -0
  4. package/.agent/rules/GEMINI.md +8 -8
  5. package/.agent/scripts/__pycache__/_colors.cpython-311.pyc +0 -0
  6. package/.agent/scripts/__pycache__/_utils.cpython-311.pyc +0 -0
  7. package/.agent/scripts/__pycache__/case_law_manager.cpython-311.pyc +0 -0
  8. package/.agent/scripts/_colors.js +18 -0
  9. package/.agent/scripts/_utils.js +42 -0
  10. package/.agent/scripts/auto_preview.js +197 -0
  11. package/.agent/scripts/bundle_analyzer.js +290 -0
  12. package/.agent/scripts/case_law_manager.js +684 -0
  13. package/.agent/scripts/checklist.js +266 -0
  14. package/.agent/scripts/colors.js +17 -0
  15. package/.agent/scripts/compress_skills.js +141 -0
  16. package/.agent/scripts/consolidate_skills.js +149 -0
  17. package/.agent/scripts/context_broker.js +609 -0
  18. package/.agent/scripts/deep_compress.js +150 -0
  19. package/.agent/scripts/dependency_analyzer.js +272 -0
  20. package/.agent/scripts/graph_builder.js +199 -0
  21. package/.agent/scripts/graph_zoom.js +154 -0
  22. package/.agent/scripts/inner_loop_validator.js +465 -0
  23. package/.agent/scripts/lint_runner.js +187 -0
  24. package/.agent/scripts/minify_context.js +100 -0
  25. package/.agent/scripts/patch_skills_meta.js +156 -0
  26. package/.agent/scripts/patch_skills_output.js +244 -0
  27. package/.agent/scripts/schema_validator.js +297 -0
  28. package/.agent/scripts/security_scan.js +303 -0
  29. package/.agent/scripts/session_manager.js +276 -0
  30. package/.agent/scripts/skill_evolution.js +644 -0
  31. package/.agent/scripts/skill_integrator.js +313 -0
  32. package/.agent/scripts/strengthen_skills.js +193 -0
  33. package/.agent/scripts/strip_tribunal.js +47 -0
  34. package/.agent/scripts/swarm_dispatcher.js +360 -0
  35. package/.agent/scripts/test_runner.js +193 -0
  36. package/.agent/scripts/utils.js +32 -0
  37. package/.agent/scripts/verify_all.js +256 -0
  38. package/.agent/skills/agent-organizer/SKILL.md +12 -4
  39. package/.agent/skills/agentic-patterns/SKILL.md +12 -4
  40. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +12 -4
  41. package/.agent/skills/api-patterns/SKILL.md +209 -201
  42. package/.agent/skills/api-security-auditor/SKILL.md +12 -4
  43. package/.agent/skills/app-builder/SKILL.md +12 -4
  44. package/.agent/skills/app-builder/templates/SKILL.md +76 -68
  45. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +1 -1
  46. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  47. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +1 -1
  48. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  49. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +1 -1
  50. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +1 -1
  51. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +1 -1
  52. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +1 -1
  53. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
  54. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +1 -1
  55. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +1 -1
  56. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +1 -1
  57. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +1 -1
  58. package/.agent/skills/appflow-wireframe/SKILL.md +12 -4
  59. package/.agent/skills/architecture/SKILL.md +12 -4
  60. package/.agent/skills/authentication-best-practices/SKILL.md +12 -4
  61. package/.agent/skills/bash-linux/SKILL.md +12 -4
  62. package/.agent/skills/behavioral-modes/SKILL.md +12 -4
  63. package/.agent/skills/brainstorming/SKILL.md +12 -4
  64. package/.agent/skills/building-native-ui/SKILL.md +12 -4
  65. package/.agent/skills/clean-code/SKILL.md +12 -4
  66. package/.agent/skills/code-review-checklist/SKILL.md +12 -4
  67. package/.agent/skills/config-validator/SKILL.md +12 -4
  68. package/.agent/skills/csharp-developer/SKILL.md +12 -4
  69. package/.agent/skills/data-validation-schemas/SKILL.md +290 -282
  70. package/.agent/skills/database-design/SKILL.md +202 -194
  71. package/.agent/skills/deployment-procedures/SKILL.md +12 -4
  72. package/.agent/skills/devops-engineer/SKILL.md +12 -4
  73. package/.agent/skills/devops-incident-responder/SKILL.md +12 -4
  74. package/.agent/skills/doc.md +1 -1
  75. package/.agent/skills/documentation-templates/SKILL.md +12 -4
  76. package/.agent/skills/edge-computing/SKILL.md +12 -4
  77. package/.agent/skills/error-resilience/SKILL.md +390 -382
  78. package/.agent/skills/extract-design-system/SKILL.md +12 -4
  79. package/.agent/skills/framer-motion-expert/SKILL.md +206 -199
  80. package/.agent/skills/frontend-design/SKILL.md +163 -155
  81. package/.agent/skills/game-design-expert/SKILL.md +12 -4
  82. package/.agent/skills/game-engineering-expert/SKILL.md +12 -4
  83. package/.agent/skills/geo-fundamentals/SKILL.md +12 -4
  84. package/.agent/skills/github-operations/SKILL.md +12 -4
  85. package/.agent/skills/gsap-core/SKILL.md +54 -48
  86. package/.agent/skills/gsap-frameworks/SKILL.md +54 -48
  87. package/.agent/skills/gsap-performance/SKILL.md +54 -48
  88. package/.agent/skills/gsap-plugins/SKILL.md +54 -48
  89. package/.agent/skills/gsap-react/SKILL.md +54 -48
  90. package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -48
  91. package/.agent/skills/gsap-timeline/SKILL.md +54 -48
  92. package/.agent/skills/gsap-utils/SKILL.md +54 -48
  93. package/.agent/skills/i18n-localization/SKILL.md +12 -4
  94. package/.agent/skills/intelligent-routing/SKILL.md +41 -33
  95. package/.agent/skills/knowledge-graph/SKILL.md +36 -0
  96. package/.agent/skills/lint-and-validate/SKILL.md +12 -4
  97. package/.agent/skills/llm-engineering/SKILL.md +12 -4
  98. package/.agent/skills/local-first/SKILL.md +12 -4
  99. package/.agent/skills/mcp-builder/SKILL.md +12 -4
  100. package/.agent/skills/mobile-design/SKILL.md +225 -217
  101. package/.agent/skills/monorepo-management/SKILL.md +296 -288
  102. package/.agent/skills/motion-engineering/SKILL.md +195 -187
  103. package/.agent/skills/nextjs-react-expert/SKILL.md +196 -188
  104. package/.agent/skills/nodejs-best-practices/SKILL.md +12 -4
  105. package/.agent/skills/observability/SKILL.md +12 -4
  106. package/.agent/skills/parallel-agents/SKILL.md +12 -4
  107. package/.agent/skills/performance-profiling/SKILL.md +12 -4
  108. package/.agent/skills/plan-writing/SKILL.md +12 -4
  109. package/.agent/skills/platform-engineer/SKILL.md +12 -4
  110. package/.agent/skills/playwright-best-practices/SKILL.md +12 -4
  111. package/.agent/skills/powershell-windows/SKILL.md +12 -4
  112. package/.agent/skills/project-idioms/SKILL.md +12 -4
  113. package/.agent/skills/python-patterns/SKILL.md +12 -4
  114. package/.agent/skills/python-pro/SKILL.md +285 -277
  115. package/.agent/skills/react-specialist/SKILL.md +239 -231
  116. package/.agent/skills/readme-builder/SKILL.md +12 -4
  117. package/.agent/skills/realtime-patterns/SKILL.md +12 -4
  118. package/.agent/skills/red-team-tactics/SKILL.md +12 -4
  119. package/.agent/skills/rust-pro/SKILL.md +12 -4
  120. package/.agent/skills/seo-fundamentals/SKILL.md +12 -4
  121. package/.agent/skills/server-management/SKILL.md +12 -4
  122. package/.agent/skills/shadcn-ui-expert/SKILL.md +12 -4
  123. package/.agent/skills/skill-creator/SKILL.md +12 -4
  124. package/.agent/skills/sql-pro/SKILL.md +12 -4
  125. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +12 -4
  126. package/.agent/skills/swiftui-expert/SKILL.md +12 -4
  127. package/.agent/skills/systematic-debugging/SKILL.md +12 -4
  128. package/.agent/skills/tailwind-patterns/SKILL.md +12 -4
  129. package/.agent/skills/tdd-workflow/SKILL.md +12 -4
  130. package/.agent/skills/test-result-analyzer/SKILL.md +12 -4
  131. package/.agent/skills/testing-patterns/SKILL.md +12 -4
  132. package/.agent/skills/trend-researcher/SKILL.md +12 -4
  133. package/.agent/skills/typescript-advanced/SKILL.md +297 -289
  134. package/.agent/skills/ui-ux-pro-max/SKILL.md +12 -4
  135. package/.agent/skills/ui-ux-researcher/SKILL.md +12 -4
  136. package/.agent/skills/vue-expert/SKILL.md +237 -229
  137. package/.agent/skills/vulnerability-scanner/SKILL.md +12 -4
  138. package/.agent/skills/web-accessibility-auditor/SKILL.md +12 -4
  139. package/.agent/skills/web-design-guidelines/SKILL.md +12 -4
  140. package/.agent/skills/webapp-testing/SKILL.md +12 -4
  141. package/.agent/skills/whimsy-injector/SKILL.md +12 -4
  142. package/.agent/skills/workflow-optimizer/SKILL.md +12 -4
  143. package/.agent/workflows/audit.md +6 -6
  144. package/.agent/workflows/deploy.md +1 -1
  145. package/.agent/workflows/generate.md +23 -6
  146. package/.agent/workflows/session.md +5 -5
  147. package/.agent/workflows/swarm.md +2 -2
  148. package/README.md +242 -186
  149. package/bin/tribunal-kit.js +297 -57
  150. package/package.json +81 -77
  151. package/scripts/changelog.js +167 -0
  152. package/scripts/sync-version.js +81 -0
  153. package/scripts/validate-payload.js +73 -0
  154. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  155. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  156. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  157. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  158. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  159. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  160. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  161. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  162. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  163. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  164. package/.agent/scripts/auto_preview.py +0 -180
  165. package/.agent/scripts/bundle_analyzer.py +0 -259
  166. package/.agent/scripts/case_law_manager.py +0 -755
  167. package/.agent/scripts/checklist.py +0 -209
  168. package/.agent/scripts/compress_skills.py +0 -167
  169. package/.agent/scripts/consolidate_skills.py +0 -173
  170. package/.agent/scripts/deep_compress.py +0 -202
  171. package/.agent/scripts/dependency_analyzer.py +0 -247
  172. package/.agent/scripts/lint_runner.py +0 -188
  173. package/.agent/scripts/minify_context.py +0 -80
  174. package/.agent/scripts/patch_skills_meta.py +0 -177
  175. package/.agent/scripts/patch_skills_output.py +0 -285
  176. package/.agent/scripts/schema_validator.py +0 -279
  177. package/.agent/scripts/security_scan.py +0 -224
  178. package/.agent/scripts/session_manager.py +0 -261
  179. package/.agent/scripts/skill_evolution.py +0 -563
  180. package/.agent/scripts/skill_integrator.py +0 -234
  181. package/.agent/scripts/strengthen_skills.py +0 -220
  182. package/.agent/scripts/strip_tribunal.py +0 -41
  183. package/.agent/scripts/swarm_dispatcher.py +0 -350
  184. package/.agent/scripts/test_runner.py +0 -192
  185. package/.agent/scripts/test_swarm_dispatcher.py +0 -163
  186. package/.agent/scripts/verify_all.py +0 -195
@@ -1,205 +1,205 @@
1
- ---
2
- name: api-patterns
3
- description: API design mastery. REST, GraphQL, tRPC, and gRPC selection. Request/response design, pagination (cursor/offset), filtering, versioning, rate limiting, error formats (RFC 9457), authentication (JWT/OAuth2/API keys), idempotency, file uploads, webhooks, and OpenAPI documentation. Use when designing APIs, choosing protocols, or implementing API standards.
4
- allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 3.1.0
6
- last-updated: 2026-04-07
7
- applies-to-model: gemini-3-1-pro, claude-3-7-sonnet
8
- ---
9
-
10
- # API Patterns — Design & Protocol Mastery
11
-
12
- ## Hallucination Traps (Read First)
13
- - ❌ JWT in URL query params → ✅ `Authorization: Bearer` header only. Query params get logged in server access logs.
14
- - ❌ Assuming JWT is encrypted → ✅ JWT is base64-encoded (NOT encrypted). Anyone can decode it. Never put secrets/PII in the payload.
15
- - ❌ Offset pagination on large tables → ✅ `OFFSET 100000` scans and discards 100K rows. Use cursor pagination for tables > 10K rows.
16
- - ❌ Verbs in REST URLs (`/api/getUsers`) → ✅ Nouns only (`GET /api/users`). HTTP method IS the verb.
17
- - ❌ `POST` is idempotent → ✅ `POST` is NOT idempotent — requires `Idempotency-Key` header for safe retries.
18
- - ❌ GraphQL has no security risks → ✅ Deeply nested queries are a DoS vector. Set max depth, query cost limits. Disable introspection in production.
19
-
20
- ---
21
-
22
- ## Protocol Selection Matrix
23
-
24
- | Protocol | Use When |
25
- |----------|----------|
26
- | **REST** | Public APIs, 3rd-party consumers, standard CRUD, HTTP caching |
27
- | **GraphQL** | Complex nested data, multiple clients, flexible queries, mobile bandwidth sensitivity |
28
- | **tRPC** | Full-stack TypeScript (Next.js monorepo), shared types, no codegen |
29
- | **gRPC** | Internal microservices, high-throughput, streaming, binary protocol |
30
- | **WebSocket** | Bidirectional real-time (chat, gaming, live collaboration) |
31
- | **SSE** | Server-to-client streaming only (AI token streaming, live feeds) |
32
-
33
- ---
34
-
35
- ## REST Design
36
-
37
- ### URL Conventions
38
- ```
39
- ✅ GET /api/v1/users list users
40
- ✅ GET /api/v1/users/123 get user by ID
41
- ✅ POST /api/v1/users create user
42
- ✅ PATCH /api/v1/users/123 partial update
43
- ✅ DELETE /api/v1/users/123 delete user
44
- ✅ GET /api/v1/users/123/posts nested resource
45
-
46
- ❌ /api/getUsers /api/createUser /api/user (singular) /api/Users (uppercase)
47
- ```
48
-
49
- ### HTTP Status Codes
50
- ```
51
- 200 OK → GET / PUT / PATCH success
52
- 201 Created → POST success (include Location: /api/v1/users/123 header)
53
- 204 No Content → DELETE success
54
- 400 Bad Request → Malformed request / missing fields
55
- 401 Unauthorized → Missing or invalid authentication
56
- 403 Forbidden → Authenticated but not authorized
57
- 404 Not Found → Resource does not exist
58
- 409 Conflict → Duplicate resource (email already exists)
59
- 422 Unprocessable → Valid JSON, semantically invalid data
60
- 429 Too Many Req → Rate limit exceeded
61
- 500 Internal → Unhandled server error — NEVER expose stack traces
62
- ```
63
-
64
- ### Response Envelope
65
- ```typescript
66
- interface ApiResponse<T> { data: T; meta?: Record<string, unknown>; }
67
-
68
- interface ApiError {
69
- error: {
70
- code: string; // machine-readable: "VALIDATION_ERROR"
71
- message: string; // human-readable: "Email is already in use"
72
- details?: Array<{ field: string; message: string }>; // field-level errors
73
- requestId?: string; // for support/tracing
74
- };
75
- }
76
- ```
77
-
78
- ---
79
-
80
- ## Pagination
81
-
82
- ```typescript
83
- // ✅ Cursor-based — required for large/dynamic datasets
84
- // GET /api/v1/posts?cursor=eyJpZCI6MTAwfQ&limit=20
85
- const posts = await db.post.findMany({
86
- where: { id: { lt: decodeCursor(req.query.cursor).id } },
87
- orderBy: { id: "desc" },
88
- take: limit + 1, // fetch one extra to determine hasMore
89
- });
90
- const hasMore = posts.length > limit;
91
- if (hasMore) posts.pop();
92
- return { data: posts, meta: { hasMore, nextCursor: encodeCursor(posts.at(-1)) } };
93
-
94
- // Offset-based — only for small datasets where users need page jumping
95
- // GET /api/v1/posts?page=3&limit=20
96
- // ❌ TRAP: OFFSET 100000 scans and discards 100K rows — degrades badly at scale
97
- ```
98
-
99
- ---
100
-
101
- ## Idempotency
102
-
103
- ```typescript
104
- // POST /api/v1/payments with header: Idempotency-Key: <uuid>
105
- app.post("/api/v1/payments", async (req, res) => {
106
- const key = req.headers["idempotency-key"];
107
- if (!key) return res.status(400).json({ error: "Missing Idempotency-Key" });
108
-
109
- const cached = await redis.get(`idempotency:${key}`);
110
- if (cached) return res.status(200).json(JSON.parse(cached));
111
-
112
- const result = await processPayment(req.body);
113
- await redis.set(`idempotency:${key}`, JSON.stringify(result), "EX", 86400);
114
- return res.status(201).json(result);
115
- });
116
- // GET, PUT, DELETE → naturally idempotent (safe to retry without a key)
117
- // POST, PATCH → NOT idempotent by default — require Idempotency-Key
118
- ```
119
-
120
- ---
121
-
122
- ## Webhooks
123
-
124
- ```typescript
125
- // HMAC signature verification (always verify — never trust unsigned webhooks)
126
- import { createHmac, timingSafeEqual } from "node:crypto";
127
- function verify(payload: string, signature: string, secret: string): boolean {
128
- const expected = createHmac("sha256", secret).update(payload).digest("hex");
129
- return timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
130
- }
131
-
132
- app.post("/webhooks", (req, res) => {
133
- if (!verify(JSON.stringify(req.body), req.headers["x-webhook-signature"] as string, WEBHOOK_SECRET))
134
- return res.status(401).send("Invalid signature");
135
- res.status(200).send("OK"); // respond immediately
136
- processWebhookAsync(req.body); // process asynchronously
137
- });
138
- // Retry policy: 3 retries with exponential backoff (1s → 10s → 100s)
139
- // Include unique event ID in payload for receiver-side deduplication
140
- ```
141
-
142
- ---
143
-
144
- ## Versioning
145
-
146
- ```
147
- URL path (recommended): /api/v1/users → simplest, most common, cache-friendly
148
- Header: Accept: application/vnd.api.v1+json
149
- Query param: /api/users?version=1 → messy, avoid
150
-
151
- Rules:
152
- - Start at v1, never v0
153
- - Breaking changes = new major version (v2)
154
- - Non-breaking additions (new optional fields) do NOT need a version bump
155
- - Deprecate before removing — give consumers 6+ months notice
156
- ```
157
-
158
- ---
159
-
160
- ## Rate Limiting
161
-
162
- ```
163
- Strategy How When
164
- Token bucket → Burst allowed, refills Most APIs (recommended)
165
- Sliding window → Smooth distribution Strict fairness required
166
- Fixed window → Simple counter per period Basic needs only
167
-
168
- Response headers to always include:
169
- X-RateLimit-Limit (max requests in window)
170
- X-RateLimit-Remaining (requests left)
171
- X-RateLimit-Reset (Unix timestamp when limit resets)
172
- Retry-After (seconds to wait on 429)
173
- ```
174
-
175
- ---
176
-
177
- ## GraphQL Security
178
-
179
- ```
180
- Protect against:
181
- Depth attacks → Set max query depth (typically 7–10)
182
- Cost attacks → Calculate query complexity score, reject > threshold
183
- Batch abuse → Limit batch size / alias count
184
- Introspection → Disable in production (exposes full schema to attackers)
185
- ```
186
-
187
- ---
188
-
189
- ## Authentication Selection
190
-
191
- | Pattern | Best For |
192
- |---------|----------|
193
- | **JWT** (short-lived access + httpOnly refresh) | Stateless services, microservices |
194
- | **Session** | Traditional server-rendered apps |
195
- | **OAuth 2.0 / OIDC** | Third-party login, delegated access |
196
- | **API Key** | Server-to-server, public API consumers |
197
- | **Passkey (WebAuthn)** | Modern passwordless (2026+) |
1
+ ---
2
+ name: api-patterns
3
+ description: API design mastery. REST, GraphQL, tRPC, and gRPC selection. Request/response design, pagination (cursor/offset), filtering, versioning, rate limiting, error formats (RFC 9457), authentication (JWT/OAuth2/API keys), idempotency, file uploads, webhooks, and OpenAPI documentation. Use when designing APIs, choosing protocols, or implementing API standards.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 3.1.0
6
+ last-updated: 2026-04-07
7
+ applies-to-model: gemini-3-1-pro, claude-3-7-sonnet
8
+ ---
9
+
10
+ # API Patterns — Design & Protocol Mastery
11
+
12
+ ## Hallucination Traps (Read First)
13
+ - ❌ JWT in URL query params → ✅ `Authorization: Bearer` header only. Query params get logged in server access logs.
14
+ - ❌ Assuming JWT is encrypted → ✅ JWT is base64-encoded (NOT encrypted). Anyone can decode it. Never put secrets/PII in the payload.
15
+ - ❌ Offset pagination on large tables → ✅ `OFFSET 100000` scans and discards 100K rows. Use cursor pagination for tables > 10K rows.
16
+ - ❌ Verbs in REST URLs (`/api/getUsers`) → ✅ Nouns only (`GET /api/users`). HTTP method IS the verb.
17
+ - ❌ `POST` is idempotent → ✅ `POST` is NOT idempotent — requires `Idempotency-Key` header for safe retries.
18
+ - ❌ GraphQL has no security risks → ✅ Deeply nested queries are a DoS vector. Set max depth, query cost limits. Disable introspection in production.
19
+
20
+ ---
21
+
22
+ ## Protocol Selection Matrix
23
+
24
+ | Protocol | Use When |
25
+ |----------|----------|
26
+ | **REST** | Public APIs, 3rd-party consumers, standard CRUD, HTTP caching |
27
+ | **GraphQL** | Complex nested data, multiple clients, flexible queries, mobile bandwidth sensitivity |
28
+ | **tRPC** | Full-stack TypeScript (Next.js monorepo), shared types, no codegen |
29
+ | **gRPC** | Internal microservices, high-throughput, streaming, binary protocol |
30
+ | **WebSocket** | Bidirectional real-time (chat, gaming, live collaboration) |
31
+ | **SSE** | Server-to-client streaming only (AI token streaming, live feeds) |
32
+
33
+ ---
34
+
35
+ ## REST Design
36
+
37
+ ### URL Conventions
38
+ ```
39
+ ✅ GET /api/v1/users list users
40
+ ✅ GET /api/v1/users/123 get user by ID
41
+ ✅ POST /api/v1/users create user
42
+ ✅ PATCH /api/v1/users/123 partial update
43
+ ✅ DELETE /api/v1/users/123 delete user
44
+ ✅ GET /api/v1/users/123/posts nested resource
45
+
46
+ ❌ /api/getUsers /api/createUser /api/user (singular) /api/Users (uppercase)
47
+ ```
48
+
49
+ ### HTTP Status Codes
50
+ ```
51
+ 200 OK → GET / PUT / PATCH success
52
+ 201 Created → POST success (include Location: /api/v1/users/123 header)
53
+ 204 No Content → DELETE success
54
+ 400 Bad Request → Malformed request / missing fields
55
+ 401 Unauthorized → Missing or invalid authentication
56
+ 403 Forbidden → Authenticated but not authorized
57
+ 404 Not Found → Resource does not exist
58
+ 409 Conflict → Duplicate resource (email already exists)
59
+ 422 Unprocessable → Valid JSON, semantically invalid data
60
+ 429 Too Many Req → Rate limit exceeded
61
+ 500 Internal → Unhandled server error — NEVER expose stack traces
62
+ ```
63
+
64
+ ### Response Envelope
65
+ ```typescript
66
+ interface ApiResponse<T> { data: T; meta?: Record<string, unknown>; }
67
+
68
+ interface ApiError {
69
+ error: {
70
+ code: string; // machine-readable: "VALIDATION_ERROR"
71
+ message: string; // human-readable: "Email is already in use"
72
+ details?: Array<{ field: string; message: string }>; // field-level errors
73
+ requestId?: string; // for support/tracing
74
+ };
75
+ }
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Pagination
81
+
82
+ ```typescript
83
+ // ✅ Cursor-based — required for large/dynamic datasets
84
+ // GET /api/v1/posts?cursor=eyJpZCI6MTAwfQ&limit=20
85
+ const posts = await db.post.findMany({
86
+ where: { id: { lt: decodeCursor(req.query.cursor).id } },
87
+ orderBy: { id: "desc" },
88
+ take: limit + 1, // fetch one extra to determine hasMore
89
+ });
90
+ const hasMore = posts.length > limit;
91
+ if (hasMore) posts.pop();
92
+ return { data: posts, meta: { hasMore, nextCursor: encodeCursor(posts.at(-1)) } };
93
+
94
+ // Offset-based — only for small datasets where users need page jumping
95
+ // GET /api/v1/posts?page=3&limit=20
96
+ // ❌ TRAP: OFFSET 100000 scans and discards 100K rows — degrades badly at scale
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Idempotency
102
+
103
+ ```typescript
104
+ // POST /api/v1/payments with header: Idempotency-Key: <uuid>
105
+ app.post("/api/v1/payments", async (req, res) => {
106
+ const key = req.headers["idempotency-key"];
107
+ if (!key) return res.status(400).json({ error: "Missing Idempotency-Key" });
108
+
109
+ const cached = await redis.get(`idempotency:${key}`);
110
+ if (cached) return res.status(200).json(JSON.parse(cached));
111
+
112
+ const result = await processPayment(req.body);
113
+ await redis.set(`idempotency:${key}`, JSON.stringify(result), "EX", 86400);
114
+ return res.status(201).json(result);
115
+ });
116
+ // GET, PUT, DELETE → naturally idempotent (safe to retry without a key)
117
+ // POST, PATCH → NOT idempotent by default — require Idempotency-Key
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Webhooks
123
+
124
+ ```typescript
125
+ // HMAC signature verification (always verify — never trust unsigned webhooks)
126
+ import { createHmac, timingSafeEqual } from "node:crypto";
127
+ function verify(payload: string, signature: string, secret: string): boolean {
128
+ const expected = createHmac("sha256", secret).update(payload).digest("hex");
129
+ return timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
130
+ }
131
+
132
+ app.post("/webhooks", (req, res) => {
133
+ if (!verify(JSON.stringify(req.body), req.headers["x-webhook-signature"] as string, WEBHOOK_SECRET))
134
+ return res.status(401).send("Invalid signature");
135
+ res.status(200).send("OK"); // respond immediately
136
+ processWebhookAsync(req.body); // process asynchronously
137
+ });
138
+ // Retry policy: 3 retries with exponential backoff (1s → 10s → 100s)
139
+ // Include unique event ID in payload for receiver-side deduplication
140
+ ```
141
+
142
+ ---
143
+
144
+ ## Versioning
145
+
146
+ ```
147
+ URL path (recommended): /api/v1/users → simplest, most common, cache-friendly
148
+ Header: Accept: application/vnd.api.v1+json
149
+ Query param: /api/users?version=1 → messy, avoid
150
+
151
+ Rules:
152
+ - Start at v1, never v0
153
+ - Breaking changes = new major version (v2)
154
+ - Non-breaking additions (new optional fields) do NOT need a version bump
155
+ - Deprecate before removing — give consumers 6+ months notice
156
+ ```
157
+
158
+ ---
198
159
 
160
+ ## Rate Limiting
161
+
162
+ ```
163
+ Strategy How When
164
+ Token bucket → Burst allowed, refills Most APIs (recommended)
165
+ Sliding window → Smooth distribution Strict fairness required
166
+ Fixed window → Simple counter per period Basic needs only
167
+
168
+ Response headers to always include:
169
+ X-RateLimit-Limit (max requests in window)
170
+ X-RateLimit-Remaining (requests left)
171
+ X-RateLimit-Reset (Unix timestamp when limit resets)
172
+ Retry-After (seconds to wait on 429)
173
+ ```
199
174
 
200
175
  ---
201
176
 
202
- ## 🤖 LLM-Specific Traps
177
+ ## GraphQL Security
178
+
179
+ ```
180
+ Protect against:
181
+ Depth attacks → Set max query depth (typically 7–10)
182
+ Cost attacks → Calculate query complexity score, reject > threshold
183
+ Batch abuse → Limit batch size / alias count
184
+ Introspection → Disable in production (exposes full schema to attackers)
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Authentication Selection
190
+
191
+ | Pattern | Best For |
192
+ |---------|----------|
193
+ | **JWT** (short-lived access + httpOnly refresh) | Stateless services, microservices |
194
+ | **Session** | Traditional server-rendered apps |
195
+ | **OAuth 2.0 / OIDC** | Third-party login, delegated access |
196
+ | **API Key** | Server-to-server, public API consumers |
197
+ | **Passkey (WebAuthn)** | Modern passwordless (2026+) |
198
+
199
+
200
+ ---
201
+
202
+
203
203
 
204
204
  AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
205
205
 
@@ -211,7 +211,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
211
211
 
212
212
  ---
213
213
 
214
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
214
+
215
215
 
216
216
  **Slash command: `/review` or `/tribunal-full`**
217
217
  **Active reviewers: `logic-reviewer` · `security-auditor`**
@@ -222,7 +222,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
222
222
  2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
223
223
  3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
224
224
 
225
- ### ✅ Pre-Flight Self-Audit
225
+
226
226
 
227
227
  Review these questions before confirming output:
228
228
  ```
@@ -236,4 +236,12 @@ Review these questions before confirming output:
236
236
 
237
237
  **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
238
238
  - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
239
- - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
239
+ - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
240
+
241
+
242
+ ## Pre-Flight Checklist
243
+ - [ ] Have I reviewed the user's specific constraints and requests?
244
+ - [ ] Have I checked the environment for relevant existing implementations?
245
+
246
+ ## VBC Protocol (Verification-Before-Completion)
247
+ You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
@@ -145,7 +145,7 @@ const server = new ApolloServer({
145
145
 
146
146
  ---
147
147
 
148
- ## 🤖 LLM-Specific Traps
148
+
149
149
 
150
150
  AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
151
151
 
@@ -157,7 +157,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
157
157
 
158
158
  ---
159
159
 
160
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
160
+
161
161
 
162
162
  **Slash command: `/review` or `/tribunal-full`**
163
163
  **Active reviewers: `logic-reviewer` · `security-auditor`**
@@ -168,7 +168,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
168
168
  2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
169
169
  3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
170
170
 
171
- ### ✅ Pre-Flight Self-Audit
171
+
172
172
 
173
173
  Review these questions before confirming output:
174
174
  ```
@@ -182,4 +182,12 @@ Review these questions before confirming output:
182
182
 
183
183
  **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
184
184
  - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
185
- - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
185
+ - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
186
+
187
+
188
+ ## Pre-Flight Checklist
189
+ - [ ] Have I reviewed the user's specific constraints and requests?
190
+ - [ ] Have I checked the environment for relevant existing implementations?
191
+
192
+ ## VBC Protocol (Verification-Before-Completion)
193
+ You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
@@ -524,7 +524,7 @@ Monorepo:
524
524
 
525
525
  ---
526
526
 
527
- ## 🤖 LLM-Specific Traps
527
+
528
528
 
529
529
  AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
530
530
 
@@ -536,7 +536,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
536
536
 
537
537
  ---
538
538
 
539
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
539
+
540
540
 
541
541
  **Slash command: `/review` or `/tribunal-full`**
542
542
  **Active reviewers: `logic-reviewer` · `security-auditor`**
@@ -547,7 +547,7 @@ AI coding assistants often fall into specific bad habits when dealing with this
547
547
  2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
548
548
  3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
549
549
 
550
- ### ✅ Pre-Flight Self-Audit
550
+
551
551
 
552
552
  Review these questions before confirming output:
553
553
  ```
@@ -561,4 +561,12 @@ Review these questions before confirming output:
561
561
 
562
562
  **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
563
563
  - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
564
- - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
564
+ - ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
565
+
566
+
567
+ ## Pre-Flight Checklist
568
+ - [ ] Have I reviewed the user's specific constraints and requests?
569
+ - [ ] Have I checked the environment for relevant existing implementations?
570
+
571
+ ## VBC Protocol (Verification-Before-Completion)
572
+ You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
@@ -35,73 +35,81 @@ allowed-tools: Read, Glob, Grep
35
35
  2. Match to appropriate template
36
36
  3. Read ONLY that template's TEMPLATE.md
37
37
  4. Follow its tech stack and structure
38
-
39
- ---
40
-
41
- ## 🚨 LLM Trap Table
42
-
43
- |Pattern|What AI Does Wrong|What Is Actually Correct|
44
- |:---|:---|:---|
45
- |[domain-specific trap 1]|[hallucination]|[correct behavior]|
46
- |[domain-specific trap 2]|[hallucination]|[correct behavior]|
47
- |[domain-specific trap 3]|[hallucination]|[correct behavior]|
48
-
49
- ---
50
-
51
- ## ✅ Pre-Flight Self-Audit
52
-
53
- Before producing any output, verify:
54
- ``
55
- ✅ Did I read the actual files before making claims about them?
56
- ✅ Did I verify all method names against official documentation?
57
- ✅ Did I add // VERIFY: on any uncertain API calls?
58
- ✅ Are all imports from packages that actually exist in package.json?
59
- ✅ Did I test my logic with edge cases (null, empty, 0, max)?
60
- ✅ Did I avoid generating code for more than one module at a time?
61
- ✅ Am I working from evidence, not assumption?
62
- ``
63
-
64
- ---
65
-
66
- ## 🔁 VBC Protocol (Verify → Build → Confirm)
67
-
68
- ``
69
- VERIFY: Read the actual codebase before writing anything
70
- BUILD: Generate the smallest meaningful unit of code
71
- CONFIRM: Verify the output is correct before presenting
38
+
39
+ ---
40
+
41
+ ## 🚨 LLM Trap Table
42
+
43
+ |Pattern|What AI Does Wrong|What Is Actually Correct|
44
+ |:---|:---|:---|
45
+ |[domain-specific trap 1]|[hallucination]|[correct behavior]|
46
+ |[domain-specific trap 2]|[hallucination]|[correct behavior]|
47
+ |[domain-specific trap 3]|[hallucination]|[correct behavior]|
48
+
49
+ ---
50
+
51
+ ## ✅ Pre-Flight Self-Audit
52
+
53
+ Before producing any output, verify:
72
54
  ``
73
-
74
- ---
75
-
76
- ## 🚨 LLM Trap Table
77
-
78
- |Pattern|What AI Does Wrong|What Is Actually Correct|
79
- |:---|:---|:---|
80
- |[domain-specific trap 1]|[hallucination]|[correct behavior]|
81
- |[domain-specific trap 2]|[hallucination]|[correct behavior]|
82
- |[domain-specific trap 3]|[hallucination]|[correct behavior]|
83
-
84
- ---
85
-
86
- ## ✅ Pre-Flight Self-Audit
87
-
88
- Before producing any output, verify:
89
- ``
90
- ✅ Did I read the actual files before making claims about them?
91
- ✅ Did I verify all method names against official documentation?
92
- ✅ Did I add // VERIFY: on any uncertain API calls?
93
- ✅ Are all imports from packages that actually exist in package.json?
94
- ✅ Did I test my logic with edge cases (null, empty, 0, max)?
95
- ✅ Did I avoid generating code for more than one module at a time?
96
- ✅ Am I working from evidence, not assumption?
97
- ``
98
-
99
- ---
100
-
101
- ## 🔁 VBC Protocol (Verify → Build → Confirm)
102
-
103
- ``
104
- VERIFY: Read the actual codebase before writing anything
105
- BUILD: Generate the smallest meaningful unit of code
106
- CONFIRM: Verify the output is correct before presenting
55
+ ✅ Did I read the actual files before making claims about them?
56
+ ✅ Did I verify all method names against official documentation?
57
+ ✅ Did I add // VERIFY: on any uncertain API calls?
58
+ ✅ Are all imports from packages that actually exist in package.json?
59
+ ✅ Did I test my logic with edge cases (null, empty, 0, max)?
60
+ ✅ Did I avoid generating code for more than one module at a time?
61
+ ✅ Am I working from evidence, not assumption?
107
62
  ``
63
+
64
+ ---
65
+
66
+ ## 🔁 VBC Protocol (Verify → Build → Confirm)
67
+
68
+ ``
69
+ VERIFY: Read the actual codebase before writing anything
70
+ BUILD: Generate the smallest meaningful unit of code
71
+ CONFIRM: Verify the output is correct before presenting
72
+ ``
73
+
74
+ ---
75
+
76
+ ## 🚨 LLM Trap Table
77
+
78
+ |Pattern|What AI Does Wrong|What Is Actually Correct|
79
+ |:---|:---|:---|
80
+ |[domain-specific trap 1]|[hallucination]|[correct behavior]|
81
+ |[domain-specific trap 2]|[hallucination]|[correct behavior]|
82
+ |[domain-specific trap 3]|[hallucination]|[correct behavior]|
83
+
84
+ ---
85
+
86
+ ## ✅ Pre-Flight Self-Audit
87
+
88
+ Before producing any output, verify:
89
+ ``
90
+ ✅ Did I read the actual files before making claims about them?
91
+ ✅ Did I verify all method names against official documentation?
92
+ ✅ Did I add // VERIFY: on any uncertain API calls?
93
+ ✅ Are all imports from packages that actually exist in package.json?
94
+ ✅ Did I test my logic with edge cases (null, empty, 0, max)?
95
+ ✅ Did I avoid generating code for more than one module at a time?
96
+ ✅ Am I working from evidence, not assumption?
97
+ ``
98
+
99
+ ---
100
+
101
+ ## 🔁 VBC Protocol (Verify → Build → Confirm)
102
+
103
+ ``
104
+ VERIFY: Read the actual codebase before writing anything
105
+ BUILD: Generate the smallest meaningful unit of code
106
+ CONFIRM: Verify the output is correct before presenting
107
+ ``
108
+
109
+
110
+ ## Pre-Flight Checklist
111
+ - [ ] Have I reviewed the user's specific constraints and requests?
112
+ - [ ] Have I checked the environment for relevant existing implementations?
113
+
114
+ ## VBC Protocol (Verification-Before-Completion)
115
+ You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
@@ -73,4 +73,4 @@ project-name/
73
73
  - Use Content Collections for type safety
74
74
  - Leverage static generation
75
75
  - Add islands only where needed
76
- - Optimize images with Astro Image
76
+ - Optimize images with Astro Image