ScopeGuard

Your AI coding agent says the tests pass. ScopeGuard checks how it got there. It reads the change and flags every test that was skipped, loosened, commented out or deleted, every CI step told to ignore failures, and every file the task never allowed it to touch.

Runs in your browser: nothing is uploadedNo AI decides the verdictSame answer on the command line, in CI and as a Claude Code hookMIT licence

Try it

Pick one of the real-shaped examples, or paste your own change: the output of git diff, git show, or a pull request's .diff link saved as text.

Start here

  1. Press an example above, then Check it. "It skipped the failing test" is the quickest to read: one line, one finding.
  2. Read the verdict. Flagged means at least one high finding: a reviewer must read those lines before the change is merged. Review means only review findings: worth a look, often honest. Clean means no rule fired.
  3. Read each finding. Every one names its rule, the file and line, and the exact text. The rule list below says what each rule looks for.
  4. Paste your own change. In a terminal in your project, run git diff main...HEAD (or git show for the last commit), copy the output, paste it in. Nothing leaves this page.
  5. Add a scope if the task should only touch some files: one allow line per folder or file pattern. Anything else the change touches is flagged.
  6. Put it to work: in CI on every pull request, as a Claude Code hook so the agent cannot finish with a weakened test, or as a pre-commit check. See Put it to work.

How it works

Five steps, all in one small file of code (kernel.mjs) that this page runs directly. The same file runs on the command line and in CI, so this page's answer is the command line's answer.

The change goes through five steps: read the diff, sort every path, run the rules, give the verdict, fingerprint it 1 · Readthe diff, line by linerefuse what can't be read 2 · Sorteach file: test, gateor code; in scope or not 3 · Rulesa closed listover added and removed lines 4 · Verdictclean · review · flaggedevery finding with its line 5 · FingerprintSHA-256 of the inputand of the result a cut-off diff stops hereno AI model, no networkanyone can recompute both

Traced from a real run

This trace is computed when the page loads, by running the "It skipped the failing test" example through the kernel. It is not a picture of what should happen; it is what happened.

  1. Running…

Two kinds of rule

Line rules look at one added line: a skip marker, a focus marker, a "continue on error". They only fire when the marker is new: one that was removed and added back (moved, re-indented) is not new.

Pairing rules compare what was removed with what was added in the same file. An exact check (toBe(2500), assertEqual, ==) removed and a looser one (toBeDefined(), assertTrue, !=) added on the same value is a loosened check. The pairing is by the value being checked, so argument order does not matter, and a rename to a different value is not paired. A removed line and an added line that differ only in one number are compared number by number, which is how a widened tolerance or a lowered coverage floor is found.

The rules

This is the whole list, read from the kernel as the page loads. Nothing is checked that is not on it. High: a reviewer must read it before merging. Review: worth a look, often honest.

RuleLevelLooks atWhat it finds

Which files count as tests and gates

Tests:

Snapshots:

Gates (CI and test configuration):

Add your own with tests <pattern> and gate <pattern> lines in the scope. Patterns: ** any number of folders, * any characters within one name, ? one character.

Measured: how often it cries wolf, and whether it catches what it says

A checker that flags every honest change gets switched off. So before the rules were written, we fixed how they would be judged (CLAIMS.md, committed first): every commit that touches a test or CI file in our own public repositories, split by repository into a half the rules could be tuned on and a half held back and run once, after the code was frozen.

The sealed result: version 1, run once on the held-out half

Tuning halfHeld-out half

Planted weakenings, on real diffs

For each high rule, a weakening was planted into the held-out real diffs (one line, or one removed and one added line, with the hunk header adjusted) and the copy run through the kernel. A plant counts as caught when that rule fires on that file. The sealed target was every plant caught, for every rule.

RuleVersion 1 (sealed)Version 1.2 (this one)

Versions 1.1 and 1.2: the fixes for what version 1 missed

Version 1 missed planted weakenings for three reasons, all real: it treated a CI step as still testing when any command of the same runner stayed (so dropping one gated file from a list went unseen); it counted a check as "still exact" when any exact check on the same value was added (so a generic value like r.why hid a loosened one); and it judged a replaced assertion across the whole file (so an identical line elsewhere hid it). Version 1.1 fixes all three. Version 1.2 then stopped reading a marker inside a string literal as code: found when ScopeGuard checked its own first push, whose tests hold diffs as strings ('+it.skip("adds"...') and were flagged as skipped tests. Because the held-out half had already been read, these versions' figures on it are a re-run, not a held-out result.

