Differential Security Review
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
Security-focused code review for PRs, commits, and diffs.
When to Use
- You need a security-focused review of a PR, commit range, or diff rather than a general code review.
- The changes touch auth, crypto, external calls, value transfer, permissions, or other high-risk logic.
- You need findings backed by code evidence, attack scenarios, and an explicit report artifact.
Core Principles
- Risk-First: Focus on auth, crypto, value transfer, external calls
- Evidence-Based: Every finding backed by git history, line numbers, attack scenarios
- Adaptive: Scale to codebase size (SMALL/MEDIUM/LARGE)
- Honest: Explicitly state coverage limits and confidence level
- Output-Driven: Always generate comprehensive markdown report file
Rationalizations (Do Not Skip)
| Rationalization |
Why It's Wrong |
Required Action |
| "Small PR, quick review" |
Heartbleed was 2 lines |
Classify by RISK, not size |
| "I know this codebase" |
Familiarity breeds blind spots |
Build explicit baseline context |
| "Git history takes too long" |
History reveals regressions |
Never skip Phase 1 |
| "Blast radius is obvious" |
You'll miss transitive callers |
Calculate quantitatively |
| "No tests = not my problem" |
Missing tests = elevated risk rating |
Flag in report, elevate severity |
| "Just a refactor, no security impact" |
Refactors break invariants |
Analyze as HIGH until proven LOW |
| "I'll explain verbally" |
No artifact = findings lost |
Always write report |
Quick Reference
Codebase Size Strategy
| Codebase Size |
Strategy |
Approach |
| SMALL (<20 files) |
DEEP |
Read all deps, full git blame |
| MEDIUM (20-200) |
FOCUSED |
1-hop deps, priority files |
| LARGE (200+) |
SURGICAL |
Critical paths only |
Risk Level Triggers
| Risk Level |
Triggers |
| HIGH |
Auth, crypto, external calls, value transfer, validation removal |
| MEDIUM |
Business logic, state changes, new public APIs |
| LOW |
Comments, tests, UI, logging |
Workflow Overview
Pre-Analysis → Phase 0: Triage → Phase 1: Code Analysis → Phase 2: Test Coverage
↓ ↓ ↓ ↓
Phase 3: Blast Radius → Phase 4: Deep Context → Phase 5: Adversarial → Phase 6: Report
Decision Tree
Starting a review?
├─ Need detailed phase-by-phase methodology?
│ └─ Read: methodology.md
│ (Pre-Analysis + Phases 0-4: triage, code analysis, test coverage, blast radius)
│
├─ Analyzing HIGH RISK change?
│ └─ Read: adversarial.md
│ (Phase 5: Attacker modeling, exploit scenarios, exploitability rating)
│
├─ Writing the final report?
│ └─ Read: reporting.md
│ (Phase 6: Report structure, templates, formatting guidelines)
│
├─ Looking for specific vulnerability patterns?
│ └─ Read: patterns.md
│ (Regressions, reentrancy, access control, overflow, etc.)
│
└─ Quick triage only?
└─ Use Quick Reference above, skip detailed docs
Quality Checklist
Before delivering:
Integration
audit-context-building skill:
- Pre-Analysis: Build baseline context
- Phase 4: Deep context on HIGH RISK changes
issue-writer skill:
- Transform findings into formal audit reports
- Command:
issue-writer --input DIFFERENTIAL_REVIEW_REPORT.md --format audit-report
Example Usage
Quick Triage (Small PR)
Input: 5 file PR, 2 HIGH RISK files
Strategy: Use Quick Reference
1. Classify risk level per file (2 HIGH, 3 LOW)
2. Focus on 2 HIGH files only
3. Git blame removed code
4. Generate minimal report
Time: ~30 minutes
Standard Review (Medium Codebase)
Input: 80 files, 12 HIGH RISK changes
Strategy: FOCUSED (see methodology.md)
1. Full workflow on HIGH RISK files
2. Surface scan on MEDIUM
3. Skip LOW risk files
4. Complete report with all sections
Time: ~3-4 hours
Deep Audit (Large, Critical Change)
Input: 450 files, auth system rewrite
Strategy: SURGICAL + audit-context-building
1. Baseline context with audit-context-building
2. Deep analysis on auth changes only
3. Blast radius analysis
4. Adversarial modeling
5. Comprehensive report
Time: ~6-8 hours
When NOT to Use This Skill
- Greenfield code (no baseline to compare)
- Documentation-only changes (no security impact)
- Formatting/linting (cosmetic changes)
- User explicitly requests quick summary only (they accept risk)
For these cases, use standard code review instead.
Red Flags (Stop and Investigate)
Immediate escalation triggers:
- Removed code from "security", "CVE", or "fix" commits
- Access control modifiers removed (onlyOwner, internal → external)
- Validation removed without replacement
- External calls added without checks
- High blast radius (50+ callers) + HIGH risk change
These patterns require adversarial analysis even in quick triage.
Tips for Best Results
Do:
- Start with git blame for removed code
- Calculate blast radius early to prioritize
- Generate concrete attack scenarios
- Reference specific line numbers and commits
- Be honest about coverage limitations
- Always generate the output file
Don't:
- Skip git history analysis
- Make generic findings without evidence
- Claim full analysis when time-limited
- Forget to check test coverage
- Miss high blast radius changes
- Output report only to chat (file required)
Supporting Documentation
- methodology.md - Detailed phase-by-phase workflow (Phases 0-4)
- adversarial.md - Attacker modeling and exploit scenarios (Phase 5)
- reporting.md - Report structure and formatting (Phase 6)
- patterns.md - Common vulnerability patterns reference
For first-time users: Start with methodology.md to understand the complete workflow.
For experienced users: Use this page's Quick Reference and Decision Tree to navigate directly to needed content.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
1---2name: differential-review3description: ALWAYS use this when the request matches Differential Review: Security-focused code review for PRs, commits, and diffs.4---56# Differential Security Review78## Selective Reading Rule910Start with:1112- `references/senior-master-standard.md`13- `references/usage-routing.md`14- `references/quality-checklist.md`1516Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.1718Security-focused code review for PRs, commits, and diffs.1920## When to Use21- You need a security-focused review of a PR, commit range, or diff rather than a general code review.22- The changes touch auth, crypto, external calls, value transfer, permissions, or other high-risk logic.23- You need findings backed by code evidence, attack scenarios, and an explicit report artifact.2425## Core Principles26271. **Risk-First**: Focus on auth, crypto, value transfer, external calls282. **Evidence-Based**: Every finding backed by git history, line numbers, attack scenarios293. **Adaptive**: Scale to codebase size (SMALL/MEDIUM/LARGE)304. **Honest**: Explicitly state coverage limits and confidence level315. **Output-Driven**: Always generate comprehensive markdown report file3233---3435## Rationalizations (Do Not Skip)3637| Rationalization | Why It's Wrong | Required Action |38|-----------------|----------------|-----------------|39| "Small PR, quick review" | Heartbleed was 2 lines | Classify by RISK, not size |40| "I know this codebase" | Familiarity breeds blind spots | Build explicit baseline context |41| "Git history takes too long" | History reveals regressions | Never skip Phase 1 |42| "Blast radius is obvious" | You'll miss transitive callers | Calculate quantitatively |43| "No tests = not my problem" | Missing tests = elevated risk rating | Flag in report, elevate severity |44| "Just a refactor, no security impact" | Refactors break invariants | Analyze as HIGH until proven LOW |45| "I'll explain verbally" | No artifact = findings lost | Always write report |4647---4849## Quick Reference5051### Codebase Size Strategy5253| Codebase Size | Strategy | Approach |54|---------------|----------|----------|55| SMALL (<20 files) | DEEP | Read all deps, full git blame |56| MEDIUM (20-200) | FOCUSED | 1-hop deps, priority files |57| LARGE (200+) | SURGICAL | Critical paths only |5859### Risk Level Triggers6061| Risk Level | Triggers |62|------------|----------|63| HIGH | Auth, crypto, external calls, value transfer, validation removal |64| MEDIUM | Business logic, state changes, new public APIs |65| LOW | Comments, tests, UI, logging |6667---6869## Workflow Overview7071```72Pre-Analysis → Phase 0: Triage → Phase 1: Code Analysis → Phase 2: Test Coverage73 ↓ ↓ ↓ ↓74Phase 3: Blast Radius → Phase 4: Deep Context → Phase 5: Adversarial → Phase 6: Report75```7677---7879## Decision Tree8081**Starting a review?**8283```84├─ Need detailed phase-by-phase methodology?85│ └─ Read: methodology.md86│ (Pre-Analysis + Phases 0-4: triage, code analysis, test coverage, blast radius)87│88├─ Analyzing HIGH RISK change?89│ └─ Read: adversarial.md90│ (Phase 5: Attacker modeling, exploit scenarios, exploitability rating)91│92├─ Writing the final report?93│ └─ Read: reporting.md94│ (Phase 6: Report structure, templates, formatting guidelines)95│96├─ Looking for specific vulnerability patterns?97│ └─ Read: patterns.md98│ (Regressions, reentrancy, access control, overflow, etc.)99│100└─ Quick triage only?101 └─ Use Quick Reference above, skip detailed docs102```103104---105106## Quality Checklist107108Before delivering:109110- [ ] All changed files analyzed111- [ ] Git blame on removed security code112- [ ] Blast radius calculated for HIGH risk113- [ ] Attack scenarios are concrete (not generic)114- [ ] Findings reference specific line numbers + commits115- [ ] Report file generated116- [ ] User notified with summary117118---119120## Integration121122**audit-context-building skill:**123- Pre-Analysis: Build baseline context124- Phase 4: Deep context on HIGH RISK changes125126**issue-writer skill:**127- Transform findings into formal audit reports128- Command: `issue-writer --input DIFFERENTIAL_REVIEW_REPORT.md --format audit-report`129130---131132## Example Usage133134### Quick Triage (Small PR)135```136Input: 5 file PR, 2 HIGH RISK files137Strategy: Use Quick Reference1381. Classify risk level per file (2 HIGH, 3 LOW)1392. Focus on 2 HIGH files only1403. Git blame removed code1414. Generate minimal report142Time: ~30 minutes143```144145### Standard Review (Medium Codebase)146```147Input: 80 files, 12 HIGH RISK changes148Strategy: FOCUSED (see methodology.md)1491. Full workflow on HIGH RISK files1502. Surface scan on MEDIUM1513. Skip LOW risk files1524. Complete report with all sections153Time: ~3-4 hours154```155156### Deep Audit (Large, Critical Change)157```158Input: 450 files, auth system rewrite159Strategy: SURGICAL + audit-context-building1601. Baseline context with audit-context-building1612. Deep analysis on auth changes only1623. Blast radius analysis1634. Adversarial modeling1645. Comprehensive report165Time: ~6-8 hours166```167168---169170## When NOT to Use This Skill171172- **Greenfield code** (no baseline to compare)173- **Documentation-only changes** (no security impact)174- **Formatting/linting** (cosmetic changes)175- **User explicitly requests quick summary only** (they accept risk)176177For these cases, use standard code review instead.178179---180181## Red Flags (Stop and Investigate)182183**Immediate escalation triggers:**184- Removed code from "security", "CVE", or "fix" commits185- Access control modifiers removed (onlyOwner, internal → external)186- Validation removed without replacement187- External calls added without checks188- High blast radius (50+ callers) + HIGH risk change189190These patterns require adversarial analysis even in quick triage.191192---193194## Tips for Best Results195196**Do:**197- Start with git blame for removed code198- Calculate blast radius early to prioritize199- Generate concrete attack scenarios200- Reference specific line numbers and commits201- Be honest about coverage limitations202- Always generate the output file203204**Don't:**205- Skip git history analysis206- Make generic findings without evidence207- Claim full analysis when time-limited208- Forget to check test coverage209- Miss high blast radius changes210- Output report only to chat (file required)211212---213214## Supporting Documentation215216- **methodology.md** - Detailed phase-by-phase workflow (Phases 0-4)217- **adversarial.md** - Attacker modeling and exploit scenarios (Phase 5)218- **reporting.md** - Report structure and formatting (Phase 6)219- **patterns.md** - Common vulnerability patterns reference220221---222223**For first-time users:** Start with methodology.md to understand the complete workflow.224225**For experienced users:** Use this page's Quick Reference and Decision Tree to navigate directly to needed content.226227## Limitations228- Use this skill only when the task clearly matches the scope described above.229- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.230- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.