tribunal-kit 2.4.5 → 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 (144) 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 +160 -0
  42. package/.agent/skills/api-patterns/SKILL.md +289 -257
  43. package/.agent/skills/api-security-auditor/SKILL.md +177 -0
  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 -58
  47. package/.agent/skills/architecture/SKILL.md +331 -200
  48. package/.agent/skills/authentication-best-practices/SKILL.md +173 -0
  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 +174 -0
  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 +134 -0
  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 +162 -0
  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/readme-builder/SKILL.md +42 -0
  84. package/.agent/skills/realtime-patterns/SKILL.md +304 -296
  85. package/.agent/skills/rust-pro/SKILL.md +701 -240
  86. package/.agent/skills/seo-fundamentals/SKILL.md +154 -181
  87. package/.agent/skills/server-management/SKILL.md +190 -212
  88. package/.agent/skills/shadcn-ui-expert/SKILL.md +206 -0
  89. package/.agent/skills/skill-creator/SKILL.md +68 -0
  90. package/.agent/skills/sql-pro/SKILL.md +633 -104
  91. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +78 -0
  92. package/.agent/skills/swiftui-expert/SKILL.md +176 -0
  93. package/.agent/skills/systematic-debugging/SKILL.md +118 -186
  94. package/.agent/skills/tailwind-patterns/SKILL.md +576 -232
  95. package/.agent/skills/tdd-workflow/SKILL.md +137 -209
  96. package/.agent/skills/testing-patterns/SKILL.md +573 -205
  97. package/.agent/skills/vue-expert/SKILL.md +964 -119
  98. package/.agent/skills/vulnerability-scanner/SKILL.md +269 -316
  99. package/.agent/skills/web-accessibility-auditor/SKILL.md +193 -0
  100. package/.agent/skills/webapp-testing/SKILL.md +145 -236
  101. package/.agent/workflows/api-tester.md +151 -279
  102. package/.agent/workflows/audit.md +138 -168
  103. package/.agent/workflows/brainstorm.md +110 -146
  104. package/.agent/workflows/changelog.md +112 -144
  105. package/.agent/workflows/create.md +124 -139
  106. package/.agent/workflows/debug.md +189 -196
  107. package/.agent/workflows/deploy.md +189 -153
  108. package/.agent/workflows/enhance.md +151 -139
  109. package/.agent/workflows/fix.md +135 -143
  110. package/.agent/workflows/generate.md +157 -164
  111. package/.agent/workflows/migrate.md +160 -163
  112. package/.agent/workflows/orchestrate.md +168 -151
  113. package/.agent/workflows/performance-benchmarker.md +123 -305
  114. package/.agent/workflows/plan.md +173 -151
  115. package/.agent/workflows/preview.md +80 -137
  116. package/.agent/workflows/refactor.md +183 -153
  117. package/.agent/workflows/review-ai.md +129 -140
  118. package/.agent/workflows/review.md +116 -155
  119. package/.agent/workflows/session.md +94 -154
  120. package/.agent/workflows/status.md +79 -125
  121. package/.agent/workflows/strengthen-skills.md +139 -99
  122. package/.agent/workflows/swarm.md +179 -194
  123. package/.agent/workflows/test.md +211 -166
  124. package/.agent/workflows/tribunal-backend.md +113 -111
  125. package/.agent/workflows/tribunal-database.md +115 -132
  126. package/.agent/workflows/tribunal-frontend.md +118 -115
  127. package/.agent/workflows/tribunal-full.md +133 -136
  128. package/.agent/workflows/tribunal-mobile.md +119 -123
  129. package/.agent/workflows/tribunal-performance.md +133 -152
  130. package/.agent/workflows/ui-ux-pro-max.md +143 -171
  131. package/README.md +11 -15
  132. package/package.json +1 -1
  133. package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
  134. package/.agent/skills/game-development/2d-games/SKILL.md +0 -119
  135. package/.agent/skills/game-development/3d-games/SKILL.md +0 -135
  136. package/.agent/skills/game-development/SKILL.md +0 -236
  137. package/.agent/skills/game-development/game-art/SKILL.md +0 -185
  138. package/.agent/skills/game-development/game-audio/SKILL.md +0 -190
  139. package/.agent/skills/game-development/game-design/SKILL.md +0 -129
  140. package/.agent/skills/game-development/mobile-games/SKILL.md +0 -108
  141. package/.agent/skills/game-development/multiplayer/SKILL.md +0 -132
  142. package/.agent/skills/game-development/pc-games/SKILL.md +0 -144
  143. package/.agent/skills/game-development/vr-ar/SKILL.md +0 -123
  144. package/.agent/skills/game-development/web-games/SKILL.md +0 -150