Tuning halfHeld-out half (re-run)

What the high findings on the held-out half were (version 1.2, a re-run)

Each was read by hand and labelled: a real weakening (a catch, not a false alarm), a false alarm, or a file the checker cannot read (git stores it as binary, so it says so instead of passing it).

Repository · commitRuleFileLabelWhy

Re-run any number on this page: every record names a public repository, a commit and the SHA-256 of the diff the kernel read. git show --format= --no-color --no-ext-diff -M <commit> | node cli.mjs - --json gives the same findings. The tools are in tools/.

What it can't tell you

Put it to work

In CI, on every pull request (GitHub Actions)

name: scopeguard
on: [pull_request]
jobs:
  scopeguard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: sjgant80-hub/kar-scopeguard@main   # pin to a commit SHA in production
        with:
          fail-on: high        # or: review

The scope file (.scopeguard in the repository root) is read from the base commit, not from the pull request, so a change cannot widen its own scope. The findings go to the job summary.

As a Claude Code hook: the agent cannot finish with a weakened test

Claude Code runs "Stop" hooks when the agent is about to end its turn. When a Stop hook exits with code 2, the agent is not allowed to stop and is shown the hook's message as the reason. ScopeGuard's hook checks the working tree against the last commit. On a high finding it stops the agent once, lists the lines, and asks it to fix the code instead of the check, or to explain an honest change in its final message. It never stops the agent twice for the same findings, so it cannot trap it in a loop. Review findings never stop it. Put this in .claude/settings.json:

{
  "hooks": {
    "Stop": [
      { "hooks": [ { "type": "command", "command": "node /path/to/kar-scopeguard/cli.mjs --hook" } ] }
    ]
  }
}

Before each commit

node /path/to/kar-scopeguard/cli.mjs --git --staged

Put that line in .git/hooks/pre-commit. It checks what is staged and exits 2 on a high finding, which stops the commit.

On the command line

git diff main...HEAD | node cli.mjs - --scope .scopeguard
node cli.mjs change.diff --claim summary.txt --json
node cli.mjs --git            # this folder against its last commit, new files included

Exit codes: 0 clean (and review, unless --fail-on review), 2 flagged, 1 the input could not be read or the options were wrong. Node.js 20 or later; nothing to install.

Blueprint

Each part, what it does and how it is checked. A mutation gate changes the code on purpose (flips a comparison, swaps && for ||) and reruns the tests: if the tests still pass, they were not really checking that line. Every part below is gated on every change, in public, on GitHub.

PartWhat it doesGate

For your business

AI coding agents are now writing a large share of the changes many teams merge. They are rewarded for one thing: the tests going green. When a test is hard to pass, the cheapest way to green is often to change the test, not the code. A reviewer reading a large AI change can miss one .skip or one toBeDefined() among hundreds of lines. ScopeGuard reads every line, every time, and puts those lines at the top.

CTO and engineering leads

A green build from an AI agent becomes something you can trust: weakened tests and widened scope are caught before merge, not found in an incident review. The same rules run in CI and in the agent's own loop.

CISO and information security

Scope files turn "the agent may only touch these paths" into a check that runs on every change, read from the base commit. Changes to CI and test configuration (the controls themselves) are always surfaced. No code leaves your machines.

CFO

Review time is the cost of using AI agents safely. This puts the lines that need a human first, so the rest of the review goes faster. The cost case below counts that time at the UK median wage.

COO and delivery

Fewer escaped defects from "it passed CI" changes, and a written record (the fingerprint) of what was checked on each change.

Chief executive and the board

Evidence that AI-written code is governed by a control, not by hope, and a control anyone can rerun and get the same answer.

The engineers

No new tool to log into. It is a CI step and a hook. When it flags an honest change, a sentence in the pull request explains it.

Against what you pay now

Today this check is done, when it is done, by a human reviewer reading the whole diff. AI code-review services read changes too, usually sold as a subscription for each developer, and judge them with a model, so the same change can get a different answer on a different day. ScopeGuard is MIT-licensed with no licence fee, gives the same answer every time, and runs on your own machines. If it replaces a tool you pay for, enter that tool's monthly cost in the case below and it is counted. We do not quote other vendors' prices; yours are the ones that matter.

