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,206 +1,360 @@
1
- ---
2
- name: clean-code
3
- description: Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
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
- # Clean Code Standards
11
-
12
- > Code is read far more than it is written. Write for the next person.
13
- > That person is often you, six months from now, confused.
14
-
15
- ---
16
-
17
- ## Core Philosophy
18
-
19
- Clean code is not aesthetic. It is functional. Messy code is slow to change, easy to break, and hard to debug. These standards exist to make code **safe to modify** — not to make it look clever.
20
-
21
- ---
22
-
23
- ## Naming
24
-
25
- Names are the primary documentation. Choose them seriously.
26
-
27
- **Rules:**
28
- - Variables and functions describe what they hold or do — not how they do it
29
- - Boolean names start with `is`, `has`, `can`, `should`
30
- - No single-letter names except loop counters (`i`, `j`) and throwaway lambdas
31
- - No abbreviations unless they are industry-wide (`url`, `id`, `dto`, `api`)
32
- - Name at the right level of abstraction `user` not `userObjectFromDatabase`
33
-
34
- ```ts
35
- // ❌ Unclear
36
- const d = new Date();
37
- const fn = (x) => x * 1.2;
38
-
39
- // Self-documenting
40
- const createdAt = new Date();
41
- const applyTax = (price: number) => price * 1.2;
42
- ```
43
-
44
- ---
45
-
46
- ## Functions
47
-
48
- A function does one thing. If you need "and" to describe it, split it.
49
-
50
- - Max ~20 lines per function before questioning its scope
51
- - Arguments: 0–2 preferred, 3 acceptable, 4+ is a signal to use an options object
52
- - No boolean flags as arguments — they mean the function does two things
53
- - Return early to avoid nesting — guard clauses before main logic
54
-
55
- ```ts
56
- // Flag argument
57
- function createUser(data: UserData, sendEmail: boolean) { ... }
58
-
59
- // ✅ Two clear functions
60
- function createUser(data: UserData) { ... }
61
- function createUserAndNotify(data: UserData) { ... }
62
- ```
63
-
64
- ---
65
-
66
- ## Comments
67
-
68
- Comments explain **why** — not **what**.
69
-
70
- - Code explains what it does. A comment explaining what code does means the code is unclear — rewrite the code.
71
- - Comments explain intent, business rules, non-obvious constraints, and external references
72
- - Never leave commented-out code in a commit. Use version control.
73
-
74
- ```ts
75
- // ❌ Pointless comment
76
- // Get the user by id
77
- const user = await getUser(id);
78
-
79
- // ✅ Useful comment
80
- // Retry up to 3 times — payment gateway times out under load
81
- const result = await retry(() => chargeCard(amount), 3);
82
- ```
83
-
84
- ---
85
-
86
- ## Error Handling
87
-
88
- Errors are part of the contract. Don't hide them.
89
-
90
- - Every async function must handle its rejection — `try/catch` or `.catch()`
91
- - Log full context: what operation failed, with what input, what the error was
92
- - Never swallow errors silently (`catch (e) {}`)
93
- - User-facing error messages are different from developer error messages — don't conflate them
94
-
95
- ---
96
-
97
- ## Testing Standards
98
-
99
- Tests make refactoring safe. Without them, every change is a gamble.
100
-
101
- **AAA Pattern every test:**
102
- ```
103
- Arrange set up what you need
104
- Act → call the thing being tested
105
- Assert → verify the outcome
106
- ```
107
-
108
- **Test pyramid:**
109
- - Unit tests: fast, isolated, abundant test one function
110
- - Integration tests: slower, test how components interact
111
- - E2E tests: fewest, test the full user path
112
-
113
- **Rules:**
114
- - One assertion per concept (multiple `expect` calls OK if they verify the same outcome)
115
- - Tests must pass consistently a flaky test is a broken test
116
- - Descriptive test names: `should return 401 when token is expired` not `test auth`
117
-
118
- ---
119
-
120
- ## Performance
121
-
122
- Measure first. Optimize what is actually slow.
123
-
124
- - Profile before assuming perceived slowness is not always where you think
125
- - O(n²) in a list that never exceeds 10 items is not a problem worth solving
126
- - Premature optimization adds complexity and creates bugs
127
- - Core Web Vitals are the standard for frontend performance targets (2025)
128
-
129
- ---
130
-
131
- ## Security Baseline (Always)
132
-
133
- These are not optional:
134
-
135
- - Secrets in environment variables — never in code
136
- - All SQL queries parameterized — never string-interpolated
137
- - User input validated at every boundary — never trusted
138
- - Authentication checked before business logic executes
139
-
140
- ---
141
-
142
- ## 🤖 LLM-Specific Clean Code Traps
143
-
144
- AI coding assistants (like you) fall into specific bad habits when writing code. These are strictly forbidden under the clean-code standard:
145
-
146
- 1. **JSDoc/Docstring Spam:** Documenting what a function does when the code is self-evident.
147
- * *❌ AI Trait:* `/** Adds two numbers. @param a First number @param b Second number @returns The sum */ function add(a, b) { return a + b; }`
148
- * *✅ Clean Code:* `function add(a: number, b: number): number { return a + b; }`
149
- 2. **Defensive Programming Overkill:** Adding 15 `null` checks where the TypeScript compiler or the previous tier has already guaranteed validity.
150
- 3. **Premature Abstraction:** Creating an `AbstractDataManager` factory class with interfaces to parse a simple CSV file. Code what is needed *now*.
151
- 4. **Variable Diarrhea:** Extracting every step of a calculation into a separate `const` when a single readable line would suffice.
152
- 5. **Apologetic Comments:** `// TODO: Refactor this later` or `// I assumed this was the right way`. If you write it, own it. If it's incomplete, flag the user.
153
-
154
- ---
155
-
156
- ## Output Format
157
-
158
- When this skill produces or reviews code, structure your output as follows:
159
-
160
- ```
161
- ━━━ Clean Code Report ━━━━━━━━━━━━━━━━━━━━━━━━
162
- Skill: Clean Code
163
- Language: [detected language / framework]
164
- Scope: [N files · N functions]
165
- ─────────────────────────────────────────────────
166
- Passed: [checks that passed, or "All clean"]
167
- ⚠️ Warnings: [non-blocking issues, or "None"]
168
- ❌ Blocked: [blocking issues requiring fix, or "None"]
169
- ─────────────────────────────────────────────────
170
- VBC status: PENDING VERIFIED
171
- Evidence: [test output / lint pass / compile success]
172
- ```
173
-
174
- **VBC (Verification-Before-Completion) is mandatory.**
175
- Do not mark status as VERIFIED until concrete terminal evidence is provided.
176
-
177
-
178
- ---
179
-
180
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
181
-
182
- **Slash command: `/generate`, `/review-types`**
183
- **Active reviewers: `logic-reviewer` · `type-safety-reviewer`**
184
-
185
- ### ❌ Forbidden AI Tropes in Code Generation
186
-
187
- 1. **Over-engineering:** Solving a problem with 3 classes when 1 function works perfectly.
188
- 2. **Commented-out code:** Submitting commented-out dead code, "just in case." Delete it.
189
- 3. **Implicit `any` types:** Failing to strictly type a critical parameter or return value.
190
-
191
- ### Pre-Flight Self-Audit
192
-
193
- Review these questions before confirming code generation or review:
194
- ```
195
- Does this function do strictly ONE thing?
196
- Have I removed all pointless comments explaining *what* the code does?
197
- ✅ Did I use specific, business-logic naming rather than generic abbreviations?
198
- ✅ Are all edge cases and rejections properly handled (no swallowed errors)?
199
- ✅ Did I avoid over-engineering this solution?
200
- ```
201
-
202
- ### 🛑 Verification-Before-Completion (VBC) Protocol
203
-
204
- **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
205
- - **Forbidden:** Refactoring code or blindly applying "clean code" rules without verifying the code still compiles and works.
206
- - **Required:** You are explicitly forbidden from finalizing a refactor without providing **concrete terminal evidence** (e.g., passing unit tests logs, successful linting execution, or type-check success) proving the refactored code maintains the original behavior.
1
+ ---
2
+ name: clean-code
3
+ description: Clean code mastery. Naming conventions, function design, DRY vs WET, SOLID principles with code examples, refactoring patterns, code smells detection, error handling philosophy, comments that add value, and the art of simplicity. Use when reviewing code quality, refactoring, or establishing coding standards.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 2.0.0
6
+ last-updated: 2026-04-01
7
+ applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
+ ---
9
+
10
+ # Clean Code — The Art of Readable Software
11
+
12
+ > Clean code reads like well-written prose. If you need a comment to explain what it does, rename the function.
13
+ > The ratio of time spent reading code to writing code is 10:1. Optimize for the reader.
14
+
15
+ ---
16
+
17
+ ## Naming
18
+
19
+ ### Variables & Functions
20
+
21
+ ```typescript
22
+ // ❌ BAD: Cryptic, abbreviated, meaningless
23
+ const d = new Date();
24
+ const u = getU();
25
+ const flag = true;
26
+ function proc(x: number): number { return x * 1.08; }
27
+
28
+ // GOOD: Self-documenting, reveals intent
29
+ const registrationDate = new Date();
30
+ const currentUser = getCurrentUser();
31
+ const isEligibleForDiscount = true;
32
+ function addSalesTax(price: number): number { return price * 1.08; }
33
+ ```
34
+
35
+ ### Booleans
36
+
37
+ ```typescript
38
+ // ❌ BAD ✅ GOOD
39
+ const active = true; const isActive = true;
40
+ const admin = false; const hasAdminRole = false;
41
+ const loading = true; const isLoading = true;
42
+ const open = false; const isModalOpen = false;
43
+ const valid = true; const canSubmit = true;
44
+
45
+ // Boolean function names start with is/has/can/should
46
+ function isExpired(token: Token): boolean {}
47
+ function hasPermission(user: User, action: string): boolean {}
48
+ function canRetry(attempt: number): boolean {}
49
+ function shouldNotify(event: Event): boolean {}
50
+ ```
51
+
52
+ ### Constants & Enums
53
+
54
+ ```typescript
55
+ // ❌ BAD: Magic numbers and strings
56
+ if (user.role === 3) { ... }
57
+ if (retries > 5) { ... }
58
+ const delay = 86400000;
59
+
60
+ // ✅ GOOD: Named constants with meaning
61
+ const MAX_RETRY_ATTEMPTS = 5;
62
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;
63
+
64
+ enum UserRole {
65
+ VIEWER = "viewer",
66
+ EDITOR = "editor",
67
+ ADMIN = "admin",
68
+ }
69
+
70
+ if (user.role === UserRole.ADMIN) { ... }
71
+ if (retries > MAX_RETRY_ATTEMPTS) { ... }
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Function Design
77
+
78
+ ### Small, Single-Purpose Functions
79
+
80
+ ```typescript
81
+ // BAD: Does 5 things in one function
82
+ async function processOrder(order: Order) {
83
+ // validate
84
+ if (!order.items.length) throw new Error("Empty");
85
+ if (order.total < 0) throw new Error("Negative");
86
+ // calculate
87
+ const subtotal = order.items.reduce((sum, i) => sum + i.price * i.qty, 0);
88
+ const tax = subtotal * 0.08;
89
+ const total = subtotal + tax;
90
+ // save
91
+ await db.orders.insert({ ...order, total });
92
+ // notify
93
+ await emailService.send(order.userId, "Order placed");
94
+ // log
95
+ logger.info("Order processed", { orderId: order.id });
96
+ }
97
+
98
+ // ✅ GOOD: Each function does one thing
99
+ async function processOrder(order: Order): Promise<ProcessedOrder> {
100
+ validateOrder(order);
101
+ const totals = calculateTotals(order.items);
102
+ const savedOrder = await saveOrder(order, totals);
103
+ await notifyCustomer(savedOrder);
104
+ return savedOrder;
105
+ }
106
+
107
+ function validateOrder(order: Order): void {
108
+ if (!order.items.length) throw new ValidationError("Order cannot be empty");
109
+ if (order.total < 0) throw new ValidationError("Total cannot be negative");
110
+ }
111
+
112
+ function calculateTotals(items: OrderItem[]): OrderTotals {
113
+ const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
114
+ const tax = subtotal * TAX_RATE;
115
+ return { subtotal, tax, total: subtotal + tax };
116
+ }
117
+ ```
118
+
119
+ ### Parameter Rules
120
+
121
+ ```typescript
122
+ // BAD: Too many parameters
123
+ function createUser(
124
+ name: string, email: string, role: string,
125
+ isActive: boolean, avatar: string, bio: string
126
+ ) { ... }
127
+
128
+ // ✅ GOOD: Use an object for 3+ parameters
129
+ interface CreateUserInput {
130
+ name: string;
131
+ email: string;
132
+ role?: UserRole;
133
+ isActive?: boolean;
134
+ avatar?: string;
135
+ bio?: string;
136
+ }
137
+
138
+ function createUser(input: CreateUserInput): User { ... }
139
+
140
+ // ❌ BAD: Boolean parameter (caller can't read intent)
141
+ setVisible(true);
142
+
143
+ // ✅ GOOD: Named method instead
144
+ show();
145
+ hide();
146
+ ```
147
+
148
+ ---
149
+
150
+ ## SOLID Principles (With Code)
151
+
152
+ ### S Single Responsibility
153
+
154
+ ```typescript
155
+ // ❌ BAD: UserService does everything
156
+ class UserService {
157
+ createUser() { ... }
158
+ sendEmail() { ... }
159
+ generateReport() { ... }
160
+ uploadAvatar() { ... }
161
+ }
162
+
163
+ // ✅ GOOD: Separate concerns
164
+ class UserService { createUser() { ... } }
165
+ class EmailService { sendWelcomeEmail() { ... } }
166
+ class ReportService { generateUserReport() { ... } }
167
+ class AvatarService { upload() { ... } }
168
+ ```
169
+
170
+ ### O Open/Closed
171
+
172
+ ```typescript
173
+ // ❌ BAD: Adding a new type requires modifying existing code
174
+ function calculateDiscount(type: string, amount: number): number {
175
+ if (type === "student") return amount * 0.20;
176
+ if (type === "veteran") return amount * 0.15;
177
+ if (type === "senior") return amount * 0.10; // must modify for every new type
178
+ return 0;
179
+ }
180
+
181
+ // ✅ GOOD: Open for extension, closed for modification
182
+ interface DiscountStrategy {
183
+ calculate(amount: number): number;
184
+ }
185
+
186
+ class StudentDiscount implements DiscountStrategy {
187
+ calculate(amount: number) { return amount * 0.20; }
188
+ }
189
+
190
+ class VeteranDiscount implements DiscountStrategy {
191
+ calculate(amount: number) { return amount * 0.15; }
192
+ }
193
+
194
+ // New types = new class, no existing code changes
195
+ class EmployeeDiscount implements DiscountStrategy {
196
+ calculate(amount: number) { return amount * 0.25; }
197
+ }
198
+ ```
199
+
200
+ ### D — Dependency Inversion
201
+
202
+ ```typescript
203
+ // ❌ BAD: High-level module depends on low-level concrete
204
+ class OrderService {
205
+ private db = new MySQLDatabase(); // coupled to MySQL
206
+ private mailer = new SendGridMailer(); // coupled to SendGrid
207
+ }
208
+
209
+ // ✅ GOOD: Depend on abstractions (interfaces)
210
+ interface Database { save(data: unknown): Promise<void>; }
211
+ interface Mailer { send(to: string, body: string): Promise<void>; }
212
+
213
+ class OrderService {
214
+ constructor(
215
+ private db: Database, // can be MySQL, Postgres, in-memory
216
+ private mailer: Mailer, // can be SendGrid, SES, mock
217
+ ) {}
218
+ }
219
+ ```
220
+
221
+ ---
222
+
223
+ ## Error Handling
224
+
225
+ ```typescript
226
+ // ❌ BAD: Swallowing errors
227
+ try {
228
+ await saveUser(user);
229
+ } catch (e) {
230
+ // silence
231
+ }
232
+
233
+ // ❌ BAD: Generic catch-all
234
+ try {
235
+ await processPayment(order);
236
+ } catch (e) {
237
+ console.log("Something went wrong");
238
+ }
239
+
240
+ // ✅ GOOD: Handle specific errors, propagate unexpected
241
+ try {
242
+ await processPayment(order);
243
+ } catch (error) {
244
+ if (error instanceof InsufficientFundsError) {
245
+ return { success: false, message: "Insufficient funds" };
246
+ }
247
+ if (error instanceof PaymentGatewayError) {
248
+ logger.warn("Payment gateway unavailable, queuing for retry", { orderId: order.id });
249
+ await retryQueue.add(order);
250
+ return { success: false, message: "Payment processing delayed" };
251
+ }
252
+ throw error; // unexpected error — let it propagate
253
+ }
254
+ ```
255
+
256
+ ---
257
+
258
+ ## Comments
259
+
260
+ ```typescript
261
+ // ❌ BAD: Comments that restate the code
262
+ // Increment i by 1
263
+ i++;
264
+
265
+ // Set the user's name
266
+ user.name = newName;
267
+
268
+ // Check if user is active
269
+ if (user.isActive) { ... }
270
+
271
+ // ✅ GOOD: Comments that explain WHY, not WHAT
272
+ // Tax exemption expires after 365 days per IRS Publication 334
273
+ const isExempt = daysSinceRegistration < 365;
274
+
275
+ // Using binary search here because the list is pre-sorted and
276
+ // can contain 100K+ items. Linear search caused P95 > 2s.
277
+ const index = binarySearch(sortedItems, target);
278
+
279
+ // Retry 3 times because the payment gateway has transient 503s
280
+ // during their daily maintenance window (02:00-02:15 UTC)
281
+ const result = await withRetry(() => chargeCard(amount), { maxRetries: 3 });
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Code Smells → Refactoring
287
+
288
+ ```
289
+ Smell → Refactoring
290
+ ───────────────────────────────────────
291
+ Long function (>30 lines) → Extract method
292
+ Deep nesting (>3 levels) → Early return / guard clauses
293
+ Duplicate code → Extract shared function
294
+ Magic numbers → Named constants
295
+ Boolean parameters → Separate methods or options object
296
+ God class (>300 lines) → Split into focused classes
297
+ Feature envy → Move method to appropriate class
298
+ Primitive obsession → Value objects (Email, Money, UserId)
299
+ Long parameter list → Parameter object
300
+ ```
301
+
302
+ ```typescript
303
+ // Deep nesting → Early return
304
+ // ❌ BAD
305
+ function processUser(user: User) {
306
+ if (user) {
307
+ if (user.isActive) {
308
+ if (user.hasPermission("edit")) {
309
+ // actual logic buried 3 levels deep
310
+ doStuff();
311
+ }
312
+ }
313
+ }
314
+ }
315
+
316
+ // ✅ GOOD: Guard clauses — fail fast, keep happy path unindented
317
+ function processUser(user: User) {
318
+ if (!user) return;
319
+ if (!user.isActive) return;
320
+ if (!user.hasPermission("edit")) return;
321
+
322
+ doStuff(); // happy path at top level
323
+ }
324
+ ```
325
+
326
+ ---
327
+
328
+ ## 🤖 LLM-Specific Traps
329
+
330
+ 1. **Comments That Restate Code:** `// Set name to value` above `name = value` adds zero information.
331
+ 2. **Abbreviations Without Context:** `usr`, `mgr`, `proc`, `calc` — use full words.
332
+ 3. **Giant Functions:** If a function is >30 lines, it's doing too many things. Split it.
333
+ 4. **Boolean Parameters:** `setVisible(true)` is unreadable. Use named methods: `show()`, `hide()`.
334
+ 5. **Magic Numbers:** `if (retries > 5)` — what's 5? Use `MAX_RETRY_ATTEMPTS`.
335
+ 6. **Swallowing Errors:** `catch (e) {}` — silent failures are worse than crashes.
336
+ 7. **Generic Error Messages:** `"Something went wrong"` helps no one. Be specific.
337
+ 8. **Over-Commenting Obvious Code:** Comments should explain *why*, not *what*.
338
+ 9. **Deep Nesting:** 3+ levels of nesting → use guard clauses and early returns.
339
+ 10. **Premature Abstraction:** Don't create interfaces/abstractions until you have 2+ implementations.
340
+
341
+ ---
342
+
343
+ ## 🏛️ Tribunal Integration
344
+
345
+ **Slash command: `/review`**
346
+
347
+ ### ✅ Pre-Flight Self-Audit
348
+
349
+ ```
350
+ ✅ Are all names self-documenting (no abbreviations)?
351
+ ✅ Are all booleans prefixed with is/has/can/should?
352
+ ✅ Are functions <30 lines and single-purpose?
353
+ ✅ Are magic numbers replaced with named constants?
354
+ ✅ Do comments explain WHY, not WHAT?
355
+ ✅ Are errors handled specifically (not swallowed or generic)?
356
+ ✅ Is nesting ≤3 levels (using guard clauses)?
357
+ ✅ Are there no boolean parameters?
358
+ ✅ Do functions have ≤3 parameters (or use an object)?
359
+ ✅ Is there no duplicated logic?
360
+ ```