Generated banner for Differential Review
Generated logo for Differential Review

Differential Review

Trail of BitsOfficialPublished by Trail of Bits

  • Skill
  • Review and audit
  • Security
  • CC-BY-SA-4.0
  • No issues found

From the author

Performs security-focused differential review of code changes. Adapts analysis depth to codebase size, uses git blame for context, calculates blast radius by counting callers, checks test coverage of modified code, and generates a markdown report. Use when reviewing a PR, commit, or diff for security vulnerabilities, checking whether a change re-introduces a previously fixed bug, asking what else a change could break, or finding which modified code has no test covering it.
— the description by Trail of Bits

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Differential Review provides a structured, risk-based methodology for auditing code changes. It helps developers and security engineers identify potential vulnerabilities by analyzing git history, assessing test coverage, and calculating the blast radius of modifications. The skill is designed to scale its analysis depth based on codebase size and risk level, ensuring that critical changes receive rigorous scrutiny while maintaining efficiency. It produces comprehensive markdown reports that document findings, evidence, and potential attack scenarios.

What it does

  • Performs security-focused differential analysis on PRs, commits, and diffs
  • Adapts analysis depth based on codebase size and risk level
  • Uses git history to identify regressions and security-related code removals
  • Calculates blast radius by identifying transitive callers of modified code
  • Checks test coverage for modified code to identify untested security risks
  • Generates structured markdown reports with concrete findings and evidence

When to use it

  • When reviewing PRs or commits for potential security vulnerabilities
  • When assessing the impact of refactors on existing security invariants
  • When investigating whether a change re-introduces previously fixed bugs
  • When determining if modified code lacks sufficient test coverage
  • When performing deep audits on critical system changes like authentication rewrites

Advantages

  • Risk-first approach prioritizes critical areas like auth and crypto
  • Evidence-based findings linked to git history and line numbers
  • Scalable methodology suitable for small PRs or large-scale audits
  • Quantifiable blast radius analysis reduces blind spots
  • Standardized reporting ensures consistent and actionable audit documentation

Usage examples

“Review this PR for security vulnerabilities and generate a report.”
The agent analyzes the diff, checks git history for removed security code, calculates the blast radius, and outputs a markdown report detailing any identified risks.
“Does this refactor introduce any security regressions?”
The agent performs a differential review, focusing on the refactored logic and comparing it against historical git blame data to identify potential regressions.
“Perform a deep audit on this authentication system rewrite.”
The agent applies the surgical strategy, building baseline context, performing deep analysis on auth changes, and conducting adversarial modeling to identify potential exploits.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/trailofbits/differential-review/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip differential-review.zip -d .agents/skills

Documentation by Trail of Bits

Differential Security Review

Security-focused code review for PRs, commits, and diffs.

Core Principles

  1. Risk-First: Focus on auth, crypto, value transfer, external calls

  2. Evidence-Based: Every finding backed by git history, line numbers, attack scenarios

  3. Adaptive: Scale to codebase size (SMALL/MEDIUM/LARGE)

  4. Honest: Explicitly state coverage limits and confidence level

  5. Output-Driven: Always generate comprehensive markdown report file


Rationalizations (Do Not Skip)

RationalizationWhy It's WrongRequired Action
"Small PR, quick review"Heartbleed was 2 linesClassify by RISK, not size
"I know this codebase"Familiarity breeds blind spotsBuild explicit baseline context
"Git history takes too long"History reveals regressionsNever skip Phase 1
"Blast radius is obvious"You'll miss transitive callersCalculate quantitatively
"No tests = not my problem"Missing tests = elevated risk ratingFlag in report, elevate severity
"Just a refactor, no security impact"Refactors break invariantsAnalyze as HIGH until proven LOW
"I'll explain verbally"No artifact = findings lostAlways write report

Quick Reference

Codebase Size Strategy
Codebase SizeStrategyApproach
SMALL (<20 files)DEEPRead all deps, full git blame
MEDIUM (20-200)FOCUSED1-hop deps, priority files
LARGE (200+)SURGICALCritical paths only
Risk Level Triggers
Risk LevelTriggers
HIGHAuth, crypto, external calls, value transfer, validation removal
MEDIUMBusiness logic, state changes, new public APIs
LOWComments, 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)
│  └─ Or delegate to: differential-review:adversarial-modeler agent
│     (Autonomous attacker modeling with concrete exploit scenarios)
│
├─ 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