Cost case

The inputs are yours; change them. Staff time is costed at the UK median hourly wage with on-costs left out, so the figure is a floor (an engineer costs more). It rises each year with UK inflation. Both figures are from the Office for National Statistics and listed under the table.

Working it out…

"By hand" means a reviewer going through the diff for test, CI and scope changes specifically. The 10-minute default is our assumption; use your own. The share is below 1 because flagged lines still need a human to read them.

Security, compliance and data protection

Nothing leaves the page, and the browser enforces it. The page carries a Content-Security-Policy with connect-src 'none': it cannot open a connection to any site, its own included, so even a changed copy of the code could not send your diff anywhere. The check itself needs no connection: you paste or drop the change in, and the kernel runs inside this tab. It loads only its own files. Check it yourself: open your browser's developer tools, Network tab, paste a change and press Check it. No request is made.

Where is the code processed?
Only in the browser tab, or on the machine that runs the command line (your laptop, your CI runner). No server of ours is involved. GitHub Pages serves the page's files and never sees what is pasted.
How long is anything kept?
On the page: not at all. No cookies, no local storage, nothing written to disk. The hook writes one line to your repository's .git folder: the fingerprint of the last findings it stopped on, so it never stops twice for the same ones.
Is an AI model involved?
No. The verdict comes from fixed rules in code you can read. The same input gives the same output on any machine, which is what the fingerprints prove.
Supply chain?
No package dependencies. The page, the kernel and the command line are plain JavaScript files you can read. In CI, pin the Action to a commit SHA rather than a branch, as you would any Action.
Can it run with no internet?
Yes. Copy the repository; the command line and the page both work offline.
Who is the data processor?
Nobody: no data reaches AI Native Solutions, GitHub or anyone else when you use the page or the command line. You stay the controller of your own code.
Can a change get past it by editing the scope?
In CI and in the hook, the scope is read from the committed version, not the change being checked. A change to .scopeguard itself is a high finding.

Roll-out

  1. Day one: paste last week's three largest AI-made changes into this page. Read what it flags.
  2. Week one: add the Action to one repository with fail-on: high. Read the job summaries.
  3. Week two: add a .scopeguard file to repositories where agents work on bounded tasks. Turn on the Claude Code hook for the agents.
  4. Month one: make the ScopeGuard step a required check. Ask for one sentence in the pull request for every honest high finding.

Support and ownership

Supplied by AI Native Solutions; start through that site. Support, any service level, warranty and liability are agreed per deployment, in each deployment's agreement. The software is MIT-licensed and keeps running without us: you own your copy.

Risks, answered straight

What if it flags honest changes?
It will sometimes. The measured rate is in Measured. A false flag costs a reviewer the time to read the named lines and a sentence of explanation.
What if it misses a weakening?
It can: see What it can't tell you. It is one control. Mutation testing, which checks whether the tests can fail at all, is the natural partner.
Can an agent learn to get round it?
An agent that reads this page could choose weakenings with no rule. That is why the rules are a closed, published list and the verdict is "read these lines", not "this change is safe". Clean means no listed rule fired, nothing more.
Can I trust the code?
Read it: the kernel is one file, and every rule has a test with an example that must fire and one that must not. A mutation gate checks the tests on every change. The first version's rules were tuned on half of our history and still had to pass the held-out half.
Who is accountable for a merge?
Your reviewers. ScopeGuard points; people decide.

The case for the board

AI agents write code faster than people can review it. The specific way that goes wrong is quiet: the agent makes the checks pass by weakening the checks. That failure leaves no trace in a green build. ScopeGuard is a fixed, published control that finds it on every change, costs no licence fee, sends nothing outside the company, and gives an answer anyone can rerun. Its false-alarm rate on honest changes is measured and published, not promised.

The explainer

The problem. A coding agent is trained and prompted to finish tasks, and a task is "finished" when the tests pass. Tests are code, and the agent can edit code. So there are two ways to green: fix the program, or change the test. Agents take the second way often enough that people who supervise them have learnt to look for it, and published evaluations of coding agents have caught it many times: tests skipped, assertions deleted, expected values rewritten to match wrong output, CI told to ignore a failing step.