@@ -1,212 +1,190 @@
1
- ---
2
- name: server-management
3
- description: Server management principles and decision-making. Process management, monitoring strategy, and scaling decisions. Teaches thinking, not commands.
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
- # Server Management Principles
11
-
12
- > A server you can't observe is a server you can't operate.
13
- > Monitoring is not optional it is how you find out about problems before your users do.
14
-
15
- ---
16
-
17
- ## Process Management
18
-
19
- Never run Node.js or Python processes directly in production with `node app.js`. Use a process manager.
20
-
21
- | Tool | Best For | Why |
22
- |---|---|---|
23
- | PM2 | Single-server Node.js | Auto-restart, log rotation, cluster mode |
24
- | systemd | Linux servers, any language | Native to most Linux distros, reliable |
25
- | Supervisor | Python, Ruby, any language | Simple config, battle-tested |
26
- | Docker (+restart policy) | Containerized apps | Portable, consistent across environments |
27
-
28
- **Core requirement:** If the process crashes, it restarts automatically. If it can't restart, you are alerted.
29
-
30
- ```bash
31
- # PM2 example stays running, auto-restarts, survives reboots
32
- pm2 start app.js --name "api" --instances max
33
- pm2 save
34
- pm2 startup # generates the command to run at boot
35
- ```
36
-
37
- ---
38
-
39
- ## What to Monitor
40
-
41
- The minimum viable monitoring stack:
42
-
43
- | Signal | What To Alert On |
44
- |---|---|
45
- | Process health | Process is not running |
46
- | Response time | P95 latency > SLA threshold |
47
- | Error rate | Error rate > 2x baseline |
48
- | Disk usage | > 80% full |
49
- | Memory | Growing without bound (memory leak) |
50
- | CPU | Sustained > 80% for more than 5 minutes |
51
-
52
- **Alert on symptoms, not just causes.** "Error rate spiked" is a better alert than "CPU is high" — users don't feel CPU, they feel slow responses and errors.
53
-
54
- ---
55
-
56
- ## Log Management
57
-
58
- Logs are useless without structure. Structured logs can be queried and aggregated.
59
-
60
- ```ts
61
- // ❌ Unstructured — hard to query
62
- console.log(`User ${userId} failed to login at ${new Date()}`);
63
-
64
- // Structured can be filtered, aggregated, alerted on
65
- logger.warn('login_failed', {
66
- userId,
67
- ip: req.ip,
68
- reason: 'invalid_password',
69
- timestamp: new Date().toISOString(),
70
- });
71
- ```
72
-
73
- **Log levels, used correctly:**
74
- - `ERROR` — something failed that requires attention
75
- - `WARN` something unexpected but non-fatal happened
76
- - `INFO` — key business events (user registered, payment processed)
77
- - `DEBUG` — useful for troubleshooting, never on in production by default
78
-
79
- **Never log:**
80
- - Passwords, tokens, or full credit card numbers
81
- - PII without a documented retention policy
82
- - Full request bodies on auth endpoints
83
-
84
- ---
85
-
86
- ## Scaling Decision Framework
87
-
88
- Before scaling, answer:
89
-
90
- **Is the bottleneck identified?**
91
- - Profile first. Is it CPU, memory, database, or network?
92
- - Scaling horizontally when the bottleneck is a single database query helps nothing.
93
-
94
- | Bottleneck | Scaling Approach |
95
- |---|---|
96
- | CPU-bound app logic | Horizontal scale (more instances) |
97
- | Memory limit | Vertical scale (more RAM per instance) |
98
- | I/O-bound (DB, external calls) | Connection pooling, caching, async patterns |
99
- | Database reads | Read replicas, query optimization, caching |
100
- | Database writes | Sharding, write queuing, schema redesign |
101
-
102
- **Cached responses don't need scaling.** Add caching before adding instances.
103
-
104
- ---
105
-
106
- ## Nginx Configuration Essentials
107
-
108
- ```nginx
109
- server {
110
- listen 80;
111
- server_name example.com;
112
-
113
- # Redirect HTTP → HTTPS
114
- return 301 https://$host$request_uri;
115
- }
116
-
117
- server {
118
- listen 443 ssl;
119
- server_name example.com;
120
-
121
- # Security headers
122
- add_header X-Frame-Options DENY;
123
- add_header X-Content-Type-Options nosniff;
124
- add_header Strict-Transport-Security "max-age=31536000" always;
125
-
126
- # Proxy to Node.js app
127
- location / {
128
- proxy_pass http://127.0.0.1:3000;
129
- proxy_set_header Host $host;
130
- proxy_set_header X-Real-IP $remote_addr;
131
- proxy_set_header X-Forwarded-Proto https;
132
- }
133
-
134
- # Serve static files directly (don't proxy to Node)
135
- location /static/ {
136
- root /var/www/myapp;
137
- expires 1y;
138
- add_header Cache-Control "public, immutable";
139
- }
140
- }
141
- ```
142
-
143
- ---
144
-
145
- ## Backup Strategy
146
-
147
- The 3-2-1 rule:
148
- - **3** copies of data
149
- - **2** on different storage media
150
- - **1** offsite (different data center, cloud region)
151
-
152
- Test restores on a schedule — a backup you've never restored is a backup you don't know works.
153
-
154
- ---
155
-
156
- ## Output Format
157
-
158
- When this skill produces a recommendation or design decision, structure your output as:
159
-
160
- ```
161
- ━━━ Server Management Recommendation ━━━━━━━━━━━━━━━━
162
- Decision: [what was chosen / proposed]
163
- Rationale: [why one concise line]
164
- Trade-offs: [what is consciously accepted]
165
- Next action: [concrete next step for the user]
166
- ─────────────────────────────────────────────────
167
- Pre-Flight: ✅ All checks passed
168
- or [blocking item that must be resolved first]
169
- ```
170
-
171
-
172
-
173
- ---
174
-
175
- ## 🤖 LLM-Specific Traps
176
-
177
- AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
178
-
179
- 1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
180
- 2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
181
- 3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
182
- 4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
183
- 5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
184
-
185
- ---
186
-
187
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
188
-
189
- **Slash command: `/review` or `/tribunal-full`**
190
- **Active reviewers: `logic-reviewer` · `security-auditor`**
191
-
192
- ### ❌ Forbidden AI Tropes
193
-
194
- 1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
195
- 2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
196
- 3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
197
-
198
- ### ✅ Pre-Flight Self-Audit
199
-
200
- Review these questions before confirming output:
201
- ```
202
- ✅ Did I rely ONLY on real, verified tools and methods?
203
- ✅ Is this solution appropriately scoped to the user's constraints?
204
- ✅ Did I handle potential failure modes and edge cases?
205
- ✅ Have I avoided generic boilerplate that doesn't add value?
206
- ```
207
-
208
- ### 🛑 Verification-Before-Completion (VBC) Protocol
209
-
210
- **CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
211
- - ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
212
- - ✅ **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.
1
+ ---
2
+ name: server-management
3
+ description: Production Linux server administration mastery. Systemd services, Nginx reverse proxy architecture, UFW firewalls, SSH key security, cron scheduling, log rotation, and server hardening. Use when configuring bare-metal, VPS instances, or reviewing deployment architecture.
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
+ # Server Management — Production Linux Mastery
11
+
12
+ > Never run a web server as root. Never expose raw ports securely.
13
+ > A naked Node/Python process dies silently. A systemd service acts as its immortal guardian.
14
+
15
+ ---
16
+
17
+ ## 1. Systemd Service Architecture (Process Guard)
18
+
19
+ Do not use `pm2`, `forever`, or custom `screen` sessions attached to SSH panels for server orchestration. Linux provides an enterprise-grade init system natively: systemd.
20
+
21
+ ```ini
22
+ # /etc/systemd/system/myapp.service
23
+
24
+ [Unit]
25
+ Description=My Application Node.js Server
26
+ Documentation=https://example.com/docs
27
+ After=network.target postgresql.service # Ensure DB and Network start first
28
+
29
+ [Service]
30
+ Type=simple
31
+ User=appuser # NEVER run as root
32
+ Group=appuser
33
+ WorkingDirectory=/var/www/myapp
34
+
35
+ # Explicitly declare environment limits and variables
36
+ Environment=NODE_ENV=production
37
+ Environment=PORT=3000
38
+ EnvironmentFile=/var/www/myapp/.env
39
+
40
+ # The execution target
41
+ ExecStart=/usr/bin/node /var/www/myapp/build/index.js
42
+
43
+ # Immortal behavior: Restart strictly on failure
44
+ Restart=on-failure
45
+ RestartSec=5
46
+
47
+ # Security Hardening
48
+ NoNewPrivileges=yes
49
+ PrivateTmp=yes
50
+ RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
51
+
52
+ [Install]
53
+ WantedBy=multi-user.target
54
+ ```
55
+
56
+ **Commands:**
57
+ `sudo systemctl daemon-reload`
58
+ `sudo systemctl enable myapp`
59
+ `sudo systemctl start myapp`
60
+ `journalctl -u myapp -f` (Follow logs seamlessly)
61
+
62
+ ---
63
+
64
+ ## 2. Nginx Reverse Proxy Architecture
65
+
66
+ You must shield your internal application framework (Node/Python/Ruby) behind Nginx. Nginx handles SSL termination, static file caching, and DDOS mitigation.
67
+
68
+ ```nginx
69
+ # /etc/nginx/sites-available/myapp.com
70
+
71
+ server {
72
+ listen 80;
73
+ server_name api.myapp.com;
74
+
75
+ # Force SSL Redirect
76
+ return 301 https://$host$request_uri;
77
+ }
78
+
79
+ server {
80
+ listen 443 ssl http2;
81
+ server_name api.myapp.com;
82
+
83
+ # SSL Certs (Let's Encrypt / Certbot)
84
+ ssl_certificate /etc/letsencrypt/live/api.myapp.com/fullchain.pem;
85
+ ssl_certificate_key /etc/letsencrypt/live/api.myapp.com/privkey.pem;
86
+
87
+ # Modern Security Headers
88
+ add_header Strict-Transport-Security "max-age=63072000" always;
89
+ add_header X-Content-Type-Options nosniff;
90
+ add_header X-Frame-Options DENY;
91
+
92
+ # GZIP Compression
93
+ gzip on;
94
+ gzip_types text/plain application/json;
95
+
96
+ location / {
97
+ # Proxy traffic to internal local process
98
+ proxy_pass http://127.0.0.1:3000;
99
+
100
+ # Forward original IP and Protocol for rate limiters
101
+ proxy_set_header Host $host;
102
+ proxy_set_header X-Real-IP $remote_addr;
103
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
104
+ proxy_set_header X-Forwarded-Proto $scheme;
105
+
106
+ # WebSocket support (Required for GraphQL subscriptions, TRPC, Socket.io)
107
+ proxy_http_version 1.1;
108
+ proxy_set_header Upgrade $http_upgrade;
109
+ proxy_set_header Connection "upgrade";
110
+ }
111
+ }
112
+ ```
113
+
114
+ ---
115
+
116
+ ## 3. Server Hardening Fundamentals
117
+
118
+ ### SSH Security (`/etc/ssh/sshd_config`)
119
+ ```bash
120
+ PermitRootLogin no # Kill direct root login attacks immediately
121
+ PasswordAuthentication no # Enforce SSH key-based login ONLY
122
+ Port 2022 # (Optional) Obscurity defense against automated script-kiddie scanners
123
+ ```
124
+
125
+ ### Uncomplicated Firewall (UFW)
126
+ A naked server with all ports open is a honeypot.
127
+ ```bash
128
+ sudo ufw default deny incoming
129
+ sudo ufw default allow outgoing
130
+ sudo ufw allow 22/tcp # Allow SSH
131
+ sudo ufw allow 80/tcp # Allow HTTP
132
+ sudo ufw allow 443/tcp # Allow HTTPS
133
+ sudo ufw enable
134
+ ```
135
+
136
+ ### Fail2Ban
137
+ Automatically bans IPs attempting brute force credential filling after 5 bad attempts.
138
+
139
+ ---
140
+
141
+ ## 4. Log Rotation (Prevent Disk Full Outages)
142
+
143
+ A server will inevitably crash when `/var/log` consumes 100% of the disk.
144
+
145
+ ```bash
146
+ # /etc/logrotate.d/myapp
147
+
148
+ /var/www/myapp/logs/*.log {
149
+ daily # Rotate every day
150
+ missingok # Ignore if file is missing
151
+ rotate 14 # Keep 14 days of history
152
+ compress # Gzip old logs
153
+ delaycompress # Don't compress the one created yesterday
154
+ notifempty # Do nothing if log is empty
155
+ copytruncate # Copy then clear (avoids disrupting Node's open file handles)
156
+ }
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 🤖 LLM-Specific Traps (Server Management)
162
+
163
+ 1. **PM2 Fallacy:** AI frequently defaults to `pm2 start app.js` for production deployments. Demand raw `systemd`. It ensures startup order (Wait for network) and unified journalctl logging.
164
+ 2. **Root Execution:** Suggesting `ExecStart=npm start` under the `User=root` directive. The application process should operate under a restricted `appuser` daemon tier.
165
+ 3. **Missing Proxy Headers:** AI writing basic Nginx configs but omitting `X-Forwarded-For`. This causes the internal App to log all requests as coming from "127.0.0.1", instantly breaking IP Rate limiters.
166
+ 4. **WebSocket Blocking:** Forgetting to pass `Upgrade` headers in Nginx proxy setups, breaking realtime web applications silently.
167
+ 5. **Naked Node Ports:** Instructing users to run `node index.js` on `port 80`. Never natively bind unprivileged web processes to port 80. Bind to 3000 locally and use reverse proxy routing.
168
+ 6. **Firewall Blindness:** Assuming Docker auto-secures ports. Executing `docker run -p 8080:80` on Ubuntu completely bypasses UFW restrictions through iptables hooks, exposing the database to the internet. Always bind `127.0.0.1:8080:80`.
169
+ 7. **Password SSH Prompts:** Creating automation scripts utilizing raw passwords (e.g., `sshpass`). Always assume ed25519 identity keyfiles for automated CI deployments.
170
+ 8. **Log Rotation Void:** Neglecting log rotation in custom bash script loops, guaranteeing a 100% disk usage outage 3 months later.
171
+ 9. **GZIP Assumption:** Forgetting to enable `gzip on` in Nginx resulting in 10MB JSON payloads saturating the virtual server network adapter.
172
+ 10. **In-place Nginx Modding:** Editing `/etc/nginx/nginx.conf` directly instead of writing symlinks between the `sites-available` and `sites-enabled` architecture.
173
+
174
+ ---
175
+
176
+ ## 🏛️ Tribunal Integration
177
+
178
+ ### ✅ Pre-Flight Self-Audit
179
+ ```
180
+ Are persistent services orchestrated securely via `systemd` (not PM2)?
181
+ Does the systemd service explicitly execute as a non-root `appuser`?
182
+ Is the internal application shielded by an Nginx/Caddy reverse proxy?
183
+ Does the reverse proxy explicitly forward realtime `Upgrade` (WebSocket) headers?
184
+ ✅ Does the reverse proxy forward IP integrity headers (`X-Forwarded-For`)?
185
+ ✅ Has SSH `PasswordAuthentication` been disabled defensively?
186
+ ✅ Is UFW configured to strictly deny all incoming non-essential ports?
187
+ If suggesting Docker, are database/internal ports scoped to `127.0.0.1:X:Y`?
188
+ ✅ Have manual application log files been mapped in `logrotate.d`?
189
+ Has `PermitRootLogin` been set to `no`?
190
+ ```
@@ -0,0 +1,206 @@
1
+ ---
2
+ name: shadcn-ui-expert
3
+ description: shadcn/ui mastery. Installation, customization via tailwind.config, component extraction, state management with Radix Primitives, theme variables (CSS custom properties), dark mode implementations, and overriding default designs. Use when building or modifying shadcn/ui components in React/Next.js projects.
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
+ # shadcn/ui Expert — Component Architecture Mastery
11
+
12
+ > shadcn/ui is NOT a component library. It is a collection of re-usable components that you copy and paste into your apps.
13
+ > You own the code. You own the styling. You own the accessibility.
14
+
15
+ ---
16
+
17
+ ## 1. Core Architecture
18
+
19
+ shadcn/ui leverages two layers:
20
+ 1. **Radix UI Primitives**: Headless, fully accessible functionality (Focus management, ARIA, Keyboard nav).
21
+ 2. **Tailwind CSS**: The styling layer mapped over the headless components.
22
+
23
+ ```typescript
24
+ // ❌ BAD: Re-inventing the wheel for accessibility
25
+ const Select = ({ options }) => {
26
+ const [open, setOpen] = useState(false)
27
+ return <div onClick={() => setOpen(!open)}>...</div> // Breaks keyboard/screen readers
28
+ }
29
+
30
+ // ✅ GOOD: Using shadcn (Radix under the hood)
31
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
32
+
33
+ export function MySelect() {
34
+ return (
35
+ <Select>
36
+ <SelectTrigger className="w-[180px]">
37
+ <SelectValue placeholder="Theme" />
38
+ </SelectTrigger>
39
+ <SelectContent>
40
+ <SelectItem value="light">Light</SelectItem>
41
+ <SelectItem value="dark">Dark</SelectItem>
42
+ </SelectContent>
43
+ </Select>
44
+ )
45
+ }
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 2. Component Modification (You Own The Code)
51
+
52
+ Do not treat `components/ui/*` as an immutable black box. You are *supposed* to modify them.
53
+
54
+ ### Adding Variants via `cva` (Class Variance Authority)
55
+
56
+ ```typescript
57
+ import { cva, type VariantProps } from "class-variance-authority"
58
+
59
+ // Adding a new "ghost-rounded" variant to the Button component
60
+ const buttonVariants = cva(
61
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors...",
62
+ {
63
+ variants: {
64
+ variant: {
65
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
66
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
67
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
68
+ // YOUR CUSTOM VARIANT:
69
+ "ghost-rounded": "bg-transparent hover:bg-accent hover:text-accent-foreground rounded-full px-6",
70
+ },
71
+ size: {
72
+ default: "h-9 px-4 py-2",
73
+ sm: "h-8 rounded-md px-3 text-xs",
74
+ lg: "h-10 rounded-md px-8",
75
+ icon: "h-9 w-9",
76
+ },
77
+ },
78
+ defaultVariants: {
79
+ variant: "default",
80
+ size: "default",
81
+ },
82
+ }
83
+ )
84
+ ```
85
+
86
+ ---
87
+
88
+ ## 3. Theming & Dark Mode (CSS Variables)
89
+
90
+ shadcn/ui manages themes explicitly through CSS custom properties (variables), not Tailwind config hardcoding.
91
+
92
+ ```css
93
+ /* app/globals.css */
94
+ @layer base {
95
+ :root {
96
+ --background: 0 0% 100%;
97
+ --foreground: 222.2 84% 4.9%;
98
+ --card: 0 0% 100%;
99
+ --card-foreground: 222.2 84% 4.9%;
100
+ --primary: 221.2 83.2% 53.3%;
101
+ --primary-foreground: 210 40% 98%;
102
+ /* ... */
103
+ --radius: 0.5rem;
104
+ }
105
+
106
+ .dark {
107
+ --background: 222.2 84% 4.9%;
108
+ --foreground: 210 40% 98%;
109
+ --card: 222.2 84% 4.9%;
110
+ --primary: 217.2 91.2% 59.8%;
111
+ /* ... */
112
+ }
113
+ }
114
+ ```
115
+
116
+ Implementation with Tailwind v4 CSS-first configuration:
117
+ ```css
118
+ /* Note how standard colors map directly to the CSS vars */
119
+ @theme {
120
+ --color-background: hsl(var(--background));
121
+ --color-foreground: hsl(var(--foreground));
122
+ --color-primary: hsl(var(--primary));
123
+ --color-primary-foreground: hsl(var(--primary-foreground));
124
+ --radius-lg: var(--radius);
125
+ --radius-md: calc(var(--radius) - 2px);
126
+ --radius-sm: calc(var(--radius) - 4px);
127
+ }
128
+ ```
129
+
130
+ ---
131
+
132
+ ## 4. Using the `cn` Utility
133
+
134
+ The `cn` utility combines `clsx` (conditional classes) and `tailwind-merge` (fixing class conflicts).
135
+
136
+ ```typescript
137
+ import { clsx, type ClassValue } from "clsx"
138
+ import { twMerge } from "tailwind-merge"
139
+
140
+ export function cn(...inputs: ClassValue[]) {
141
+ return twMerge(clsx(inputs))
142
+ }
143
+
144
+ // ❌ BAD: String concatenation breeds conflicts
145
+ // hover:bg-blue-500 will fail if className contains hover:bg-red-500 earlier
146
+ const className = `px-4 py-2 bg-blue-500 hover:bg-blue-600 ${props.className}`
147
+
148
+ // ✅ GOOD: cn resolves conflicts correctly
149
+ const className = cn("px-4 py-2 bg-blue-500 hover:bg-blue-600", props.className)
150
+ ```
151
+
152
+ ---
153
+
154
+ ## 5. Next.js App Router Integration
155
+
156
+ ### Modals / Dialogs inside Server Components
157
+ Radix primitives (Dialog, Select, etc.) utilize React context and side effects. They must be Client Components.
158
+
159
+ ```typescript
160
+ // ❌ BAD: Server Component trying to use a shadcn Dialog directly with state
161
+ export default function Page() {
162
+ const [open, setOpen] = useState(false); // ERROR
163
+ return <Dialog open={open}>...</Dialog>
164
+ }
165
+
166
+ // ✅ GOOD: Extract the interactive part to a Client Component
167
+ import { MyDialogComponent } from "./MyDialogComponent" // "use client" inside
168
+
169
+ export default async function Page() {
170
+ const data = await fetchDb(); // Server Component fetches data
171
+ return <MyDialogComponent data={data} /> // Passes data to interactive client component
172
+ }
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 🤖 LLM-Specific Traps (shadcn/ui)
178
+
179
+ 1. **Treating it like an NPM Package:** AI asks to run `npm install shadcn-ui`. It's `npx shadcn@latest add [component]`. Components live in your tree (`components/ui`), not in `node_modules`.
180
+ 2. **Missing the `cn` utility:** AI writes generic template literals for className overrides, guaranteeing Tailwind specificity conflicts. Always import and wrap overrides in `cn()`.
181
+ 3. **Hardcoding Colors:** AI writes `bg-blue-500` inside standard components. shadcn demands semantic variables: `bg-primary`, `bg-accent`, `text-muted-foreground`.
182
+ 4. **Server Component Conflicts:** AI inserts interactive shadcn components (Dialog, Tabs, Accordion) directly into Next.js Server Components without creating a `"use client"` wrapper boundary.
183
+ 5. **Radix Primitive Ignorance:** AI attempts to pass `onClick` or `onChange` to headless wrapper elements like `<Select>` instead of `<SelectValue>` or tracking state properly via the `onValueChange` prop of the root component.
184
+ 6. **Forgetting `asChild`:** When wrapping existing buttons or links in shadcn Triggers, AI forgets the `asChild` prop, resulting in invalid HTML (e.g., `<button><button>click</button></button>`).
185
+ 7. **Modifying `node_modules/@radix-ui`:** AI tries to fix Radix a11y bugs by editing node_modules. Modify your local wrappers in `components/ui`, never Radix internals.
186
+ 8. **Broken Form Integration:** AI tries to manually string together standard React state with shadcn inputs. You MUST use `<Form>`, `<FormField>`, `<FormItem>`, and `react-hook-form` logic for proper shadcn forms.
187
+ 9. **Tailwind Class Order:** AI doesn't understand that `tailwind-merge` resolves conflicts from left to right. Overriding classes must be passed at the *end* of the `cn()` arguments.
188
+ 10. **Theme Variable Format:** AI writes `--primary: #3b82f6`. shadcn/ui CSS custom properties are strictly HSL scalar values WITHOUT the `hsl()` wrapper inside the root definition: `--primary: 221.2 83.2% 53.3%;`.
189
+
190
+ ---
191
+
192
+ ## 🏛️ Tribunal Integration
193
+
194
+ ### ✅ Pre-Flight Self-Audit
195
+ ```
196
+ ✅ Are interactive shadcn components safely inside "use client" boundaries?
197
+ ✅ Are classes merged dynamically using the `cn()` utility?
198
+ ✅ Are colors utilizing standard semantic vars (`bg-primary`) rather than hardcoded colors?
199
+ ✅ Did I remember the `asChild` prop when wrapping links/buttons in Triggers?
200
+ ✅ Are forms correctly using `react-hook-form` via the `<Form>` and `<FormField>` components?
201
+ ✅ Are CSS theme root variables using raw HSL scalar values?
202
+ ✅ Am I modifying the local `components/ui/*` files if new variants are needed?
203
+ ✅ Have I respected Radix a11y primitives (not inventing my own onClick focus handling)?
204
+ ✅ Are component variants properly declared using `cva`?
205
+ ✅ Did I pass user-supplied `className` props at the END of the `cn()` function to allow overrides?
206
+ ```