@esreekarreddy/ai-prompts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +361 -0
- package/chains/_index.md +33 -0
- package/chains/bug-fix.md +222 -0
- package/chains/new-feature.md +216 -0
- package/chains/production-launch.md +291 -0
- package/chains/refactor.md +210 -0
- package/chains/security-hardening.md +242 -0
- package/contexts/guides/api-design.md +229 -0
- package/contexts/guides/error-handling.md +219 -0
- package/contexts/patterns/agentic-coding.md +368 -0
- package/contexts/patterns/mcp-server-patterns.md +267 -0
- package/contexts/patterns/repository-pattern.md +163 -0
- package/contexts/patterns/service-layer.md +185 -0
- package/contexts/stacks/fastapi.md +187 -0
- package/contexts/stacks/nextjs-14.md +149 -0
- package/contexts/stacks/prisma.md +228 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +284 -0
- package/dist/index.js.map +1 -0
- package/examples/architecture-docs/sample-architecture.md +270 -0
- package/examples/code-reviews/sample-review.md +232 -0
- package/examples/prds/sample-prd.md +179 -0
- package/instructions/_index.md +57 -0
- package/instructions/personas/code-reviewer.md +83 -0
- package/instructions/personas/devops-engineer.md +90 -0
- package/instructions/personas/security-expert.md +69 -0
- package/instructions/personas/senior-engineer.md +243 -0
- package/instructions/personas/ux-engineer.md +88 -0
- package/instructions/standards/fastapi.md +241 -0
- package/instructions/standards/go.md +427 -0
- package/instructions/standards/nextjs.md +350 -0
- package/instructions/standards/nodejs.md +284 -0
- package/instructions/standards/python.md +245 -0
- package/instructions/standards/react.md +227 -0
- package/instructions/standards/rust.md +318 -0
- package/instructions/standards/typescript-react.md +822 -0
- package/instructions/standards/typescript.md +294 -0
- package/instructions/workflows/feature-development.md +222 -0
- package/instructions/workflows/incident-response.md +192 -0
- package/instructions/workflows/pr-review.md +149 -0
- package/instructions/workflows/tdd.md +160 -0
- package/package.json +84 -0
- package/prompts/_index.md +70 -0
- package/prompts/agentic/agentic-loop.md +83 -0
- package/prompts/agentic/context-manager.md +37 -0
- package/prompts/agentic/test-driven-fix.md +41 -0
- package/prompts/analysis/deep-debugger.md +488 -0
- package/prompts/design/design-system-extractor.md +147 -0
- package/prompts/development/code-cleaner.md +119 -0
- package/prompts/development/debugger.md +64 -0
- package/prompts/development/tech-debt-audit.md +88 -0
- package/prompts/planning/architecture-analyzer.md +72 -0
- package/prompts/planning/implementation-plan.md +98 -0
- package/prompts/planning/prd-generator.md +66 -0
- package/prompts/planning/scope-killer.md +74 -0
- package/prompts/quality/critical-path-tester.md +133 -0
- package/prompts/quality/pre-launch-checklist.md +137 -0
- package/prompts/quality/security-audit.md +115 -0
- package/prompts/quality/security-fixer.md +117 -0
- package/prompts/quality/security-hardening.md +157 -0
- package/prompts/system/master-system-prompt.md +252 -0
- package/skills/_index.md +60 -0
- package/skills/code-review-advanced.md +435 -0
- package/skills/code-review.md +86 -0
- package/skills/debugging.md +86 -0
- package/skills/documentation.md +97 -0
- package/skills/pr-description.md +116 -0
- package/skills/project-setup.md +123 -0
- package/skills/refactoring.md +93 -0
- package/skills/testing.md +134 -0
- package/snippets/_index.md +57 -0
- package/snippets/constraints/mvp-only.md +50 -0
- package/snippets/constraints/no-external-deps.md +45 -0
- package/snippets/constraints/read-only.md +45 -0
- package/snippets/constraints/security-first.md +50 -0
- package/snippets/modifiers/be-ruthless.md +52 -0
- package/snippets/modifiers/be-thorough.md +50 -0
- package/snippets/modifiers/effort-high.md +56 -0
- package/snippets/modifiers/explain-reasoning.md +50 -0
- package/snippets/modifiers/megathink.md +314 -0
- package/snippets/modifiers/meta-cot.md +101 -0
- package/snippets/modifiers/no-code-yet.md +55 -0
- package/snippets/modifiers/step-by-step.md +50 -0
- package/snippets/modifiers/ultrathink.md +359 -0
- package/snippets/output-formats/checklist.md +61 -0
- package/snippets/output-formats/json.md +53 -0
- package/snippets/output-formats/markdown-table.md +44 -0
- package/snippets/output-formats/numbered-list.md +44 -0
- package/templates/_index.md +101 -0
- package/templates/claude-md/auto-enhance.md +258 -0
- package/templates/claude-md/cli-tool.md +243 -0
- package/templates/claude-md/full.md +449 -0
- package/templates/claude-md/minimal.md +52 -0
- package/templates/claude-md/nextjs-app.md +207 -0
- package/templates/claude-md/nodejs-service.md +251 -0
- package/templates/claude-md/python-api.md +236 -0
- package/templates/copilot/instructions.md +33 -0
- package/templates/cursor-rules/fullstack.txt +98 -0
- package/templates/cursor-rules/minimal.txt +20 -0
- package/templates/cursor-rules/nextjs.txt +61 -0
- package/templates/cursor-rules/python.txt +79 -0
- package/templates/docs/adr-template.md +119 -0
- package/templates/docs/api-spec-template.md +277 -0
- package/templates/docs/prd-template.md +140 -0
- package/templates/docs/runbook-template.md +238 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Skill: Advanced Code Review"
|
|
3
|
+
description: Production-grade code review covering security, performance, architecture, and maintainability
|
|
4
|
+
tags: [skill, code-review, security, performance, architecture]
|
|
5
|
+
aliases: [review-advanced, deep-review, comprehensive-review]
|
|
6
|
+
version: 2.0.0
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Advanced Code Review Skill
|
|
10
|
+
|
|
11
|
+
> Go beyond "looks good to me" - this skill transforms you into a reviewer who catches bugs before production, identifies security holes before attackers, and spots performance issues before users complain.
|
|
12
|
+
|
|
13
|
+
## The Review Framework
|
|
14
|
+
|
|
15
|
+
### 4 Lenses of Code Review
|
|
16
|
+
|
|
17
|
+
Every code change should be examined through four lenses, in this order:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
21
|
+
│ 1. CORRECTNESS │
|
|
22
|
+
│ Does it work? Does it handle edge cases? Will it break? │
|
|
23
|
+
├─────────────────────────────────────────────────────────────┤
|
|
24
|
+
│ 2. SECURITY │
|
|
25
|
+
│ Can this be exploited? Is data protected? Auth correct? │
|
|
26
|
+
├─────────────────────────────────────────────────────────────┤
|
|
27
|
+
│ 3. PERFORMANCE │
|
|
28
|
+
│ Will it scale? Any O(n²)? N+1 queries? Memory leaks? │
|
|
29
|
+
├─────────────────────────────────────────────────────────────┤
|
|
30
|
+
│ 4. MAINTAINABILITY │
|
|
31
|
+
│ Can others understand it? Test it? Extend it? Debug it? │
|
|
32
|
+
└─────────────────────────────────────────────────────────────┘
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Lens 1: Correctness
|
|
38
|
+
|
|
39
|
+
### Checklist
|
|
40
|
+
- [ ] Does it actually solve the stated problem?
|
|
41
|
+
- [ ] Are all requirements addressed?
|
|
42
|
+
- [ ] Are edge cases handled?
|
|
43
|
+
- [ ] Are there off-by-one errors?
|
|
44
|
+
- [ ] Is error handling comprehensive?
|
|
45
|
+
- [ ] Are async operations awaited properly?
|
|
46
|
+
- [ ] Are types correct (not just `any`)?
|
|
47
|
+
|
|
48
|
+
### Red Flags
|
|
49
|
+
```typescript
|
|
50
|
+
// 🚨 Off-by-one error
|
|
51
|
+
for (let i = 0; i <= items.length; i++) // Should be <, not <=
|
|
52
|
+
|
|
53
|
+
// 🚨 Missing await
|
|
54
|
+
async function process() {
|
|
55
|
+
saveToDatabase(data); // Missing await - won't wait for save
|
|
56
|
+
return { success: true };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 🚨 Swallowed errors
|
|
60
|
+
try {
|
|
61
|
+
await riskyOperation();
|
|
62
|
+
} catch (e) {
|
|
63
|
+
// Silent failure - no logging, no re-throw
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 🚨 Falsy confusion
|
|
67
|
+
if (!user.age) // Fails for age === 0
|
|
68
|
+
if (user.age === undefined || user.age === null) // Correct
|
|
69
|
+
|
|
70
|
+
// 🚨 Array mutation
|
|
71
|
+
const sorted = items.sort(); // Mutates original! Use toSorted()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Questions to Ask
|
|
75
|
+
1. "What happens if this input is empty/null/undefined?"
|
|
76
|
+
2. "What happens if this is called twice quickly?"
|
|
77
|
+
3. "What happens if the network request fails?"
|
|
78
|
+
4. "What happens at exactly midnight on Dec 31?"
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Lens 2: Security
|
|
83
|
+
|
|
84
|
+
### The OWASP Top 10 Quick Check
|
|
85
|
+
|
|
86
|
+
| Vulnerability | What to Look For |
|
|
87
|
+
|--------------|------------------|
|
|
88
|
+
| Injection | String concatenation in queries, unescaped user input |
|
|
89
|
+
| Broken Auth | Missing auth checks, weak session handling |
|
|
90
|
+
| Sensitive Data Exposure | Logging PII, returning too much data |
|
|
91
|
+
| XXE | XML parsing without disabling external entities |
|
|
92
|
+
| Broken Access Control | Missing authorization after authentication |
|
|
93
|
+
| Security Misconfiguration | Debug mode in prod, default credentials |
|
|
94
|
+
| XSS | Unescaped HTML output, dangerouslySetInnerHTML |
|
|
95
|
+
| Insecure Deserialization | JSON.parse of untrusted data, eval() |
|
|
96
|
+
| Known Vulnerabilities | Outdated dependencies with CVEs |
|
|
97
|
+
| Insufficient Logging | No audit trail, no anomaly detection |
|
|
98
|
+
|
|
99
|
+
### Security Code Patterns
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// 🚨 SQL INJECTION
|
|
103
|
+
const query = `SELECT * FROM users WHERE id = '${userId}'`;
|
|
104
|
+
// ✅ FIX: Use parameterized queries
|
|
105
|
+
const user = await prisma.user.findUnique({ where: { id: userId } });
|
|
106
|
+
|
|
107
|
+
// 🚨 XSS
|
|
108
|
+
element.innerHTML = userInput;
|
|
109
|
+
// ✅ FIX: Use textContent or sanitize
|
|
110
|
+
element.textContent = userInput;
|
|
111
|
+
// Or with React, it's automatic unless you use dangerouslySetInnerHTML
|
|
112
|
+
|
|
113
|
+
// 🚨 PATH TRAVERSAL
|
|
114
|
+
const file = fs.readFileSync(`./uploads/${filename}`);
|
|
115
|
+
// Attack: filename = "../../etc/passwd"
|
|
116
|
+
// ✅ FIX: Validate and sanitize
|
|
117
|
+
const safeName = path.basename(filename);
|
|
118
|
+
const filePath = path.join(UPLOADS_DIR, safeName);
|
|
119
|
+
if (!filePath.startsWith(UPLOADS_DIR)) throw new Error('Invalid path');
|
|
120
|
+
|
|
121
|
+
// 🚨 MASS ASSIGNMENT
|
|
122
|
+
const user = await prisma.user.update({
|
|
123
|
+
where: { id },
|
|
124
|
+
data: req.body, // Attacker can set: { role: 'admin' }
|
|
125
|
+
});
|
|
126
|
+
// ✅ FIX: Whitelist allowed fields
|
|
127
|
+
const { name, email } = req.body;
|
|
128
|
+
const user = await prisma.user.update({
|
|
129
|
+
where: { id },
|
|
130
|
+
data: { name, email },
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 🚨 TIMING ATTACK on password comparison
|
|
134
|
+
if (password === storedPassword) // Short-circuits on first wrong char
|
|
135
|
+
// ✅ FIX: Use constant-time comparison
|
|
136
|
+
import { timingSafeEqual } from 'crypto';
|
|
137
|
+
const match = timingSafeEqual(
|
|
138
|
+
Buffer.from(password),
|
|
139
|
+
Buffer.from(storedPassword)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// 🚨 OPEN REDIRECT
|
|
143
|
+
res.redirect(req.query.returnUrl);
|
|
144
|
+
// Attack: returnUrl = "https://evil.com"
|
|
145
|
+
// ✅ FIX: Validate against allowlist
|
|
146
|
+
const ALLOWED_HOSTS = ['myapp.com', 'www.myapp.com'];
|
|
147
|
+
const url = new URL(req.query.returnUrl, 'https://myapp.com');
|
|
148
|
+
if (!ALLOWED_HOSTS.includes(url.host)) {
|
|
149
|
+
return res.redirect('/');
|
|
150
|
+
}
|
|
151
|
+
res.redirect(url.toString());
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Security Review Questions
|
|
155
|
+
1. "Where does this data come from? Is it trusted?"
|
|
156
|
+
2. "Who can access this endpoint? Should they be able to?"
|
|
157
|
+
3. "What happens if an attacker controls this value?"
|
|
158
|
+
4. "Is this logged? Should it be? (PII?)"
|
|
159
|
+
5. "Are secrets hardcoded anywhere?"
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Lens 3: Performance
|
|
164
|
+
|
|
165
|
+
### Time Complexity Red Flags
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// 🚨 O(n²) hidden in innocent-looking code
|
|
169
|
+
for (const item of items) {
|
|
170
|
+
const match = otherItems.find(o => o.id === item.id); // O(n) inside O(n)
|
|
171
|
+
}
|
|
172
|
+
// ✅ FIX: Use a Map for O(1) lookup
|
|
173
|
+
const otherMap = new Map(otherItems.map(o => [o.id, o]));
|
|
174
|
+
for (const item of items) {
|
|
175
|
+
const match = otherMap.get(item.id); // O(1)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 🚨 N+1 database queries
|
|
179
|
+
const users = await prisma.user.findMany();
|
|
180
|
+
for (const user of users) {
|
|
181
|
+
const posts = await prisma.post.findMany({ where: { userId: user.id } });
|
|
182
|
+
}
|
|
183
|
+
// ✅ FIX: Use includes/joins
|
|
184
|
+
const users = await prisma.user.findMany({
|
|
185
|
+
include: { posts: true },
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// 🚨 Fetching all when you need one
|
|
189
|
+
const allUsers = await prisma.user.findMany();
|
|
190
|
+
const admin = allUsers.find(u => u.role === 'admin');
|
|
191
|
+
// ✅ FIX: Query for what you need
|
|
192
|
+
const admin = await prisma.user.findFirst({
|
|
193
|
+
where: { role: 'admin' },
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// 🚨 Synchronous operations in async context
|
|
197
|
+
const data = fs.readFileSync(path); // Blocks event loop!
|
|
198
|
+
// ✅ FIX: Use async version
|
|
199
|
+
const data = await fs.promises.readFile(path);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Memory Red Flags
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// 🚨 Unbounded cache
|
|
206
|
+
const cache = new Map();
|
|
207
|
+
function getCached(key) {
|
|
208
|
+
if (!cache.has(key)) {
|
|
209
|
+
cache.set(key, expensiveOperation(key));
|
|
210
|
+
}
|
|
211
|
+
return cache.get(key);
|
|
212
|
+
}
|
|
213
|
+
// ✅ FIX: Use LRU cache with max size
|
|
214
|
+
import { LRUCache } from 'lru-cache';
|
|
215
|
+
const cache = new LRUCache({ max: 500 });
|
|
216
|
+
|
|
217
|
+
// 🚨 Loading entire file into memory
|
|
218
|
+
const content = await fs.readFile('huge-file.csv', 'utf-8');
|
|
219
|
+
// ✅ FIX: Stream processing
|
|
220
|
+
import { createReadStream } from 'fs';
|
|
221
|
+
import { createInterface } from 'readline';
|
|
222
|
+
|
|
223
|
+
const rl = createInterface({
|
|
224
|
+
input: createReadStream('huge-file.csv'),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
for await (const line of rl) {
|
|
228
|
+
processLine(line);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 🚨 Accumulating in array
|
|
232
|
+
const results = [];
|
|
233
|
+
for await (const chunk of stream) {
|
|
234
|
+
results.push(process(chunk)); // Memory grows unbounded
|
|
235
|
+
}
|
|
236
|
+
// ✅ FIX: Process and discard, or stream to destination
|
|
237
|
+
for await (const chunk of stream) {
|
|
238
|
+
await writeToDestination(process(chunk));
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### React Performance Red Flags
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
// 🚨 Creating new objects/arrays in render
|
|
246
|
+
function Component() {
|
|
247
|
+
return <Child style={{ color: 'red' }} />; // New object every render
|
|
248
|
+
}
|
|
249
|
+
// ✅ FIX: Hoist or memoize
|
|
250
|
+
const style = { color: 'red' };
|
|
251
|
+
function Component() {
|
|
252
|
+
return <Child style={style} />;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// 🚨 Creating functions in render
|
|
256
|
+
function Component() {
|
|
257
|
+
return <Button onClick={() => handleClick(id)} />; // New fn every render
|
|
258
|
+
}
|
|
259
|
+
// ✅ FIX: useCallback
|
|
260
|
+
const handleButtonClick = useCallback(() => handleClick(id), [id]);
|
|
261
|
+
|
|
262
|
+
// 🚨 Missing keys or using index as key
|
|
263
|
+
{items.map((item, index) => <Item key={index} {...item} />)}
|
|
264
|
+
// ✅ FIX: Use stable, unique key
|
|
265
|
+
{items.map(item => <Item key={item.id} {...item} />)}
|
|
266
|
+
|
|
267
|
+
// 🚨 Expensive calculation on every render
|
|
268
|
+
function Component({ items }) {
|
|
269
|
+
const sorted = items.sort((a, b) => a.name.localeCompare(b.name));
|
|
270
|
+
return <List items={sorted} />;
|
|
271
|
+
}
|
|
272
|
+
// ✅ FIX: useMemo
|
|
273
|
+
const sorted = useMemo(
|
|
274
|
+
() => [...items].sort((a, b) => a.name.localeCompare(b.name)),
|
|
275
|
+
[items]
|
|
276
|
+
);
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Performance Review Questions
|
|
280
|
+
1. "What's the time complexity? Does it scale?"
|
|
281
|
+
2. "How many database queries does this make?"
|
|
282
|
+
3. "Is there unnecessary data being fetched?"
|
|
283
|
+
4. "Will this work with 10x the data? 100x?"
|
|
284
|
+
5. "Are there any synchronous blocking operations?"
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Lens 4: Maintainability
|
|
289
|
+
|
|
290
|
+
### Code Smell Detection
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
// 🚨 GOD FUNCTION - does too many things
|
|
294
|
+
async function processOrder(order) {
|
|
295
|
+
validateOrder(order);
|
|
296
|
+
calculateTax(order);
|
|
297
|
+
applyDiscounts(order);
|
|
298
|
+
chargePayment(order);
|
|
299
|
+
updateInventory(order);
|
|
300
|
+
sendConfirmationEmail(order);
|
|
301
|
+
notifyWarehouse(order);
|
|
302
|
+
updateAnalytics(order);
|
|
303
|
+
}
|
|
304
|
+
// ✅ FIX: Single responsibility
|
|
305
|
+
async function processOrder(order) {
|
|
306
|
+
const validatedOrder = await orderValidator.validate(order);
|
|
307
|
+
const pricedOrder = await pricingService.calculate(validatedOrder);
|
|
308
|
+
const payment = await paymentService.charge(pricedOrder);
|
|
309
|
+
await fulfillmentService.initiate(pricedOrder, payment);
|
|
310
|
+
await notificationService.sendConfirmation(pricedOrder);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// 🚨 MAGIC NUMBERS/STRINGS
|
|
314
|
+
if (user.role === 'admin' && order.total > 1000) {
|
|
315
|
+
applyDiscount(0.1);
|
|
316
|
+
}
|
|
317
|
+
// ✅ FIX: Named constants
|
|
318
|
+
const ROLES = { ADMIN: 'admin', USER: 'user' } as const;
|
|
319
|
+
const BULK_ORDER_THRESHOLD = 1000;
|
|
320
|
+
const BULK_DISCOUNT_RATE = 0.1;
|
|
321
|
+
|
|
322
|
+
if (user.role === ROLES.ADMIN && order.total > BULK_ORDER_THRESHOLD) {
|
|
323
|
+
applyDiscount(BULK_DISCOUNT_RATE);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// 🚨 DEEP NESTING
|
|
327
|
+
if (user) {
|
|
328
|
+
if (user.isActive) {
|
|
329
|
+
if (user.hasPermission('edit')) {
|
|
330
|
+
if (document.isEditable) {
|
|
331
|
+
// Finally do something
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
// ✅ FIX: Early returns
|
|
337
|
+
if (!user) return;
|
|
338
|
+
if (!user.isActive) return;
|
|
339
|
+
if (!user.hasPermission('edit')) return;
|
|
340
|
+
if (!document.isEditable) return;
|
|
341
|
+
// Do something
|
|
342
|
+
|
|
343
|
+
// 🚨 BOOLEAN PARAMETER
|
|
344
|
+
function createUser(name, isAdmin) {
|
|
345
|
+
// ...
|
|
346
|
+
}
|
|
347
|
+
createUser('John', true); // What does true mean?
|
|
348
|
+
// ✅ FIX: Use object parameter
|
|
349
|
+
function createUser({ name, role }: { name: string; role: 'admin' | 'user' }) {
|
|
350
|
+
// ...
|
|
351
|
+
}
|
|
352
|
+
createUser({ name: 'John', role: 'admin' });
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Maintainability Review Questions
|
|
356
|
+
1. "Can I understand this code in 6 months?"
|
|
357
|
+
2. "Can a junior developer understand this?"
|
|
358
|
+
3. "How hard would it be to add a new feature here?"
|
|
359
|
+
4. "How hard would it be to test this?"
|
|
360
|
+
5. "Is there duplicated logic that should be extracted?"
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Review Output Format
|
|
365
|
+
|
|
366
|
+
Use this format for consistent, actionable reviews:
|
|
367
|
+
|
|
368
|
+
```markdown
|
|
369
|
+
## Code Review: [PR Title]
|
|
370
|
+
|
|
371
|
+
### Summary
|
|
372
|
+
[1-2 sentence summary of the change and overall assessment]
|
|
373
|
+
|
|
374
|
+
### 🔴 Must Fix (Blocking)
|
|
375
|
+
Issues that must be addressed before merging:
|
|
376
|
+
|
|
377
|
+
1. **[Issue Title]** (Line X)
|
|
378
|
+
- **Problem:** [What's wrong]
|
|
379
|
+
- **Impact:** [Why it matters]
|
|
380
|
+
- **Fix:** [Specific suggestion]
|
|
381
|
+
|
|
382
|
+
### 🟡 Should Fix (Non-blocking)
|
|
383
|
+
Issues that should be addressed, but don't block merge:
|
|
384
|
+
|
|
385
|
+
1. **[Issue Title]** (Line X)
|
|
386
|
+
- [Description and suggestion]
|
|
387
|
+
|
|
388
|
+
### 🟢 Suggestions (Optional)
|
|
389
|
+
Nice-to-haves that would improve the code:
|
|
390
|
+
|
|
391
|
+
1. **[Suggestion]** (Line X)
|
|
392
|
+
- [Description]
|
|
393
|
+
|
|
394
|
+
### ✅ What's Good
|
|
395
|
+
Acknowledge good patterns and decisions:
|
|
396
|
+
|
|
397
|
+
- [Good thing 1]
|
|
398
|
+
- [Good thing 2]
|
|
399
|
+
|
|
400
|
+
### Questions
|
|
401
|
+
Things I'd like clarification on:
|
|
402
|
+
|
|
403
|
+
1. [Question 1]
|
|
404
|
+
2. [Question 2]
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Review Efficiency Tips
|
|
410
|
+
|
|
411
|
+
### For Large PRs (500+ lines)
|
|
412
|
+
1. Review commit-by-commit if possible
|
|
413
|
+
2. Focus on public APIs first
|
|
414
|
+
3. Use "Files changed" to identify high-risk files
|
|
415
|
+
4. Ask if PR can be split
|
|
416
|
+
|
|
417
|
+
### For Unfamiliar Code
|
|
418
|
+
1. Start with tests to understand intent
|
|
419
|
+
2. Read the PR description carefully
|
|
420
|
+
3. Ask questions before assuming bugs
|
|
421
|
+
4. Check if patterns match rest of codebase
|
|
422
|
+
|
|
423
|
+
### Time Boxing
|
|
424
|
+
- Aim for 300-500 lines per hour
|
|
425
|
+
- Take breaks every 45 minutes
|
|
426
|
+
- Don't review for more than 2 hours straight
|
|
427
|
+
- Context switch to fresh reviewer for critical code
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Pairs Well With
|
|
432
|
+
|
|
433
|
+
- [[ultrathink]] - Add before review prompt for deeper analysis
|
|
434
|
+
- [[security-audit]] - When reviewing auth or data handling code
|
|
435
|
+
- [[typescript-react]] - Reference for React/TS best practices
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Skill: Code Review
|
|
2
|
+
|
|
3
|
+
> Thorough code review with actionable feedback
|
|
4
|
+
|
|
5
|
+
## When to Activate
|
|
6
|
+
|
|
7
|
+
- Reviewing pull requests
|
|
8
|
+
- Asked to review code changes
|
|
9
|
+
- Checking code before merge
|
|
10
|
+
|
|
11
|
+
## Behavior
|
|
12
|
+
|
|
13
|
+
When reviewing code:
|
|
14
|
+
|
|
15
|
+
1. **Understand Context First**
|
|
16
|
+
- What is this code trying to do?
|
|
17
|
+
- What's the scope of the change?
|
|
18
|
+
- Are there related files that should be checked?
|
|
19
|
+
|
|
20
|
+
2. **Review Systematically**
|
|
21
|
+
- Correctness: Does it do what it's supposed to?
|
|
22
|
+
- Security: Any vulnerabilities introduced?
|
|
23
|
+
- Performance: Any obvious inefficiencies?
|
|
24
|
+
- Maintainability: Will future developers understand this?
|
|
25
|
+
- Testing: Are changes tested?
|
|
26
|
+
|
|
27
|
+
3. **Prioritize Feedback**
|
|
28
|
+
- 🔴 **Must Fix**: Bugs, security issues, breaking changes
|
|
29
|
+
- 🟡 **Should Fix**: Code quality, potential issues
|
|
30
|
+
- 🟢 **Consider**: Style, minor improvements, suggestions
|
|
31
|
+
|
|
32
|
+
4. **Be Constructive**
|
|
33
|
+
- Explain why, not just what
|
|
34
|
+
- Suggest alternatives when criticizing
|
|
35
|
+
- Acknowledge good patterns
|
|
36
|
+
|
|
37
|
+
## Output Format
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
## Code Review Summary
|
|
41
|
+
|
|
42
|
+
### Overview
|
|
43
|
+
[Brief description of what the changes do]
|
|
44
|
+
|
|
45
|
+
### 🔴 Must Fix
|
|
46
|
+
1. **[File:Line]** - [Issue]
|
|
47
|
+
- Problem: [explanation]
|
|
48
|
+
- Suggestion: [how to fix]
|
|
49
|
+
|
|
50
|
+
### 🟡 Should Fix
|
|
51
|
+
1. **[File:Line]** - [Issue]
|
|
52
|
+
- [explanation and suggestion]
|
|
53
|
+
|
|
54
|
+
### 🟢 Consider
|
|
55
|
+
1. **[File:Line]** - [Suggestion]
|
|
56
|
+
|
|
57
|
+
### What's Good
|
|
58
|
+
- [Positive feedback on patterns, approach, etc.]
|
|
59
|
+
|
|
60
|
+
### Questions
|
|
61
|
+
- [Any clarifying questions about intent]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
### Good Review Comment
|
|
67
|
+
```
|
|
68
|
+
🟡 **src/api/users.ts:45** - Missing error handling
|
|
69
|
+
|
|
70
|
+
The `findUser` call can throw if the database is unavailable,
|
|
71
|
+
but there's no try/catch here. Consider:
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const user = await findUser(id);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
logger.error('Failed to find user', { id, error });
|
|
77
|
+
throw new ServiceError('User lookup failed');
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Avoid
|
|
82
|
+
```
|
|
83
|
+
❌ "This is wrong"
|
|
84
|
+
❌ "You should know better"
|
|
85
|
+
❌ Nitpicking style when there are bigger issues
|
|
86
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Skill: Debugging
|
|
2
|
+
|
|
3
|
+
> Systematic approach to finding and fixing bugs
|
|
4
|
+
|
|
5
|
+
## When to Activate
|
|
6
|
+
|
|
7
|
+
- User reports a bug or unexpected behavior
|
|
8
|
+
- Something isn't working as expected
|
|
9
|
+
- Error messages appear
|
|
10
|
+
|
|
11
|
+
## Behavior
|
|
12
|
+
|
|
13
|
+
1. **Understand the Problem**
|
|
14
|
+
- What is the expected behavior?
|
|
15
|
+
- What is the actual behavior?
|
|
16
|
+
- Can it be reproduced reliably?
|
|
17
|
+
- When did it start happening?
|
|
18
|
+
|
|
19
|
+
2. **Gather Evidence**
|
|
20
|
+
- Read error messages carefully
|
|
21
|
+
- Check logs
|
|
22
|
+
- Identify the exact failing line/function
|
|
23
|
+
- Note any recent changes
|
|
24
|
+
|
|
25
|
+
3. **Form Hypotheses**
|
|
26
|
+
- List 3-5 possible causes
|
|
27
|
+
- Consider: data, timing, environment, dependencies
|
|
28
|
+
- Rank by likelihood
|
|
29
|
+
|
|
30
|
+
4. **Test Hypotheses**
|
|
31
|
+
- Add diagnostic logging for top hypothesis
|
|
32
|
+
- Don't fix yet - confirm the cause first
|
|
33
|
+
- Rule out possibilities systematically
|
|
34
|
+
|
|
35
|
+
5. **Fix and Verify**
|
|
36
|
+
- Fix the confirmed cause
|
|
37
|
+
- Verify the fix doesn't break other things
|
|
38
|
+
- Consider if similar bugs exist elsewhere
|
|
39
|
+
|
|
40
|
+
## Debugging Questions
|
|
41
|
+
|
|
42
|
+
- Is this a data problem or a code problem?
|
|
43
|
+
- Does it happen in all environments?
|
|
44
|
+
- Is it intermittent or consistent?
|
|
45
|
+
- What changed recently?
|
|
46
|
+
- Has this ever worked?
|
|
47
|
+
|
|
48
|
+
## Anti-Patterns to Avoid
|
|
49
|
+
|
|
50
|
+
| Anti-Pattern | Problem |
|
|
51
|
+
|--------------|---------|
|
|
52
|
+
| Shotgun debugging | Random changes hoping something works |
|
|
53
|
+
| Fixing symptoms | Addressing visible issue, not root cause |
|
|
54
|
+
| Assumption-based fixes | Not verifying the cause before fixing |
|
|
55
|
+
| Ignoring logs | Logs often tell you exactly what's wrong |
|
|
56
|
+
|
|
57
|
+
## Output Format
|
|
58
|
+
|
|
59
|
+
```markdown
|
|
60
|
+
## Bug Analysis
|
|
61
|
+
|
|
62
|
+
### Problem
|
|
63
|
+
[Clear description of the issue]
|
|
64
|
+
|
|
65
|
+
### Reproduction
|
|
66
|
+
1. [Step 1]
|
|
67
|
+
2. [Step 2]
|
|
68
|
+
3. [Observe: behavior]
|
|
69
|
+
|
|
70
|
+
### Hypotheses
|
|
71
|
+
1. [Most likely] - [why]
|
|
72
|
+
2. [Second likely] - [why]
|
|
73
|
+
3. [Third likely] - [why]
|
|
74
|
+
|
|
75
|
+
### Diagnosis
|
|
76
|
+
[Diagnostic code/logs to add]
|
|
77
|
+
|
|
78
|
+
### Root Cause
|
|
79
|
+
[After diagnosis: confirmed cause]
|
|
80
|
+
|
|
81
|
+
### Fix
|
|
82
|
+
[The solution]
|
|
83
|
+
|
|
84
|
+
### Verification
|
|
85
|
+
[How to verify the fix works]
|
|
86
|
+
```
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Skill: Documentation
|
|
2
|
+
|
|
3
|
+
> Creating clear, useful documentation
|
|
4
|
+
|
|
5
|
+
## When to Activate
|
|
6
|
+
|
|
7
|
+
- Writing README files
|
|
8
|
+
- Documenting APIs
|
|
9
|
+
- Creating guides or tutorials
|
|
10
|
+
- Adding code comments
|
|
11
|
+
|
|
12
|
+
## Behavior
|
|
13
|
+
|
|
14
|
+
1. **Know Your Audience**
|
|
15
|
+
- Who will read this?
|
|
16
|
+
- What do they already know?
|
|
17
|
+
- What do they need to accomplish?
|
|
18
|
+
|
|
19
|
+
2. **Structure for Scanning**
|
|
20
|
+
- Lead with the most important info
|
|
21
|
+
- Use headers and bullets
|
|
22
|
+
- Include quick-start for busy readers
|
|
23
|
+
- Add details for those who need them
|
|
24
|
+
|
|
25
|
+
3. **Show, Don't Tell**
|
|
26
|
+
- Working code examples
|
|
27
|
+
- Copy-pasteable commands
|
|
28
|
+
- Expected outputs
|
|
29
|
+
- Common use cases
|
|
30
|
+
|
|
31
|
+
4. **Keep It Current**
|
|
32
|
+
- Date or version stamp
|
|
33
|
+
- Link to source of truth
|
|
34
|
+
- Note prerequisites
|
|
35
|
+
- Include troubleshooting
|
|
36
|
+
|
|
37
|
+
## Documentation Types
|
|
38
|
+
|
|
39
|
+
### README
|
|
40
|
+
```markdown
|
|
41
|
+
# Project Name
|
|
42
|
+
|
|
43
|
+
One-line description.
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
[3-5 commands to get running]
|
|
47
|
+
|
|
48
|
+
## What It Does
|
|
49
|
+
[Brief explanation]
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
[Detailed setup]
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
[Examples]
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
[Options]
|
|
59
|
+
|
|
60
|
+
## Contributing
|
|
61
|
+
[How to contribute]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### API Documentation
|
|
65
|
+
- Endpoint + method
|
|
66
|
+
- Parameters (required/optional)
|
|
67
|
+
- Request/response examples
|
|
68
|
+
- Error codes
|
|
69
|
+
- Authentication
|
|
70
|
+
|
|
71
|
+
### Code Comments
|
|
72
|
+
```typescript
|
|
73
|
+
// Good: Explains WHY
|
|
74
|
+
// We retry 3 times because the external API has intermittent failures
|
|
75
|
+
const MAX_RETRIES = 3;
|
|
76
|
+
|
|
77
|
+
// Bad: Explains WHAT (obvious from code)
|
|
78
|
+
// Set max retries to 3
|
|
79
|
+
const MAX_RETRIES = 3;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Writing Principles
|
|
83
|
+
|
|
84
|
+
| Principle | Example |
|
|
85
|
+
|-----------|---------|
|
|
86
|
+
| Be specific | "Run `npm test`" not "run the tests" |
|
|
87
|
+
| Use active voice | "Click Submit" not "Submit should be clicked" |
|
|
88
|
+
| Include context | "This config is only needed for production" |
|
|
89
|
+
| Anticipate questions | "If you see X error, try Y" |
|
|
90
|
+
|
|
91
|
+
## Output Checklist
|
|
92
|
+
|
|
93
|
+
- [ ] Can someone get started in < 5 minutes?
|
|
94
|
+
- [ ] Are all commands copy-pasteable?
|
|
95
|
+
- [ ] Are examples realistic (not just "foo", "bar")?
|
|
96
|
+
- [ ] Are prerequisites listed?
|
|
97
|
+
- [ ] Is there a troubleshooting section?
|