Why a reviewer misses it. The weakening is usually one line in a large change, and it reads as plausible: toBeDefined() looks like a test. A reviewer looks at what the change does, not at what it stopped checking.

What ScopeGuard does. It reads only the diff, so it works on any change from any agent or person, before anything runs. It sorts each file into test, snapshot, CI/test configuration ("gate") or ordinary code, and checks the path against an optional scope. Then it runs a closed list of rules: markers that stop tests running, assertions turned into comments or into checks that can never fail, exact checks replaced by looser ones on the same value, tolerances widened, coverage floors lowered, test commands removed, failures ignored, test files deleted or renamed out of the runner's reach. Each finding carries its line. A diff it cannot fully read (cut off, combined merge, a binary test file) is refused or flagged, never passed.

Why no AI judge. A model judging a change gives a different answer on a different day and can be talked round by the change itself (a comment saying "this skip is fine"). A fixed rule does neither. The fingerprints (SHA-256 of the exact input and of the result) let anyone confirm, later, that a given change got a given verdict.

How it was checked. The claims were written and committed before the code. The rules were tuned on half of our repositories' history and then run, once, on the other half. Each held-out high finding was read and labelled. Weakenings were planted into real diffs to measure whether each rule fires on real-world diff shapes. Every part is mutation-gated: each file's tests must kill every mutant the gate makes, with none set aside. The counts are in the blueprint, read from receipts/witness.json. All of it is on this page and in the repository.

Words on this page

Diff
The text that shows what a change added (lines starting +) and removed (-). git diff prints one.
Hunk
One block of a diff, starting with @@ -10,4 +10,5 @@: where the block starts and how many lines it has on each side. ScopeGuard checks those counts; a diff whose counts don't add up was cut off or edited, and is refused.
Assertion
The line in a test that checks a result, such as expect(total).toBe(24) or assert total == 24. Remove it and the test checks nothing.
Exact and loose checks
toBe(24) passes for 24 only. toBeDefined() passes for 24, 0, or a wrong answer. Swapping the first for the second makes a test easier to pass without making the code more right.
Gate file
A file that decides whether a change is accepted: CI workflows, test runner and coverage settings, compiler strictness settings, a mutation-test baseline.
Scope
The files a task is allowed to touch, written as patterns in a .scopeguard file.
Mutation gate
A check on the tests themselves: it changes the code on purpose and expects the tests to fail. If they still pass, they were not really testing that line. Every part of ScopeGuard passes one.
Fingerprint (SHA-256)
A 64-character code computed from exact bytes. Change one character and it changes completely. The same diff always gives the same fingerprint, so a saved result can be checked later.
Held-out data
Data kept aside while the rules were written and run once afterwards, so the rules could not be fitted to it. Later versions re-run on the same data are labelled as re-runs.
Stop hook
A command Claude Code runs when its agent is about to finish a turn. If the command exits with code 2, the agent keeps working and sees the command's message.

FAQ

Does it only work on changes made by AI?

No. It reads any diff. People weaken tests too, usually under deadline pressure. It was built for AI agents because they make many changes, fast, and are rewarded for green.

Why are some findings "review" and not "high"?

Because on honest changes they are common. An expected value changes whenever a specification changes, and a mutation baseline grows when a survivor is accepted with a reason. They are listed so a reviewer can read them, but by default they do not fail the build. --fail-on review makes them fail it.

What does the fingerprint prove?

That this exact diff, scope and summary gave this exact result. Run the command line on the same input and you get the same two fingerprints. It does not prove the change is good; it proves what was checked and what was found.

A test was skipped for a good reason. What do I do?

Say why in the pull request. The finding is a request to read the line, not a block on the change. In the hook, the agent is asked to explain it in its final message and is not stopped again for the same finding.

Can I add my own rules?

The kernel is one MIT-licensed file; add a rule with a test that fires and one that does not, and run the mutation gate. Rules are deliberately a closed list in code, not a configuration file, so a change cannot turn a rule off.

Does it support GitLab, Bitbucket or other CI?

Yes, through the command line: git diff "$BASE"...HEAD | node cli.mjs -. Exit code 2 fails the job. The GitHub Action is a convenience around that line.

Why does it read only one line at a time?

Because a diff is lines, and a rule that reads one line is simple enough to test completely. The cost: an assertion split over several lines is seen through its first line only. That is written down above as a limit.