codingbuddy-rules 2.4.2 → 3.0.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.
Files changed (53) hide show
  1. package/.ai-rules/CHANGELOG.md +122 -0
  2. package/.ai-rules/agents/README.md +527 -11
  3. package/.ai-rules/agents/accessibility-specialist.json +0 -1
  4. package/.ai-rules/agents/act-mode.json +0 -1
  5. package/.ai-rules/agents/agent-architect.json +0 -1
  6. package/.ai-rules/agents/ai-ml-engineer.json +0 -1
  7. package/.ai-rules/agents/architecture-specialist.json +14 -2
  8. package/.ai-rules/agents/backend-developer.json +14 -2
  9. package/.ai-rules/agents/code-quality-specialist.json +0 -1
  10. package/.ai-rules/agents/data-engineer.json +0 -1
  11. package/.ai-rules/agents/devops-engineer.json +24 -2
  12. package/.ai-rules/agents/documentation-specialist.json +0 -1
  13. package/.ai-rules/agents/eval-mode.json +0 -1
  14. package/.ai-rules/agents/event-architecture-specialist.json +719 -0
  15. package/.ai-rules/agents/frontend-developer.json +14 -2
  16. package/.ai-rules/agents/i18n-specialist.json +0 -1
  17. package/.ai-rules/agents/integration-specialist.json +11 -1
  18. package/.ai-rules/agents/migration-specialist.json +676 -0
  19. package/.ai-rules/agents/mobile-developer.json +0 -1
  20. package/.ai-rules/agents/observability-specialist.json +747 -0
  21. package/.ai-rules/agents/performance-specialist.json +24 -2
  22. package/.ai-rules/agents/plan-mode.json +0 -1
  23. package/.ai-rules/agents/platform-engineer.json +0 -1
  24. package/.ai-rules/agents/security-specialist.json +27 -16
  25. package/.ai-rules/agents/seo-specialist.json +0 -1
  26. package/.ai-rules/agents/solution-architect.json +0 -1
  27. package/.ai-rules/agents/technical-planner.json +0 -1
  28. package/.ai-rules/agents/test-strategy-specialist.json +14 -2
  29. package/.ai-rules/agents/ui-ux-designer.json +0 -1
  30. package/.ai-rules/rules/core.md +25 -0
  31. package/.ai-rules/skills/README.md +35 -0
  32. package/.ai-rules/skills/database-migration/SKILL.md +531 -0
  33. package/.ai-rules/skills/database-migration/expand-contract-patterns.md +314 -0
  34. package/.ai-rules/skills/database-migration/large-scale-migration.md +414 -0
  35. package/.ai-rules/skills/database-migration/rollback-strategies.md +359 -0
  36. package/.ai-rules/skills/database-migration/validation-procedures.md +428 -0
  37. package/.ai-rules/skills/dependency-management/SKILL.md +381 -0
  38. package/.ai-rules/skills/dependency-management/license-compliance.md +282 -0
  39. package/.ai-rules/skills/dependency-management/lock-file-management.md +437 -0
  40. package/.ai-rules/skills/dependency-management/major-upgrade-guide.md +292 -0
  41. package/.ai-rules/skills/dependency-management/security-vulnerability-response.md +230 -0
  42. package/.ai-rules/skills/incident-response/SKILL.md +373 -0
  43. package/.ai-rules/skills/incident-response/communication-templates.md +322 -0
  44. package/.ai-rules/skills/incident-response/escalation-matrix.md +347 -0
  45. package/.ai-rules/skills/incident-response/postmortem-template.md +351 -0
  46. package/.ai-rules/skills/incident-response/severity-classification.md +256 -0
  47. package/.ai-rules/skills/performance-optimization/CREATION-LOG.md +87 -0
  48. package/.ai-rules/skills/performance-optimization/SKILL.md +76 -0
  49. package/.ai-rules/skills/performance-optimization/documentation-template.md +70 -0
  50. package/.ai-rules/skills/pr-review/SKILL.md +768 -0
  51. package/.ai-rules/skills/refactoring/SKILL.md +192 -0
  52. package/.ai-rules/skills/refactoring/refactoring-catalog.md +1377 -0
  53. package/package.json +1 -1
