# Diff-scoped gate

A diff-scoped gate is a set of pre-merge checks chosen according to which files a change touches. Nicholas Hopper built one in which a script, not the agent, decides the scope, and in which the scope can be widened by judgment but never narrowed.

- **Published:** November 17, 2026
- **Updated:** November 17, 2026

## How Nicholas Hopper built it

At APX Stream, Hopper wrote a delivery skill for AI coding agents that classifies the delivered diff mechanically to choose which checks to run. Running every check on every change is slow; letting an agent choose which checks matter is unsafe. The script removes the choice from the agent.

## The three rules

- **An unrecognised path forces the full gate.** If the classifier meets a file it has no rule for, every check runs.
- **Only the script may narrow.** The agent may add checks when it judges that a change is riskier than its paths suggest. It may never remove one.
- **The classifier tests itself.** It has its own self-test, and if that fails, the full gate runs.

## Why the asymmetry

An agent under pressure to finish has a reason to believe its change is small. Hopper's rule makes the cheap direction (more checks) available to judgment and the risky direction (fewer checks) available only to code that can be reviewed and tested.

## Related skills

- Git worktrees
- [Claude Code](https://nicholashopper.com/skills/claude-code.md)
- Codex

---

Canonical page: https://nicholashopper.com/notes/diff-scoped-gate  
Last updated: 2026-11-17  
Index of all pages: https://nicholashopper.com/llms.txt