Agents

differential-review:adversarial-modeler — Models attacker perspectives and builds exploit scenarios for HIGH RISK code changes. Follows the 5-step adversarial methodology (attacker model, attack vectors, exploitability rating, exploit scenario, baseline cross-reference) and produces structured vulnerability reports. Delegate to this agent when Phase 5 analysis is needed on high-risk changes, passing that full namespaced name as subagent_type — a bare adversarial-modeler is unregistered and the dispatch fails at runtime.


Quality Checklist

Before delivering:

  • [ ] All changed files analyzed

  • [ ] Git blame on removed security code

  • [ ] Blast radius calculated for HIGH risk

  • [ ] Attack scenarios are concrete (not generic)

  • [ ] Findings reference specific line numbers + commits

  • [ ] Report file generated

  • [ ] User notified with summary


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


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.

Files

reporting.md

Report Generation (Phase 6)

Comprehensive markdown report structure and formatting guidelines.


Report Structure

Generate markdown report with these mandatory sections:

1. Executive Summary
  • Severity distribution table

  • Risk assessment (CRITICAL/HIGH/MEDIUM/LOW)

  • Final recommendation (APPROVE/REJECT/CONDITIONAL)

  • Key metrics (test gaps, blast radius, red flags)

Template:

# Executive Summary

| Severity | Count |
|----------|-------|
| 🔴 CRITICAL | X |
| 🟠 HIGH | Y |
| 🟡 MEDIUM | Z |
| 🟢 LOW | W |

**Overall Risk:** CRITICAL/HIGH/MEDIUM/LOW
**Recommendation:** APPROVE/REJECT/CONDITIONAL

**Key Metrics:**
- Files analyzed: X/Y (Z%)
- Test coverage gaps: N functions
- High blast radius changes: M functions
- Security regressions detected: P

2. What Changed
  • Commit timeline with visual

  • File summary table

  • Lines changed stats

Template:

## What Changed

**Commit Range:** `base..head`
**Commits:** X
**Timeline:** YYYY-MM-DD to YYYY-MM-DD

| File | +Lines | -Lines | Risk | Blast Radius |
|------|--------|--------|------|--------------|
| file1.sol | +50 | -20 | HIGH | CRITICAL |
| file2.sol | +10 | -5 | MEDIUM | LOW |

**Total:** +N, -M lines across K files

3. Critical Findings

For each HIGH/CRITICAL issue:

### [SEVERITY] Title

**File**: path/to/file.ext:lineNumber
**Commit**: hash
**Blast Radius**: N callers (HIGH/MEDIUM/LOW)
**Test Coverage**: YES/NO/PARTIAL

**Description**: [clear explanation]

**Historical Context**:
- Git blame: Added in commit X (date)
- Message: "[original commit message]"
- [Why this code existed]

**Attack Scenario**:
[Concrete exploitation steps from adversarial.md]

**Proof of Concept**:
```code demonstrating issue```

**Recommendation**:
[Specific fix with code]

Example:

### 🔴 CRITICAL: Authorization Bypass in Withdraw

**File**: TokenVault.sol:156
**Commit**: abc123def
**Blast Radius**: 23 callers (HIGH)
**Test Coverage**: NO

**Description**:
Removed `require(msg.sender == owner)` check allows any user to withdraw funds.

**Historical Context**:
- Git blame: Added 2024-06-15 (commit def456)
- Message: "Add owner check per audit finding #45"
- Code existed to prevent unauthorized withdrawals

**Attack Scenario**:
1. Attacker calls `withdraw(1000 ether)`
2. No authorization check (removed)
3. 1000 ETH transferred to attacker
4. Protocol funds drained

**Proof of Concept**:
```solidity
// As any address
vault.withdraw(vault.balance());
// Success - funds stolen

Recommendation:

function withdraw(uint256 amount) external {
+   require(msg.sender == owner, "Unauthorized");
    // ... rest of function
}

---

### 4. Test Coverage Analysis

- Coverage statistics
- Untested changes list
- Risk assessment

**Template:**
```markdown
## Test Coverage Analysis

**Coverage:** X% of changed code

**Untested Changes:**
| Function | Risk | Impact |
|----------|------|--------|
| functionA() | HIGH | No validation tests |
| functionB() | MEDIUM | Logic untested |

