tribunal-kit 1.0.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/.shared/ui-ux-pro-max/README.md +3 -3
- package/.agent/ARCHITECTURE.md +205 -10
- package/.agent/GEMINI.md +37 -7
- package/.agent/agents/accessibility-reviewer.md +134 -0
- package/.agent/agents/ai-code-reviewer.md +129 -0
- package/.agent/agents/frontend-specialist.md +3 -0
- package/.agent/agents/game-developer.md +21 -21
- package/.agent/agents/logic-reviewer.md +12 -0
- package/.agent/agents/mobile-reviewer.md +79 -0
- package/.agent/agents/orchestrator.md +56 -26
- package/.agent/agents/performance-reviewer.md +36 -0
- package/.agent/agents/supervisor-agent.md +156 -0
- package/.agent/agents/swarm-worker-contracts.md +166 -0
- package/.agent/agents/swarm-worker-registry.md +92 -0
- package/.agent/rules/GEMINI.md +134 -5
- package/.agent/scripts/bundle_analyzer.py +259 -0
- package/.agent/scripts/dependency_analyzer.py +247 -0
- package/.agent/scripts/lint_runner.py +188 -0
- package/.agent/scripts/patch_skills_meta.py +177 -0
- package/.agent/scripts/patch_skills_output.py +285 -0
- package/.agent/scripts/schema_validator.py +279 -0
- package/.agent/scripts/security_scan.py +224 -0
- package/.agent/scripts/session_manager.py +144 -3
- package/.agent/scripts/skill_integrator.py +234 -0
- package/.agent/scripts/strengthen_skills.py +220 -0
- package/.agent/scripts/swarm_dispatcher.py +317 -0
- package/.agent/scripts/test_runner.py +192 -0
- package/.agent/scripts/test_swarm_dispatcher.py +163 -0
- package/.agent/skills/agent-organizer/SKILL.md +132 -0
- package/.agent/skills/agentic-patterns/SKILL.md +335 -0
- package/.agent/skills/api-patterns/SKILL.md +226 -50
- package/.agent/skills/app-builder/SKILL.md +215 -52
- package/.agent/skills/architecture/SKILL.md +176 -31
- package/.agent/skills/bash-linux/SKILL.md +150 -134
- package/.agent/skills/behavioral-modes/SKILL.md +152 -160
- package/.agent/skills/brainstorming/SKILL.md +148 -101
- package/.agent/skills/brainstorming/dynamic-questioning.md +10 -0
- package/.agent/skills/clean-code/SKILL.md +139 -134
- package/.agent/skills/code-review-checklist/SKILL.md +177 -80
- package/.agent/skills/config-validator/SKILL.md +165 -0
- package/.agent/skills/csharp-developer/SKILL.md +107 -0
- package/.agent/skills/database-design/SKILL.md +252 -29
- package/.agent/skills/deployment-procedures/SKILL.md +122 -175
- package/.agent/skills/devops-engineer/SKILL.md +134 -0
- package/.agent/skills/devops-incident-responder/SKILL.md +98 -0
- package/.agent/skills/documentation-templates/SKILL.md +175 -121
- package/.agent/skills/dotnet-core-expert/SKILL.md +103 -0
- package/.agent/skills/edge-computing/SKILL.md +213 -0
- package/.agent/skills/frontend-design/SKILL.md +76 -0
- package/.agent/skills/frontend-design/color-system.md +18 -0
- package/.agent/skills/frontend-design/typography-system.md +18 -0
- package/.agent/skills/game-development/SKILL.md +69 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +158 -99
- package/.agent/skills/github-operations/SKILL.md +354 -0
- package/.agent/skills/i18n-localization/SKILL.md +158 -96
- package/.agent/skills/intelligent-routing/SKILL.md +89 -285
- package/.agent/skills/intelligent-routing/router-manifest.md +65 -0
- package/.agent/skills/lint-and-validate/SKILL.md +229 -27
- package/.agent/skills/llm-engineering/SKILL.md +258 -0
- package/.agent/skills/local-first/SKILL.md +203 -0
- package/.agent/skills/mcp-builder/SKILL.md +159 -111
- package/.agent/skills/mobile-design/SKILL.md +102 -282
- package/.agent/skills/nextjs-react-expert/SKILL.md +143 -227
- package/.agent/skills/nodejs-best-practices/SKILL.md +201 -254
- package/.agent/skills/observability/SKILL.md +285 -0
- package/.agent/skills/parallel-agents/SKILL.md +124 -118
- package/.agent/skills/performance-profiling/SKILL.md +143 -89
- package/.agent/skills/plan-writing/SKILL.md +133 -97
- package/.agent/skills/platform-engineer/SKILL.md +135 -0
- package/.agent/skills/powershell-windows/SKILL.md +167 -104
- package/.agent/skills/python-patterns/SKILL.md +149 -361
- package/.agent/skills/python-pro/SKILL.md +114 -0
- package/.agent/skills/react-specialist/SKILL.md +107 -0
- package/.agent/skills/readme-builder/SKILL.md +270 -0
- package/.agent/skills/realtime-patterns/SKILL.md +296 -0
- package/.agent/skills/red-team-tactics/SKILL.md +136 -134
- package/.agent/skills/rust-pro/SKILL.md +237 -173
- package/.agent/skills/seo-fundamentals/SKILL.md +134 -82
- package/.agent/skills/server-management/SKILL.md +155 -104
- package/.agent/skills/sql-pro/SKILL.md +104 -0
- package/.agent/skills/systematic-debugging/SKILL.md +156 -79
- package/.agent/skills/tailwind-patterns/SKILL.md +163 -205
- package/.agent/skills/tdd-workflow/SKILL.md +148 -88
- package/.agent/skills/test-result-analyzer/SKILL.md +299 -0
- package/.agent/skills/testing-patterns/SKILL.md +141 -114
- package/.agent/skills/trend-researcher/SKILL.md +228 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +107 -0
- package/.agent/skills/ui-ux-researcher/SKILL.md +234 -0
- package/.agent/skills/vue-expert/SKILL.md +118 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +228 -188
- package/.agent/skills/web-design-guidelines/SKILL.md +148 -33
- package/.agent/skills/webapp-testing/SKILL.md +171 -122
- package/.agent/skills/whimsy-injector/SKILL.md +349 -0
- package/.agent/skills/workflow-optimizer/SKILL.md +219 -0
- package/.agent/workflows/api-tester.md +279 -0
- package/.agent/workflows/audit.md +168 -0
- package/.agent/workflows/brainstorm.md +65 -19
- package/.agent/workflows/changelog.md +144 -0
- package/.agent/workflows/create.md +67 -14
- package/.agent/workflows/debug.md +122 -30
- package/.agent/workflows/deploy.md +82 -31
- package/.agent/workflows/enhance.md +59 -27
- package/.agent/workflows/fix.md +143 -0
- package/.agent/workflows/generate.md +84 -20
- package/.agent/workflows/migrate.md +163 -0
- package/.agent/workflows/orchestrate.md +66 -17
- package/.agent/workflows/performance-benchmarker.md +305 -0
- package/.agent/workflows/plan.md +76 -33
- package/.agent/workflows/preview.md +73 -17
- package/.agent/workflows/refactor.md +153 -0
- package/.agent/workflows/review-ai.md +140 -0
- package/.agent/workflows/review.md +83 -16
- package/.agent/workflows/session.md +154 -0
- package/.agent/workflows/status.md +74 -18
- package/.agent/workflows/strengthen-skills.md +99 -0
- package/.agent/workflows/swarm.md +194 -0
- package/.agent/workflows/test.md +80 -31
- package/.agent/workflows/tribunal-backend.md +55 -13
- package/.agent/workflows/tribunal-database.md +62 -18
- package/.agent/workflows/tribunal-frontend.md +58 -12
- package/.agent/workflows/tribunal-full.md +70 -11
- package/.agent/workflows/tribunal-mobile.md +123 -0
- package/.agent/workflows/tribunal-performance.md +152 -0
- package/.agent/workflows/ui-ux-pro-max.md +100 -82
- package/README.md +117 -62
- package/bin/tribunal-kit.js +542 -288
- package/package.json +10 -6
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: realtime-patterns
|
|
3
|
+
description: Real-time and collaborative application patterns. WebSockets, Server-Sent Events for AI streaming, CRDTs for conflict-free collaboration, presence, and sync engines. Use when building live collaboration, AI streaming UIs, live dashboards, or multiplayer features.
|
|
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
|
+
# Real-Time Patterns
|
|
11
|
+
|
|
12
|
+
> The hardest part of real-time systems is not the latency — it's the concurrent state.
|
|
13
|
+
> Two users editing the same document at the same millisecond must both win.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Transport Selection
|
|
18
|
+
|
|
19
|
+
Choose the transport based on what the data flow looks like:
|
|
20
|
+
|
|
21
|
+
| Transport | Direction | Best For | Avoid When |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| **WebSocket** | Bidirectional | Chat, multiplayer, collaboration | Simple server push |
|
|
24
|
+
| **SSE (Server-Sent Events)** | Server → client only | AI streaming, dashboards, notifications | Client needs to send data |
|
|
25
|
+
| **WebRTC** | Peer-to-peer | Video/audio, P2P file transfer | Server coordination needed |
|
|
26
|
+
| **HTTP Polling** | Client pull | Low-frequency updates, fallback | > 1 update per second |
|
|
27
|
+
| **HTTP Streaming** | Server → client | Large response streaming, AI output | Need bidirectionality |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## WebSocket Patterns
|
|
32
|
+
|
|
33
|
+
### Connection Lifecycle
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
class WebSocketManager {
|
|
37
|
+
private ws: WebSocket | null = null;
|
|
38
|
+
private reconnectDelay = 1000;
|
|
39
|
+
private maxReconnectDelay = 30000;
|
|
40
|
+
|
|
41
|
+
connect(url: string) {
|
|
42
|
+
this.ws = new WebSocket(url);
|
|
43
|
+
|
|
44
|
+
this.ws.onopen = () => {
|
|
45
|
+
this.reconnectDelay = 1000; // Reset on successful connect
|
|
46
|
+
this.authenticate();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
this.ws.onclose = (event) => {
|
|
50
|
+
if (!event.wasClean) {
|
|
51
|
+
// Exponential backoff reconnect — never hammer the server
|
|
52
|
+
setTimeout(() => this.connect(url), this.reconnectDelay);
|
|
53
|
+
this.reconnectDelay = Math.min(this.reconnectDelay * 2, this.maxReconnectDelay);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this.ws.onerror = (err) => {
|
|
58
|
+
console.error('WebSocket error:', err);
|
|
59
|
+
// onclose fires after onerror — let it handle reconnect
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private authenticate() {
|
|
64
|
+
// ✅ Always authenticate AFTER connection — never trust URL params for auth
|
|
65
|
+
this.ws!.send(JSON.stringify({
|
|
66
|
+
type: 'auth',
|
|
67
|
+
token: getAccessToken(),
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Backpressure
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// ❌ Unbounded send — crashes if network is slow
|
|
77
|
+
for (const item of hugeArray) {
|
|
78
|
+
ws.send(JSON.stringify(item)); // Buffers infinitely if slow
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ✅ Check bufferedAmount before sending
|
|
82
|
+
function sendWhenReady(ws: WebSocket, data: string) {
|
|
83
|
+
if (ws.bufferedAmount > 65536) { // 64KB threshold
|
|
84
|
+
setTimeout(() => sendWhenReady(ws, data), 50);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
ws.send(data);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## SSE for AI Streaming
|
|
94
|
+
|
|
95
|
+
The right transport for one-directional AI text streaming:
|
|
96
|
+
|
|
97
|
+
### Server (Node.js / Hono)
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
app.get('/api/chat/stream', async (c) => {
|
|
101
|
+
const { message } = c.req.query();
|
|
102
|
+
|
|
103
|
+
// Set SSE headers
|
|
104
|
+
c.res.headers.set('Content-Type', 'text/event-stream');
|
|
105
|
+
c.res.headers.set('Cache-Control', 'no-cache');
|
|
106
|
+
c.res.headers.set('Connection', 'keep-alive');
|
|
107
|
+
|
|
108
|
+
const stream = await openai.chat.completions.create({
|
|
109
|
+
model: 'gpt-4o',
|
|
110
|
+
messages: [{ role: 'user', content: message }],
|
|
111
|
+
stream: true,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const encoder = new TextEncoder();
|
|
115
|
+
const readable = new ReadableStream({
|
|
116
|
+
async start(controller) {
|
|
117
|
+
for await (const chunk of stream) {
|
|
118
|
+
const text = chunk.choices[0]?.delta?.content ?? '';
|
|
119
|
+
if (text) {
|
|
120
|
+
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ text })}\n\n`));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
controller.enqueue(encoder.encode('data: [DONE]\n\n'));
|
|
124
|
+
controller.close();
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return new Response(readable);
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Client (React)
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
function useAIStream(prompt: string) {
|
|
136
|
+
const [text, setText] = useState('');
|
|
137
|
+
const [done, setDone] = useState(false);
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const source = new EventSource(`/api/chat/stream?message=${encodeURIComponent(prompt)}`);
|
|
141
|
+
|
|
142
|
+
source.onmessage = (e) => {
|
|
143
|
+
if (e.data === '[DONE]') {
|
|
144
|
+
setDone(true);
|
|
145
|
+
source.close();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const { text: chunk } = JSON.parse(e.data);
|
|
149
|
+
setText(prev => prev + chunk);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
source.onerror = () => source.close();
|
|
153
|
+
|
|
154
|
+
return () => source.close(); // Cleanup on unmount
|
|
155
|
+
}, [prompt]);
|
|
156
|
+
|
|
157
|
+
return { text, done };
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## CRDTs: Conflict-Free Collaboration
|
|
164
|
+
|
|
165
|
+
CRDTs (Conflict-free Replicated Data Types) guarantee that concurrent edits from multiple users always merge to the same result, regardless of order or network conditions.
|
|
166
|
+
|
|
167
|
+
### When to Use CRDTs vs Last-Write-Wins
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
Last-Write-Wins (LWW):
|
|
171
|
+
✅ Settings, preferences, single-value fields
|
|
172
|
+
❌ Text editing — loses concurrent edits
|
|
173
|
+
|
|
174
|
+
Operational Transform (OT):
|
|
175
|
+
✅ Google Docs-style (centralized server required)
|
|
176
|
+
❌ Peer-to-peer, offline-first (server is the truth arbiter)
|
|
177
|
+
|
|
178
|
+
CRDTs:
|
|
179
|
+
✅ Collaborative text (Yjs), presence, shared lists
|
|
180
|
+
✅ Offline-first, peer-to-peer
|
|
181
|
+
✅ No central server required for convergence
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Yjs — The Standard CRDT Library
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import * as Y from 'yjs';
|
|
188
|
+
import { WebsocketProvider } from 'y-websocket';
|
|
189
|
+
|
|
190
|
+
// Create a shared document
|
|
191
|
+
const doc = new Y.Doc();
|
|
192
|
+
|
|
193
|
+
// Connect to sync server — providers handle conflict resolution
|
|
194
|
+
const provider = new WebsocketProvider('wss://your-server.com', 'room-id', doc);
|
|
195
|
+
|
|
196
|
+
// Y.Text — CRDT for collaborative text editing
|
|
197
|
+
const yText = doc.getText('document');
|
|
198
|
+
|
|
199
|
+
// Bind to a rich text editor (Tiptap, ProseMirror, CodeMirror)
|
|
200
|
+
const editor = new Editor({
|
|
201
|
+
extensions: [Collaboration.configure({ document: doc })],
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Y.Map — CRDT for key-value shared state
|
|
205
|
+
const awareness = new Y.Map();
|
|
206
|
+
awareness.set('cursor', { userId, position });
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Presence Patterns
|
|
212
|
+
|
|
213
|
+
Presence = "who is online and what are they doing":
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
// Server: track presence via WebSocket lifecycle
|
|
217
|
+
const presence = new Map<string, { userId: string; cursor: Position }>();
|
|
218
|
+
|
|
219
|
+
wss.on('connection', (ws, req) => {
|
|
220
|
+
const userId = authenticate(req);
|
|
221
|
+
|
|
222
|
+
ws.on('message', (data) => {
|
|
223
|
+
const msg = JSON.parse(data.toString());
|
|
224
|
+
if (msg.type === 'cursor') {
|
|
225
|
+
presence.set(userId, { userId, cursor: msg.position });
|
|
226
|
+
broadcast({ type: 'presence', users: [...presence.values()] });
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
ws.on('close', () => {
|
|
231
|
+
presence.delete(userId);
|
|
232
|
+
broadcast({ type: 'presence', users: [...presence.values()] });
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Sync Engine Selection
|
|
240
|
+
|
|
241
|
+
| Engine | Model | Best For |
|
|
242
|
+
|---|---|---|
|
|
243
|
+
| **PartyKit** | WebSocket-native, Durable Objects | Multiplayer apps, AI + realtime |
|
|
244
|
+
| **Liveblocks** | Managed CRDT + presence | Collaborative SaaS (Figma-style) |
|
|
245
|
+
| **Supabase Realtime** | PostgreSQL change streams | Postgres-centric apps |
|
|
246
|
+
| **ElectricSQL** | Local-first sync from Postgres | Offline-first apps |
|
|
247
|
+
| **Replicache** | Client-side mutations + sync | Highly interactive, offline-capable |
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Output Format
|
|
252
|
+
|
|
253
|
+
When this skill produces or reviews code, structure your output as follows:
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
━━━ Realtime Patterns Report ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
257
|
+
Skill: Realtime Patterns
|
|
258
|
+
Language: [detected language / framework]
|
|
259
|
+
Scope: [N files · N functions]
|
|
260
|
+
─────────────────────────────────────────────────
|
|
261
|
+
✅ Passed: [checks that passed, or "All clean"]
|
|
262
|
+
⚠️ Warnings: [non-blocking issues, or "None"]
|
|
263
|
+
❌ Blocked: [blocking issues requiring fix, or "None"]
|
|
264
|
+
─────────────────────────────────────────────────
|
|
265
|
+
VBC status: PENDING → VERIFIED
|
|
266
|
+
Evidence: [test output / lint pass / compile success]
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**VBC (Verification-Before-Completion) is mandatory.**
|
|
270
|
+
Do not mark status as VERIFIED until concrete terminal evidence is provided.
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
276
|
+
|
|
277
|
+
**Slash command: `/tribunal-backend`**
|
|
278
|
+
**Active reviewers: `logic` · `security` · `performance`**
|
|
279
|
+
|
|
280
|
+
### ❌ Forbidden AI Tropes in Real-Time Engineering
|
|
281
|
+
|
|
282
|
+
1. **Auth in URL params** — `ws://server.com?token=abc123` — tokens in URLs appear in logs and browser history. Authenticate via first message after handshake.
|
|
283
|
+
2. **No reconnect logic** — all WebSocket connections will drop. No reconnect = broken app on any network hiccup.
|
|
284
|
+
3. **Unbounded broadcast** — `wss.clients.forEach(ws => ws.send(data))` with no grouping = O(n) for every event.
|
|
285
|
+
4. **Polling instead of streaming** — `setInterval(() => fetch('/api/ai-status'), 500)` for AI responses = wasteful; use SSE.
|
|
286
|
+
5. **No backpressure handling** — sending data faster than the client can process = WebSocket buffer OOM.
|
|
287
|
+
|
|
288
|
+
### ✅ Pre-Flight Self-Audit
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
✅ Are WebSocket connections authenticated via first message, not URL params?
|
|
292
|
+
✅ Is there exponential backoff reconnect logic on unexpected disconnect?
|
|
293
|
+
✅ Are broadcasts scoped to rooms/channels — not sent to all connected clients?
|
|
294
|
+
✅ Is backpressure handled (bufferedAmount check before send)?
|
|
295
|
+
✅ Is SSE used for one-directional AI streaming instead of WebSocket?
|
|
296
|
+
```
|
|
@@ -1,199 +1,201 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: red-team-tactics
|
|
3
3
|
description: Red team tactics principles based on MITRE ATT&CK. Attack phases, detection evasion, reporting.
|
|
4
|
-
allowed-tools: Read, Glob, Grep
|
|
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
|
|
5
8
|
---
|
|
6
9
|
|
|
7
|
-
# Red Team
|
|
10
|
+
# Red Team & Penetration Testing Principles
|
|
8
11
|
|
|
9
|
-
>
|
|
12
|
+
> A red team engagement is a controlled attack.
|
|
13
|
+
> The goal is to find what a real attacker would find — before they do.
|
|
14
|
+
|
|
15
|
+
⚠️ **These techniques are for authorized security testing only. Unauthorized use is illegal.**
|
|
10
16
|
|
|
11
17
|
---
|
|
12
18
|
|
|
13
|
-
##
|
|
19
|
+
## Engagement Scope First
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
Before any testing activity:
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
LATERAL MOVEMENT → COLLECTION → C2 → EXFILTRATION → IMPACT
|
|
23
|
-
```
|
|
23
|
+
1. **Written authorization** — who authorized this engagement and in what scope?
|
|
24
|
+
2. **Scope definition** — which systems, IPs, domains, time windows are in scope?
|
|
25
|
+
3. **Rules of engagement** — what is prohibited? (production data access, social engineering of specific roles, DDoS)
|
|
26
|
+
4. **Emergency contact** — who do you call if you discover a critical live breach mid-engagement?
|
|
27
|
+
5. **Deconfliction** — does the blue team know an engagement is running, or is it blind?
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
| Phase | Objective |
|
|
28
|
-
|-------|-----------|
|
|
29
|
-
| **Recon** | Map attack surface |
|
|
30
|
-
| **Initial Access** | Get first foothold |
|
|
31
|
-
| **Execution** | Run code on target |
|
|
32
|
-
| **Persistence** | Survive reboots |
|
|
33
|
-
| **Privilege Escalation** | Get admin/root |
|
|
34
|
-
| **Defense Evasion** | Avoid detection |
|
|
35
|
-
| **Credential Access** | Harvest credentials |
|
|
36
|
-
| **Discovery** | Map internal network |
|
|
37
|
-
| **Lateral Movement** | Spread to other systems |
|
|
38
|
-
| **Collection** | Gather target data |
|
|
39
|
-
| **C2** | Maintain command channel |
|
|
40
|
-
| **Exfiltration** | Extract data |
|
|
29
|
+
No authorization = no testing.
|
|
41
30
|
|
|
42
31
|
---
|
|
43
32
|
|
|
44
|
-
##
|
|
33
|
+
## Attack Phases (Based on MITRE ATT&CK)
|
|
45
34
|
|
|
46
|
-
###
|
|
35
|
+
### 1. Reconnaissance
|
|
36
|
+
Passive and active information gathering before touching the target.
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| **Active** | Direct contact, more detection risk |
|
|
38
|
+
**Passive (no target contact):**
|
|
39
|
+
- DNS lookup: `nslookup`, `dig`, certificate transparency logs
|
|
40
|
+
- OSINT: LinkedIn for employee names/roles, GitHub for leaked configs, Shodan for exposed infrastructure
|
|
52
41
|
|
|
53
|
-
|
|
42
|
+
**Active (target is contacted):**
|
|
43
|
+
- Port scanning: `nmap -sV -sC <target>`
|
|
44
|
+
- Web tech detection: `whatweb`, `wappalyzer`
|
|
45
|
+
- Subdomain enumeration: `amass`, `subfinder`
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
| Technology stack | Attack vector selection |
|
|
58
|
-
| Employee info | Social engineering |
|
|
59
|
-
| Network ranges | Scanning scope |
|
|
60
|
-
| Third parties | Supply chain attack |
|
|
47
|
+
### 2. Initial Access
|
|
48
|
+
How does an attacker get their first foothold?
|
|
61
49
|
|
|
62
|
-
|
|
50
|
+
Common vectors:
|
|
51
|
+
- Phishing (credential harvest or malicious attachment)
|
|
52
|
+
- Exposed admin interfaces with default or weak credentials
|
|
53
|
+
- Publicly exposed vulnerable services (`searchsploit`, `nuclei`)
|
|
54
|
+
- Supply chain compromise (malicious npm package, CI/CD injection)
|
|
63
55
|
|
|
64
|
-
|
|
56
|
+
### 3. Persistence
|
|
57
|
+
Maintaining access after initial compromise:
|
|
65
58
|
|
|
66
|
-
|
|
59
|
+
- Scheduled tasks / cron jobs
|
|
60
|
+
- Web shells on compromised web servers
|
|
61
|
+
- New user accounts with admin rights
|
|
62
|
+
- SSH authorized_keys injection
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| **Phishing** | Human target, email access |
|
|
71
|
-
| **Public exploits** | Vulnerable services exposed |
|
|
72
|
-
| **Valid credentials** | Leaked or cracked |
|
|
73
|
-
| **Supply chain** | Third-party access |
|
|
64
|
+
### 4. Lateral Movement
|
|
65
|
+
Moving from initial foothold to higher-value targets:
|
|
74
66
|
|
|
75
|
-
|
|
67
|
+
- Pass-the-hash / pass-the-ticket (Active Directory)
|
|
68
|
+
- SSH key reuse across hosts
|
|
69
|
+
- Credential reuse (if one service is compromised, others sharing the password are vulnerable)
|
|
70
|
+
- Internal network scanning to map new targets
|
|
76
71
|
|
|
77
|
-
|
|
72
|
+
### 5. Exfiltration
|
|
73
|
+
Getting data out without triggering alerts:
|
|
78
74
|
|
|
79
|
-
|
|
75
|
+
- Small, slow transfers to blend with normal traffic
|
|
76
|
+
- Staging data in cloud storage linked to attacker-controlled accounts
|
|
77
|
+
- DNS exfiltration (for heavily monitored networks)
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|-------|-------------|
|
|
83
|
-
| Unquoted service paths | Write to path |
|
|
84
|
-
| Weak service permissions | Modify service |
|
|
85
|
-
| Token privileges | Abuse SeDebug, etc. |
|
|
86
|
-
| Stored credentials | Harvest |
|
|
79
|
+
---
|
|
87
80
|
|
|
88
|
-
|
|
81
|
+
## Common Vulnerability Targets
|
|
89
82
|
|
|
90
|
-
|
|
|
91
|
-
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
83
|
+
| Target | What to Test |
|
|
84
|
+
|---|---|
|
|
85
|
+
| Web applications | OWASP Top 10, auth bypass, IDOR, SSRF |
|
|
86
|
+
| APIs | Object-level authorization, mass assignment, rate limiting |
|
|
87
|
+
| Authentication | Brute force protection, token entropy, password reset flow |
|
|
88
|
+
| Secrets | Exposed env files, git history, CI/CD environment variables |
|
|
89
|
+
| Third-party integrations | Webhook validation, OAuth redirect URI validation |
|
|
90
|
+
| Infrastructure | Open S3 buckets, exposed admin ports, default credentials |
|
|
96
91
|
|
|
97
92
|
---
|
|
98
93
|
|
|
99
|
-
##
|
|
94
|
+
## Detection Evasion (for Authorized Testing)
|
|
100
95
|
|
|
101
|
-
|
|
96
|
+
When testing detection capabilities:
|
|
102
97
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
| Timestomping | Hide file modifications |
|
|
108
|
-
| Log clearing | Remove evidence |
|
|
98
|
+
- Slow scan rates to stay under IDS thresholds
|
|
99
|
+
- Use legitimate user agents and headers
|
|
100
|
+
- Blend with normal traffic patterns
|
|
101
|
+
- Test from IP ranges the organization wouldn't expect
|
|
109
102
|
|
|
110
|
-
|
|
103
|
+
---
|
|
111
104
|
|
|
112
|
-
|
|
113
|
-
- Mimic legitimate traffic patterns
|
|
114
|
-
- Use encrypted channels
|
|
115
|
-
- Blend with normal behavior
|
|
105
|
+
## Reporting Format
|
|
116
106
|
|
|
117
|
-
|
|
107
|
+
```markdown
|
|
108
|
+
# Red Team Report: [Engagement Name]
|
|
118
109
|
|
|
119
|
-
##
|
|
110
|
+
## Executive Summary
|
|
111
|
+
[2–3 sentences: what was tested, biggest risk found, business impact]
|
|
120
112
|
|
|
121
|
-
|
|
113
|
+
## Scope
|
|
114
|
+
[Systems tested, date range, authorization reference]
|
|
122
115
|
|
|
123
|
-
|
|
124
|
-
|------|-----|
|
|
125
|
-
| Password | Standard auth |
|
|
126
|
-
| Hash | Pass-the-hash |
|
|
127
|
-
| Ticket | Pass-the-ticket |
|
|
128
|
-
| Certificate | Certificate auth |
|
|
116
|
+
## Critical Findings
|
|
129
117
|
|
|
130
|
-
###
|
|
118
|
+
### CRIT-01: [Title]
|
|
119
|
+
**Risk:** Critical
|
|
120
|
+
**CVSS:** 9.8
|
|
121
|
+
**Description:** [What the vulnerability is]
|
|
122
|
+
**Evidence:** [Screenshot, payload, response]
|
|
123
|
+
**Impact:** [What an attacker could do]
|
|
124
|
+
**Remediation:** [Specific fix with code or config example]
|
|
131
125
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
- Exploitation of internal services
|
|
126
|
+
## Attack Narrative
|
|
127
|
+
[Chronological story of the full attack path from initial access to objective]
|
|
135
128
|
|
|
136
|
-
|
|
129
|
+
## Remediation Priority
|
|
130
|
+
| Finding | Severity | Fix By |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
```
|
|
137
133
|
|
|
138
|
-
|
|
134
|
+
---
|
|
139
135
|
|
|
140
|
-
|
|
136
|
+
## Ethical Boundaries
|
|
141
137
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
| DCSync | Domain credentials |
|
|
147
|
-
| Golden Ticket | Persistent domain access |
|
|
138
|
+
- Stop immediately if you discover evidence of an active breach by a real attacker — report it, don't continue testing
|
|
139
|
+
- Don't access, copy, or delete real user data even if you can
|
|
140
|
+
- Document everything — every command run, every finding noted
|
|
141
|
+
- Brief the client team before leaving — no surprises in the report
|
|
148
142
|
|
|
149
143
|
---
|
|
150
144
|
|
|
151
|
-
##
|
|
145
|
+
## Output Format
|
|
152
146
|
|
|
153
|
-
|
|
147
|
+
When this skill produces a recommendation or design decision, structure your output as:
|
|
154
148
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
```
|
|
150
|
+
━━━ Red Team Tactics Recommendation ━━━━━━━━━━━━━━━━
|
|
151
|
+
Decision: [what was chosen / proposed]
|
|
152
|
+
Rationale: [why — one concise line]
|
|
153
|
+
Trade-offs: [what is consciously accepted]
|
|
154
|
+
Next action: [concrete next step for the user]
|
|
155
|
+
─────────────────────────────────────────────────
|
|
156
|
+
Pre-Flight: ✅ All checks passed
|
|
157
|
+
or ❌ [blocking item that must be resolved first]
|
|
158
|
+
```
|
|
160
159
|
|
|
161
|
-
### Detection Gaps
|
|
162
160
|
|
|
163
|
-
For each successful technique:
|
|
164
|
-
- What should have detected it?
|
|
165
|
-
- Why didn't detection work?
|
|
166
|
-
- How to improve detection
|
|
167
161
|
|
|
168
162
|
---
|
|
169
163
|
|
|
170
|
-
##
|
|
164
|
+
## 🤖 LLM-Specific Traps
|
|
171
165
|
|
|
172
|
-
|
|
166
|
+
AI coding assistants often fall into specific bad habits when dealing with this domain. These are strictly forbidden:
|
|
173
167
|
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
1. **Over-engineering:** Proposing complex abstractions or distributed systems when a simpler approach suffices.
|
|
169
|
+
2. **Hallucinated Libraries/Methods:** Using non-existent methods or packages. Always `// VERIFY` or check `package.json` / `requirements.txt`.
|
|
170
|
+
3. **Skipping Edge Cases:** Writing the "happy path" and ignoring error handling, timeouts, or data validation.
|
|
171
|
+
4. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
172
|
+
5. **Silent Degradation:** Catching and suppressing errors without logging or re-raising.
|
|
178
173
|
|
|
179
|
-
|
|
174
|
+
---
|
|
180
175
|
|
|
181
|
-
|
|
182
|
-
- Cause denial of service (unless scoped)
|
|
183
|
-
- Access beyond proof of concept
|
|
184
|
-
- Retain sensitive data
|
|
176
|
+
## 🏛️ Tribunal Integration (Anti-Hallucination)
|
|
185
177
|
|
|
186
|
-
|
|
178
|
+
**Slash command: `/review` or `/tribunal-full`**
|
|
179
|
+
**Active reviewers: `logic-reviewer` · `security-auditor`**
|
|
187
180
|
|
|
188
|
-
|
|
181
|
+
### ❌ Forbidden AI Tropes
|
|
189
182
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
| Cause damage | Minimize impact |
|
|
194
|
-
| Skip reporting | Document everything |
|
|
195
|
-
| Ignore scope | Stay within boundaries |
|
|
183
|
+
1. **Blind Assumptions:** Never make an assumption without documenting it clearly with `// VERIFY: [reason]`.
|
|
184
|
+
2. **Silent Degradation:** Catching and suppressing errors without logging or handling.
|
|
185
|
+
3. **Context Amnesia:** Forgetting the user's constraints and offering generic advice instead of tailored solutions.
|
|
196
186
|
|
|
197
|
-
|
|
187
|
+
### ✅ Pre-Flight Self-Audit
|
|
188
|
+
|
|
189
|
+
Review these questions before confirming output:
|
|
190
|
+
```
|
|
191
|
+
✅ Did I rely ONLY on real, verified tools and methods?
|
|
192
|
+
✅ Is this solution appropriately scoped to the user's constraints?
|
|
193
|
+
✅ Did I handle potential failure modes and edge cases?
|
|
194
|
+
✅ Have I avoided generic boilerplate that doesn't add value?
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 🛑 Verification-Before-Completion (VBC) Protocol
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
200
|
+
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
201
|
+
- ✅ **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.
|