@@ -0,0 +1,768 @@
1
+ ---
2
+ name: pr-review
3
+ description: Use when conducting manual PR reviews - provides structured checklist covering security, performance, maintainability, and code quality dimensions with anti-sycophancy principles
4
+ ---
5
+
6
+ # PR Review
7
+
8
+ ## Overview
9
+
10
+ Systematic, evidence-based pull request review with anti-sycophancy principles. Critique-first ordering ensures critical issues are identified before any positive observations.
11
+
12
+ **Core principle:** Review what changed, not what it's called. Labels lie. Tests verify author's assumptions—review catches flawed assumptions.
13
+
14
+ **Violating the letter of this process is violating the spirit of code review.**
15
+
16
+ ## Table of Contents
17
+
18
+ - [When to Use](#when-to-use)
19
+ - [The Iron Law](#the-iron-law)
20
+ - [Quick Reference](#quick-reference)
21
+ - [Review Efficiency Framework](#review-efficiency-framework)
22
+ - [Change-Type Quick Guides](#change-type-quick-guides)
23
+ - [Review Process](#review-process)
24
+ - [Review Dimensions](#review-dimensions)
25
+ - [Security Quick Scan](#security-quick-scan)
26
+ - [Accessibility Quick Scan](#accessibility-quick-scan)
27
+ - [Devil's Advocate Analysis](#devils-advocate-analysis)
28
+ - [Impact Radius Analysis](#impact-radius-analysis)
29
+ - [Refactoring Verification](#refactoring-verification)
30
+ - [Anti-Sycophancy Guide](#anti-sycophancy-guide)
31
+ - [Constructive Feedback Patterns](#constructive-feedback-patterns)
32
+ - [Output Format](#output-format)
33
+ - [Common Rationalizations](#common-rationalizations)
34
+ - [Red Flags - STOP](#red-flags---stop)
35
+ - [When Stuck](#when-stuck)
36
+ - [Verification Checklist](#verification-checklist)
37
+ - [Knowledge Sharing](#knowledge-sharing)
38
+ - [Review Metrics](#review-metrics)
39
+ - [Specialist Escalation](#specialist-escalation)
40
+
41
+ ## When to Use
42
+
43
+ **Always use for:**
44
+ - New feature PRs
45
+ - Bug fix PRs
46
+ - Refactoring PRs
47
+ - Security-related changes
48
+ - API changes
49
+ - Database schema changes
50
+
51
+ **Lighter review acceptable for:**
52
+ - Documentation-only changes
53
+ - Configuration tweaks (still check security)
54
+ - Dependency updates (still check security + breaking changes)
55
+
56
+ **Never skip:**
57
+ - Security Quick Scan (4 critical items, ~2 min)
58
+
59
+ ## The Iron Law
60
+
61
+ ```
62
+ NO APPROVAL WITHOUT COMPLETING ALL CRITICAL DIMENSIONS
63
+ ```
64
+
65
+ Security, Correctness, and Test Coverage must ALWAYS be reviewed. No exceptions.
66
+
67
+ - Urgency doesn't reduce risk. Hotfix = MORE likely to introduce bugs.
68
+ - Trust is not a checklist substitute. Everyone makes mistakes.
69
+ - Tests passing ≠ logic correct. Tests verify author assumptions.
70
+
71
+ ## Quick Reference
72
+
73
+ ### Priority Levels
74
+
75
+ | Priority | Action | Dimensions |
76
+ |----------|--------|------------|
77
+ | **Critical** | Must complete ALWAYS | Correctness, Security, Tests |
78
+ | **High** | Must complete for non-trivial PRs | Architecture, Code Quality |
79
+ | **Medium** | Complete based on change type | Performance, Accessibility |
80
+ | **Low** | Complete if time permits | Documentation |
81
+
82
+ ### Production Blockers (Auto-Reject)
83
+
84
+ | Issue | Why It Blocks |
85
+ |-------|---------------|
86
+ | Hardcoded secrets | Security vulnerability |
87
+ | SQL injection possible | Data breach risk |
88
+ | Missing auth on protected route | Unauthorized access |
89
+ | No tests for new code | Regression risk |
90
+ | Critical security issue | Production incident |
91
+
92
+ ### Approval Decision Matrix
93
+
94
+ | Finding | Decision |
95
+ |---------|----------|
96
+ | Any Critical issue | **Request Changes** |
97
+ | Multiple High issues | **Request Changes** |
98
+ | Only Medium/Low issues | **Approve with Comments** |
99
+ | No issues, all Critical dimensions reviewed | **Approve** |
100
+
101
+ ## Review Efficiency Framework
102
+
103
+ Efficient reviews are thorough reviews. Time pressure causes shortcuts that miss issues.
104
+
105
+ ### Time-Boxing Guidelines
106
+
107
+ | PR Size | Target Time | Max Time | If Exceeded |
108
+ |---------|-------------|----------|-------------|
109
+ | XS (1-10 lines) | 5-10 min | 15 min | Document blockers |
110
+ | S (11-50 lines) | 15-30 min | 45 min | Request clarification |
111
+ | M (51-200 lines) | 30-60 min | 90 min | Split focus areas |
112
+ | L (201-500 lines) | 60-120 min | 180 min | Request smaller PR |
113
+ | XL (500+ lines) | **Request split** | - | Don't review as-is |
114
+
115
+ **Time exceeded?** You're either:
116
+ 1. Missing context → Ask author before continuing
117
+ 2. Finding too many issues → Request changes early, don't exhaust yourself
118
+ 3. Scope creeping → Stay focused on what changed, not what could be better
119
+
120
+ ### Efficiency Anti-Patterns
121
+
122
+ | Anti-Pattern | Why It Wastes Time | Instead |
123
+ |--------------|-------------------|---------|
124
+ | Reviewing file-by-file | Misses cross-file relationships | Review by logical change |
125
+ | Style nitpicking first | Depletes attention on low-value | Critical dimensions first |
126
+ | Rewriting in comments | You're doing their work | Describe what's wrong; brief suggestions OK (see Constructive Feedback) |
127
+ | Reviewing draft PRs | Premature feedback changes | Wait for "Ready for Review" |
128
+ | Multiple review passes | Tiring for both parties | One thorough pass |
129
+
130
+ ### When to Request Smaller PRs
131
+
132
+ **Immediately request split if:**
133
+ - 500+ lines changed (excluding generated files)
134
+ - Multiple unrelated features bundled
135
+ - "While I was here..." changes included
136
+ - You can't hold the full change in your head
137
+
138
+ **How to request:**
139
+ > This PR combines [X] and [Y]. Could you split into separate PRs? Review will be faster and more thorough for each.
140
+
141
+ ## Change-Type Quick Guides
142
+
143
+ Different PR types require different focus areas. Use these guides to prioritize your review.
144
+
145
+ ### Feature PRs
146
+
147
+ | Focus | Why | Key Checks |
148
+ |-------|-----|------------|
149
+ | Requirements alignment | New code must solve the right problem | Does implementation match ticket/spec? |
150
+ | API design | New interfaces are hard to change | Clean contracts? Versioning considered? |
151
+ | Test coverage | New behavior needs verification | Happy path + edge cases + errors tested? |
152
+ | Performance baseline | New features set expectations | Acceptable load? Indexed queries? |
153
+
154
+ **Time allocation:** 40% correctness, 30% architecture, 20% tests, 10% docs
155
+
156
+ ### Bug Fix PRs
157
+
158
+ | Focus | Why | Key Checks |
159
+ |-------|-----|------------|
160
+ | Root cause | Fixes that mask problems return | Does fix address cause, not symptom? |
161
+ | Regression test | Same bug shouldn't reappear | Test proves bug existed AND is fixed? |
162
+ | Related code | Similar bugs often cluster | Other code with same pattern? |
163
+ | Minimal change | Bug fixes shouldn't refactor | Only changes necessary for fix? |
164
+
165
+ **Time allocation:** 50% correctness, 30% tests, 15% impact radius, 5% docs
166
+
167
+ ### Refactoring PRs
168
+
169
+ | Focus | Why | Key Checks |
170
+ |-------|-----|------------|
171
+ | Behavior preservation | Refactoring ≠ new behavior | Tests unchanged? Same inputs → same outputs? |
172
+ | Incremental steps | Big refactors hide bugs | Each commit independently valid? |
173
+ | No feature creep | "While I'm here..." is a trap | Scope matches stated goal? |
174
+ | Test coverage before/after | Can't verify what you can't test | Coverage same or better? |
175
+
176
+ **Time allocation:** 50% behavior preservation, 30% architecture, 15% tests, 5% docs
177
+
178
+ ### Dependency Update PRs
179
+
180
+ | Focus | Why | Key Checks |
181
+ |-------|-----|------------|
182
+ | Security advisories | Main reason for updates | CVE addressed? New vulnerabilities? |
183
+ | Breaking changes | Changelog often buried | Migration guide followed? |
184
+ | Transitive deps | Your dep's deps matter | Lock file changes reviewed? |
185
+ | Build verification | Updates can break builds | CI passing? Bundle size acceptable? |
186
+
187
+ **Time allocation:** 40% security, 30% breaking changes, 20% build verification, 10% changelog
188
+
189
+ ### API Change PRs
190
+
191
+ | Focus | Why | Key Checks |
192
+ |-------|-----|------------|
193
+ | Contract compatibility | Callers depend on stable interfaces | Backward compatible? Deprecation path? |
194
+ | Versioning strategy | Breaking changes need coordination | Version bump appropriate? |
195
+ | Documentation | API users need to know what changed | Changelog updated? Migration guide? |
196
+ | Consumer impact | Changes ripple through dependents | Who calls this? Are they updated? |
197
+
198
+ **Time allocation:** 40% compatibility, 25% consumer impact, 20% documentation, 15% versioning
199
+
200
+ ## Review Process
201
+
202
+ ```dot
203
+ digraph review_process {
204
+ rankdir=TB;
205
+ node [shape=box];
206
+
207
+ start [label="PR Received" shape=ellipse];
208
+ context [label="1. Gather Context\n(description, ticket, scope)"];
209
+ change_type [label="2. Identify Change Type\n(feature/bugfix/refactor)" shape=diamond];
210
+ security_scan [label="3. Security Quick Scan\n(4 critical items)" style=filled fillcolor="#ffcccc"];
211
+ critical_dim [label="4. Critical Dimensions\n(Correctness, Tests)" style=filled fillcolor="#ffcccc"];
212
+ high_dim [label="5. High Dimensions\n(Architecture, Quality)"];
213
+ medium_dim [label="6. Medium/Low Dimensions\n(Performance, A11y, Docs)"];
214
+ devils_advocate [label="7. Devil's Advocate\n(What could go wrong?)"];
215
+ impact_radius [label="8. Impact Radius\n(Dependencies, contracts)"];
216
+ decision [label="9. Make Decision" shape=diamond];
217
+ approve [label="Approve" style=filled fillcolor="#ccffcc"];
218
+ request_changes [label="Request Changes" style=filled fillcolor="#ffcccc"];
219
+
220
+ start -> context;
221
+ context -> change_type;
222
+ change_type -> security_scan;
223
+ security_scan -> critical_dim;
224
+ critical_dim -> high_dim;
225
+ high_dim -> medium_dim;
226
+ medium_dim -> devils_advocate;
227
+ devils_advocate -> impact_radius;
228
+ impact_radius -> decision;
229
+ decision -> approve [label="No Critical/High"];
230
+ decision -> request_changes [label="Critical/High found"];
231
+ }
232
+ ```
233
+
234
+ **Key:** Red boxes = mandatory, never skip.
235
+
236
+ ## Review Dimensions
237
+
238
+ ### Critical: Correctness & Logic
239
+
240
+ Does the code do what it claims to do?
241
+
242
+ | ID | Check | Priority |
243
+ |----|-------|----------|
244
+ | CR-001 | Logic matches stated requirements/ticket | Critical |
245
+ | CR-002 | Edge cases handled (null, empty, boundary) | Critical |
246
+ | CR-003 | Error conditions handled appropriately | Critical |
247
+ | CR-004 | Data transformations preserve all fields | High |
248
+ | CR-005 | Conditional branches cover all cases | High |
249
+ | CR-006 | Off-by-one errors checked in loops | High |
250
+ | CR-007 | Async operations await properly | High |
251
+ | CR-008 | State mutations intentional and controlled | Medium |
252
+
253
+ ### Critical: Security
254
+
255
+ See **Security Quick Scan** section for 4 critical items (~2 min).
256
+
257
+ Full checklist for deeper review:
258
+
259
+ | ID | Check | Priority |
260
+ |----|-------|----------|
261
+ | SEC-001 | No hardcoded secrets/credentials | Critical |
262
+ | SEC-002 | SQL queries parameterized | Critical |
263
+ | SEC-003 | Auth required on protected routes | Critical |
264
+ | SEC-004 | Authorization verifies ownership | Critical |
265
+ | SEC-005 | XSS prevented (output encoding) | High |
266
+ | SEC-006 | CSRF tokens on state changes | High |
267
+ | SEC-007 | Sensitive data not logged | High |
268
+ | SEC-008 | File uploads validated | High |
269
+
270
+ ### Critical: Test Coverage
271
+
272
+ | ID | Check | Priority |
273
+ |----|-------|----------|
274
+ | TEST-001 | New code has corresponding tests | Critical |
275
+ | TEST-002 | Tests verify behavior, not implementation | High |
276
+ | TEST-003 | Edge cases and error paths tested | High |
277
+ | TEST-004 | Tests are readable (clear names) | Medium |
278
+ | TEST-005 | No mocking of implementation details | Medium |
279
+ | TEST-006 | Coverage meets target (90%+ core) | High |
280
+ | TEST-007 | Tests run successfully (no flaky) | Critical |
281
+ | TEST-008 | Integration tests for cross-component | Medium |
282
+
283
+ ### High: Architecture & Design
284
+
285
+ | ID | Check | Priority |
286
+ |----|-------|----------|
287
+ | ARCH-001 | Layer boundaries respected | High |
288
+ | ARCH-002 | Dependency direction correct | High |
289
+ | ARCH-003 | Single Responsibility followed | High |
290
+ | ARCH-004 | No premature abstraction (YAGNI) | Medium |
291
+ | ARCH-005 | Changes localized (not scattered) | Medium |
292
+ | ARCH-006 | Public APIs designed for stability | High |
293
+ | ARCH-007 | Appropriate patterns (not over-engineered) | Medium |
294
+ | ARCH-008 | Migration path for breaking changes | High |
295
+
296
+ ### High: Code Quality
297
+
298
+ | ID | Check | Priority |
299
+ |----|-------|----------|
300
+ | CQ-001 | No code duplication (DRY) | High |
301
+ | CQ-002 | Functions small (10-20 lines) | Medium |
302
+ | CQ-003 | Cyclomatic complexity acceptable (<=10) | Medium |
303
+ | CQ-004 | Nesting depth reasonable (<=3) | Medium |
304
+ | CQ-005 | TypeScript types explicit (no `any`) | High |
305
+ | CQ-006 | Names meaningful and consistent | High |
306
+ | CQ-007 | Dead code removed | Medium |
307
+ | CQ-008 | Comments explain 'why' not 'what' | Low |
308
+
309
+ ### Medium: Performance
310
+
311
+ | ID | Check | Priority |
312
+ |----|-------|----------|
313
+ | PERF-001 | No N+1 queries | High |
314
+ | PERF-002 | Expensive operations memoized | Medium |
315
+ | PERF-003 | Bundle size impact acceptable | Medium |
316
+ | PERF-004 | No blocking on main thread | High |
317
+ | PERF-005 | Large lists virtualized | Medium |
318
+ | PERF-006 | Images optimized | Low |
319
+ | PERF-007 | Caching strategy appropriate | Medium |
320
+ | PERF-008 | Memory leaks prevented | High |
321
+
322
+ ### Medium: Accessibility
323
+
324
+ | ID | Check | Priority |
325
+ |----|-------|----------|
326
+ | A11Y-001 | Semantic HTML used | High |
327
+ | A11Y-002 | Keyboard accessible | High |
328
+ | A11Y-003 | Images have alt text | Medium |
329
+ | A11Y-004 | Form inputs have labels | High |
330
+ | A11Y-005 | Color not only indicator | Medium |
331
+ | A11Y-006 | Focus management correct | High |
332
+ | A11Y-007 | ARIA attributes correct | Medium |
333
+ | A11Y-008 | Screen reader verified | Medium |
334
+
335
+ ### Low: Documentation
336
+
337
+ | ID | Check | Priority |
338
+ |----|-------|----------|
339
+ | DOC-001 | PR description explains 'why' | Medium |
340
+ | DOC-002 | Complex logic commented | Low |
341
+ | DOC-003 | Public APIs documented | Medium |
342
+ | DOC-004 | README updated if needed | Low |
343
+ | DOC-005 | Breaking changes documented | High |
344
+ | DOC-006 | Config changes documented | Medium |
345
+ | DOC-007 | Migration guide provided | Medium |
346
+ | DOC-008 | Commit messages clear | Low |
347
+
348
+ ## Security Quick Scan
349
+
350
+ **Always run. Takes ~2 minutes. Catches 80% of critical security issues.**
351
+
352
+ | ID | Check | Detection Pattern |
353
+ |----|-------|-------------------|
354
+ | SEC-001 | No hardcoded secrets | Search: `password=`, `apiKey=`, `token=`, `secret=` |
355
+ | SEC-002 | SQL injection prevented | Look for string concatenation in queries |
356
+ | SEC-003 | Auth on protected routes | New routes have auth middleware |
357
+ | SEC-004 | Authorization checks | Resource access verifies ownership |
358
+
359
+ **If ANY fail → STOP. Request changes immediately.**
360
+
361
+ ### Risk Signals (Trigger Deep Review)
362
+
363
+ - New/modified authentication code
364
+ - Database query changes
365
+ - User input handling changes
366
+ - File upload functionality
367
+ - External API integrations
368
+ - Cryptographic operations
369
+ - Permission/authorization changes
370
+ - New API endpoints
371
+
372
+ ## Accessibility Quick Scan
373
+
374
+ **Run for UI changes. Takes ~2 minutes. Catches common A11Y barriers.**
375
+
376
+ | ID | Check | Detection Pattern |
377
+ |----|-------|-------------------|
378
+ | A11Y-001 | Semantic HTML used | Search: `<div onClick=`, `<span onClick=` (should be buttons) |
379
+ | A11Y-002 | Keyboard accessible | onClick handlers without onKeyDown/onKeyPress |
380
+ | A11Y-004 | Form inputs have labels | `<input>` without associated label or aria-label |
381
+ | A11Y-006 | Focus management correct | tabIndex manipulation, focus traps in modals |
382
+
383
+ **If ANY fail in user-facing UI → Request changes.**
384
+
385
+ ### UI Change Signals (Trigger A11Y Review)
386
+
387
+ - New UI components or pages
388
+ - Modal/dialog implementations
389
+ - Form additions or changes
390
+ - Interactive element changes (buttons, links, menus)
391
+ - Navigation structure changes
392
+ - Custom widget implementations
393
+
394
+ ## Devil's Advocate Analysis
395
+
396
+ **Mandatory section. Challenge the implementation.**
397
+
398
+ ### Questions to Ask
399
+
400
+ 1. **What could go wrong in production?**
401
+ - Under high load?
402
+ - With unexpected input?
403
+ - With network failures?
404
+
405
+ 2. **What assumptions might be wrong?**
406
+ - Data format assumptions?
407
+ - Timing assumptions?
408
+ - State assumptions?
409
+
410
+ 3. **What edge cases are unhandled?**
411
+ - Empty collections?
412
+ - Null/undefined values?
413
+ - Concurrent modifications?
414
+ - Partial failures?
415
+
416
+ 4. **What happens when dependencies fail?**
417
+ - External API down?
418
+ - Database connection lost?
419
+ - Cache miss?
420
+
421
+ ## Impact Radius Analysis
422
+
423
+ ### Direct Dependencies
424
+
425
+ | Question | How to Check |
426
+ |----------|--------------|
427
+ | What imports this file? | `grep -r "import.*from.*<file>"` |
428
+ | What calls this function? | Find references in IDE |
429
+ | What extends this class? | Search for `extends <class>` |
430
+
431
+ ### Contract Changes
432
+
433
+ | Change Type | Breaking? | Action |
434
+ |-------------|-----------|--------|
435
+ | Removed export | Yes | Find all usages, update |
436
+ | Changed parameter | Likely | Check all callers |
437
+ | Narrowed return type | Likely | Verify consumers handle |
438
+ | Added required field | Yes | Update all creators |
439
+ | Changed behavior | Maybe | Verify tests cover |
440
+
441
+ ### Side Effect Checklist
442
+
443
+ - [ ] Changed types remain compatible with all usages?
444
+ - [ ] Existing callers' expected behavior still works?
445
+ - [ ] Affected code paths covered by tests?
446
+ - [ ] New failure cases handled by callers?
447
+ - [ ] State changes propagate correctly?
448
+ - [ ] Async chains still valid?
449
+
450
+ ## Refactoring Verification
451
+
452
+ **For refactoring PRs: Tests passing ≠ Bug-free. Manual verification required.**
453
+
454
+ | Area | Question |
455
+ |------|----------|
456
+ | **Conditional branches** | Does each if/else/switch branch work as intended? |
457
+ | **Data transformations** | Do all fields map correctly? |
458
+ | **Optional handling** | Do `?.`, `??`, `\|\|` provide intended fallbacks? |
459
+ | **Dependency injection** | Are all dependencies properly wired? |
460
+ | **Edge cases** | Null, undefined, empty array handled? |
461
+
462
+ **Output format:**
463
+ - 🔴 `file.ts:42` - [issue]: Missing null check on user.address
464
+ - ✅ Conditional branches: Verified all cases covered
465
+
466
+ ## Anti-Sycophancy Guide
467
+
468
+ ### Prohibited Phrases
469
+
470
+ | Don't Say | Why |
471
+ |-----------|-----|
472
+ | "Great job" | Subjective praise |
473
+ | "Well done" | Subjective praise |
474
+ | "Excellent work" | Subjective praise |
475
+ | "Looks good to me" (without evidence) | Empty approval |
476
+ | "LGTM" (without review) | Rubber stamp |
477
+
478
+ ### Required Language
479
+
480
+ | Instead Of | Use |
481
+ |------------|-----|
482
+ | "Great error handling" | "Error handling covers: network failures, validation errors, timeouts" |
483
+ | "Nice architecture" | "Architecture follows layer separation: API → Service → Repository" |
484
+ | "Good tests" | "Tests cover: happy path, 3 edge cases, 2 error conditions" |
485
+
486
+ ### Evidence-Based Format
487
+
488
+ Every observation must include:
489
+ - **Location**: `file.ts:line`
490
+ - **Finding**: What you observed
491
+ - **Impact**: Why it matters (or doesn't)
492
+
493
+ ## Constructive Feedback Patterns
494
+
495
+ Anti-sycophancy prevents false praise. This section ensures feedback that's both honest AND helpful.
496
+
497
+ **Note:** Brief suggestions are fine ("Consider using X"). Avoid rewriting entire implementations in comments—that's doing their work for them (see Efficiency Anti-Patterns).
498
+
499
+ ### Feedback Tone Spectrum
500
+
501
+ | Tone | Example | When to Use |
502
+ |------|---------|-------------|
503
+ | **Blocking** | "This will cause data loss. Must fix before merge." | Critical issues, security, data integrity |
504
+ | **Requesting** | "Please add null check here—crash possible." | High issues requiring change |
505
+ | **Suggesting** | "Consider extracting this to a helper—readability." | Medium issues, optional improvements |
506
+ | **Noting** | "FYI: Similar pattern in utils/helpers.ts" | Knowledge sharing, not requiring change |
507
+ | **Questioning** | "What happens if X is empty? I might be missing context." | Uncertain findings, seeking clarification |
508
+
509
+ ### Constructive Phrasing
510
+
511
+ | Instead Of | Use |
512
+ |------------|-----|
513
+ | "This is wrong" | "This will cause [specific problem] because [reason]" |
514
+ | "Why did you do this?" | "What was the reasoning for [approach]? I want to understand the context." |
515
+ | "This doesn't make sense" | "I'm having trouble following [specific part]. Could you add a comment?" |
516
+ | "You should have..." | "For future reference, [pattern] helps with [benefit]" |
517
+ | "Obviously..." | Remove. If it were obvious, it wouldn't need saying. |
518
+ | "Just do X" | "One option: [X]. This would [benefit]." |
519
+
520
+ ### Mentoring Through Reviews
521
+
522
+ **For junior developers:**
523
+ - Explain the "why" behind requests, not just the "what"
524
+ - Link to documentation, patterns, or prior PRs as examples
525
+ - Distinguish blocking issues from learning opportunities
526
+ - Acknowledge good decisions explicitly (with evidence, per anti-sycophancy)
527
+
528
+ **For senior developers:**
529
+ - Be direct—they don't need hand-holding
530
+ - Focus on architectural concerns over style
531
+ - Ask questions about design decisions you don't understand
532
+ - Trust their judgment on implementation details
533
+
534
+ ### Disagreement Protocol
535
+
536
+ When author pushes back on feedback:
537
+
538
+ 1. **Re-read your comment** — Is it clear? Is the impact obvious?
539
+ 2. **Provide evidence** — Code, docs, benchmarks, not opinions
540
+ 3. **Acknowledge tradeoffs** — "Your approach is faster to implement, mine is more maintainable"
541
+ 4. **Escalate appropriately** — Tech lead for architecture, security team for vulnerabilities
542
+ 5. **Accept disagreement** — Not every hill is worth dying on. Document and move on.
543
+
544
+ **Never:** Make it personal. Attack the code, not the coder.
545
+
546
+ ## Output Format
547
+
548
+ **Section order is mandatory. Critique-first.**
549
+
550
+ ```markdown
551
+ ## PR Review: [PR Title]
552
+
553
+ ### 1. Context
554
+ - Change type: [feature/bugfix/refactor]
555
+ - Scope: [X files, Y lines added, Z removed]
556
+ - Linked: [ticket/issue]
557
+
558
+ ### 2. Critical Findings
559
+ | Issue | Location | Impact | Severity |
560
+ |-------|----------|--------|----------|
561
+ | [finding] | file:line | [impact] | Critical/High |
562
+
563
+ ### 3. Security Quick Scan
564
+ - [x] No hardcoded secrets
565
+ - [x] SQL injection prevented
566
+ - [ ] Auth on protected routes - MISSING on `/api/users`
567
+ - [x] Authorization checks
568
+
569
+ ### 4. Devil's Advocate
570
+ - **Risk**: [what could go wrong]
571
+ - **Assumption**: [what might be wrong]
572
+ - **Edge case**: [unhandled scenario]
573
+
574
+ ### 5. Impact Radius
575
+ - Direct dependencies: [list]
576
+ - Contract changes: [breaking/non-breaking]
577
+
578
+ ### 6. Dimension Review
579
+ [Per-dimension findings with file:line references]
580
+
581
+ ### 7. Decision
582
+ **Request Changes** / **Approve** / **Approve with Comments**
583
+
584
+ Reason: [evidence-based justification]
585
+ ```
586
+
587
+ ## Common Rationalizations
588
+
589
+ | Excuse | Reality |
590
+ |--------|---------|
591
+ | "This change is too simple" | Simple changes break things too. Checklist takes 2 min. |
592
+ | "The tests pass" | Tests verify author's assumptions. Review catches flawed assumptions. |
593
+ | "I trust this developer" | Trust ≠ verification. Everyone makes mistakes. |
594
+ | "Security isn't my expertise" | Basic checklist doesn't require expertise. Follow it. |
595
+ | "Accessibility is nice-to-have" | Accessibility is a requirement. It's in the checklist. |
596
+ | "I'll do quick now, thorough later" | 'Later' never comes. Approved code ships. |
597
+ | "The PR is too large" | Large PR = high risk. Request smaller PRs or more time. |
598
+ | "It's just a hotfix" | Hotfixes become permanent. Technical debt accrues interest. |
599
+ | "Already reviewed similar code" | Context matters. This PR has different state. |
600
+ | "Internal tooling, doesn't matter" | Internal tools become external. Bad patterns spread. |
601
+ | "Generated code is safe" | Generated code can have bad templates. Review it. |
602
+ | "Just dependency updates" | Dependencies are code you didn't write. Security review MORE important. |
603
+
604
+ ## Red Flags - STOP
605
+
606
+ If you catch yourself thinking any of these, **STOP and return to checklist**:
607
+
608
+ - "Quick fix for now, investigate later"
609
+ - "Just try changing X and see if it works"
610
+ - "Skip the security check, it's internal"
611
+ - "The author said they tested it"
612
+ - "It's probably fine"
613
+ - "I don't understand but it looks okay"
614
+ - "One more approval won't hurt"
615
+ - "Everyone else approved it"
616
+ - "We're behind schedule"
617
+ - "It's been open too long"
618
+
619
+ **ALL of these mean: STOP. Return to checklist. Complete all Critical dimensions.**
620
+
621
+ ## When Stuck
622
+
623
+ | Problem | Solution |
624
+ |---------|----------|
625
+ | PR too large | Request smaller PRs. If urgent, review in chunks by component. |
626
+ | Unfamiliar domain | Ask author for context. Review related PRs. Check docs/ADRs. |
627
+ | Conflicting requirements | Escalate to product owner. Document assumptions in review. |
628
+ | Time pressure | Complete Critical dimensions ONLY. Note skipped areas explicitly. |
629
+ | Author pushback | Focus on objective evidence. Reference standards/checklist IDs. |
630
+ | Can't reproduce issue | Request reproduction steps. Check environment differences. |
631
+ | Uncertain about impact | Use Impact Radius Analysis. When in doubt, request changes. |
632
+ | Missing context | Check linked ticket/issue. Ask author before assuming. |
633
+
634
+ **If still stuck:** Escalate to specialist (see Specialist Escalation section).
635
+
636
+ ## Verification Checklist
637
+
638
+ Before submitting your review:
639
+
640
+ - [ ] Security Quick Scan completed (4 items)
641
+ - [ ] Correctness dimension reviewed
642
+ - [ ] Test coverage dimension reviewed
643
+ - [ ] Devil's Advocate analysis completed
644
+ - [ ] Impact Radius assessed
645
+ - [ ] No prohibited phrases in feedback
646
+ - [ ] All findings include file:line references
647
+ - [ ] Decision justified with evidence
648
+ - [ ] Critical Findings section appears BEFORE positives
649
+
650
+ **Cannot check all boxes? Do not submit approval.**
651
+
652
+ ## Knowledge Sharing
653
+
654
+ Reviews are learning opportunities. Capture and propagate valuable patterns.
655
+
656
+ ### What to Capture
657
+
658
+ | Discovery | Action |
659
+ |-----------|--------|
660
+ | Reusable pattern found | Add to team's pattern library or wiki |
661
+ | Common mistake identified | Create linting rule or add to onboarding docs |
662
+ | Unclear API discovered | Request/add documentation in that PR |
663
+ | Performance insight gained | Share in team channel with benchmark |
664
+ | Security vulnerability pattern | Add to security checklist, alert security team |
665
+
666
+ ### How to Share
667
+
668
+ **In the PR itself:**
669
+ - Tag team members who'd benefit: "FYI @alice - this pattern solves the issue you hit last week"
670
+ - Add explanatory comments for non-obvious code
671
+ - Link to relevant ADRs, RFCs, or documentation
672
+
673
+ **Beyond the PR:**
674
+ - Post noteworthy patterns in team Slack/channel with context
675
+ - Update team wiki with new patterns discovered
676
+ - Propose linting rules for recurring issues
677
+ - Add to interview question bank if it reveals important concepts
678
+
679
+ ### Learning from Reviews
680
+
681
+ **After each review, ask:**
682
+ - Did I learn something new about the codebase?
683
+ - Did I learn something new about the domain?
684
+ - Did I see a pattern I should adopt?
685
+ - Did I see a mistake I've made before?
686
+
687
+ **Track your own growth:**
688
+ - Keep a "TIL" (Today I Learned) log from reviews
689
+ - Note patterns you want to adopt in your own code
690
+ - Revisit your old PRs after learning new patterns
691
+
692
+ ## Review Metrics
693
+
694
+ Measure review effectiveness to improve the process.
695
+
696
+ ### Key Metrics to Track
697
+
698
+ | Metric | How to Measure | Target |
699
+ |--------|----------------|--------|
700
+ | **Review turnaround** | Time from "Ready" to first review | < 4 hours |
701
+ | **Review cycles** | Number of review → change → review loops | ≤ 2 |
702
+ | **Escapees** | Bugs found in prod that reviews missed | 0 |
703
+ | **False positives** | Requested changes that weren't actually issues | < 10% |
704
+ | **Review coverage** | PRs merged without review | 0% |
705
+
706
+ ### Issue Categorization
707
+
708
+ Tag findings for pattern analysis:
709
+
710
+ | Category | Examples |
711
+ |----------|----------|
712
+ | `security` | Auth bypass, injection, secrets |
713
+ | `correctness` | Logic errors, missing cases |
714
+ | `performance` | N+1, memory leaks, blocking |
715
+ | `maintainability` | Complexity, duplication, naming |
716
+ | `testing` | Missing tests, flaky tests |
717
+ | `documentation` | Missing/outdated docs |
718
+
719
+ ### Using Metrics
720
+
721
+ **Weekly:**
722
+ - Review turnaround times — Are PRs waiting too long?
723
+ - Cycle counts — Are requirements unclear? Are reviewers too picky?
724
+
725
+ **Monthly:**
726
+ - Escapee analysis — What did we miss? Why?
727
+ - Category trends — Are certain issue types increasing?
728
+
729
+ **Quarterly:**
730
+ - Process retrospective — Is our review process effective?
731
+ - Training needs — Do specific categories need team education?
732
+
733
+ **Don't:**
734
+ - Use metrics punitively (reviewer found issues = good, not bad)
735
+ - Optimize for speed over quality
736
+ - Compare reviewers to each other
737
+
738
+ ### Tooling {#review-tooling}
739
+
740
+ | Platform | Metric Source | Notes |
741
+ |----------|---------------|-------|
742
+ | **GitHub** | Insights → Pulse | Review activity, cycle time |
743
+ | **GitHub** | GraphQL API | Custom queries for turnaround |
744
+ | **GitLab** | Analytics → Code Review | Built-in review metrics |
745
+ | **Bitbucket** | Reports → Commits | PR activity tracking |
746
+ | **Third-party** | LinearB, Sleuth, Haystack | Cross-platform analytics |
747
+
748
+ **CLI quick checks:**
749
+ ```bash
750
+ # GitHub: Recent PR review times (requires gh CLI)
751
+ gh pr list --state merged --json number,mergedAt,createdAt --limit 20
752
+
753
+ # Git: Author-reviewer pairs (local analysis)
754
+ git log --format='%an reviewed by %cn' --merges --since='1 month ago'
755
+ ```
756
+
757
+ ## Specialist Escalation
758
+
759
+ For deep-dive reviews, reference specialist agents:
760
+
761
+ | Domain | Agent |
762
+ |--------|-------|
763
+ | Security | `.ai-rules/agents/security-specialist.json` |
764
+ | Performance | `.ai-rules/agents/performance-specialist.json` |
765
+ | Accessibility | `.ai-rules/agents/accessibility-specialist.json` |
766
+ | Architecture | `.ai-rules/agents/architecture-specialist.json` |
767
+ | Test Strategy | `.ai-rules/agents/test-strategy-specialist.json` |
768
+ | Code Quality | `.ai-rules/agents/code-quality-specialist.json` |