**Risk Assessment:**
N HIGH-risk functions without tests → Recommend blocking merge

5. Blast Radius Analysis
  • High-impact functions table

  • Dependency graph

  • Impact quantification

Template:

## Blast Radius Analysis

**High-Impact Changes:**
| Function | Callers | Risk | Priority |
|----------|---------|------|----------|
| transfer() | 89 | HIGH | P0 |
| validate() | 45 | MEDIUM | P1 |

6. Historical Context
  • Security-related removals

  • Regression risks

  • Commit message red flags

Template:

## Historical Context

**Security-Related Removals:**
- Line 45: `require` removed (added 2024-03 for CVE-2024-1234)
- Line 78: Validation removed (added 2023-12 "security hardening")

**Regression Risks:**
- Code pattern removed in commit X, re-added in commit Y

7. Recommendations
  • Immediate actions (blocking)

  • Before production (tracking)

  • Technical debt (future)

Template:

## Recommendations

### Immediate (Blocking)
- [ ] Fix CRITICAL issue in TokenVault.sol:156
- [ ] Add tests for withdraw() function

### Before Production
- [ ] Security audit of auth changes
- [ ] Load test blast radius functions

### Technical Debt
- [ ] Refactor validation pattern consistency

8. Analysis Methodology
  • Strategy used (DEEP/FOCUSED/SURGICAL)

  • Files analyzed

  • Coverage estimate

  • Techniques applied

  • Limitations

  • Confidence level

Template:

## Analysis Methodology

**Strategy:** FOCUSED (80 files, medium codebase)

**Analysis Scope:**
- Files reviewed: 45/80 (56%)
- HIGH RISK: 100% coverage
- MEDIUM RISK: 60% coverage
- LOW RISK: Excluded

**Techniques:**
- Git blame on all removals
- Blast radius calculation
- Test coverage analysis
- Adversarial modeling for HIGH RISK

**Limitations:**
- Did not analyze external dependencies
- Limited to 1-hop caller analysis

**Confidence:** HIGH for analyzed scope, MEDIUM overall

9. Appendices
  • Commit reference table

  • Key definitions

  • Contact info


Formatting Guidelines

Tables: Use markdown tables for structured data

Code blocks: Always include syntax highlighting

// Solidity code
// Rust code

Status indicators:

  • ✅ Complete

  • ⚠️ Warning

  • ❌ Failed/Blocked

Severity:

  • 🔴 CRITICAL

  • 🟠 HIGH

  • 🟡 MEDIUM

  • 🟢 LOW

Before/After comparisons:

**BEFORE:**
```code
old code

AFTER:

new code

**Line number references:** Always include
- Format: `file.sol:L123`
- Link to commit: `file.sol:L123 (commit abc123)`

---

## File Naming and Location

**Priority order for output:**
1. Current working directory (if project repo)
2. User's Desktop
3. `~/.claude/skills/differential-review/output/`

**Filename format:**

<PROJECT>DIFFERENTIAL_REVIEW<DATE>.md

Example: VeChain_Stargate_DIFFERENTIAL_REVIEW_2025-12-26.md


---

## User Notification Template

After generating report:

```markdown
Report generated successfully!

📄 File: [filename]
📁 Location: [path]
📏 Size: XX KB
⏱️ Review Time: ~X hours

Summary:
- X findings (Y critical, Z high)
- Final recommendation: APPROVE/REJECT/CONDITIONAL
- Confidence: HIGH/MEDIUM/LOW

Next steps:
- Review findings in detail
- Address CRITICAL/HIGH issues before merge
- Consider chaining with issue-writer for stakeholder report

Integration with issue-writer

After generating differential review, transform into audit report:

issue-writer --input DIFFERENTIAL_REVIEW_REPORT.md --format audit-report

This creates polished documentation for non-technical stakeholders.


Error Handling

If file write fails:

  1. Try Desktop location

  2. Try temp directory

  3. As last resort, output full report to chat

  4. Notify user to save manually

Always prioritize persistent artifact generation over ephemeral chat output.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Trail of Bits
Publisher
Trail of Bits (Official)
Source
trailofbits/skills · plugins/differential-review/skills/differential-review · commit e4dd0bb
Licence
Creative Commons Attribution-ShareAlike 4.0 International (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Trail of Bits.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download differential-review.zip