Guide / Before you commit
AI code review before you commit or open a pull request.
Pre-commit as a point in your workflow, not a hook.
Yes, you can review a change with AI before it reaches a pull request, and it is the cheapest place to find a bug: the author still has the context, and no reviewer's time has been spent. Run the review when the change is finished, on your machine, against the working tree or the branch.
Pre-commit
here means that point in the workflow. It does not mean a
Git pre-commit hook. A review that writes and runs tests takes minutes and
costs model calls. A hook runs on every commit and should finish in seconds.
Why not a Git pre-commit hook?
- Time. Hooks block the commit. Linters and formatters fit. A review that builds an environment and runs generated tests several times does not.
- Cost. Every commit would spend model tokens, including the ones you amend five times.
- Judgement. A finding needs a person to decide whether it is real. A hook can only pass or fail.
-
Bypass. Slow hooks get skipped with
--no-verify, and then they check nothing.
What does fit a hook or a CI job is rerunning tests you already accepted. That makes no model calls. See below.
What gets reviewed
With arnx, arnx review looks at what a pull request would show:
- On a branch: every commit since it left the default branch, plus uncommitted work in tracked files.
- On the default branch: tracked uncommitted work, or the last commit when the tree is clean.
- Any span:
arnx review --range A..B.
Uncommitted work means tracked files: staged and unstaged changes, and new
files once you git add them. Untracked files are left out, and
the review says how many. --untracked includes them. So you can
review before the commit exists. Staging is enough.
A change of documentation only is skipped with exit 0.
arnx review --docs reviews it anyway. Lockfiles and generated
files do not count toward the 200 KB limit and are not in the diff sent to
models.
A workflow that fits before the commit
git add path/to/new_file.py
arnx review
arnx triage
arnx accept
arnx prompt
# fix the code, or hand the prompt to your agent
arnx check
git commit
- Review once per finished change, not per edit. The first review in a repository also sets up the projects the change touches, in at most 10 minutes.
- Triage while the change is fresh. You know what you meant the code to do, which is the one thing the tool cannot know.
-
Commit the fix together with
.arnx/tests/and.arnx/accepted-tests.json. Reviewers of the pull request then see the bug's test next to its fix.
The pull request still gets its normal review, by people or by a PR-based tool. The two do different jobs. See arnx and CodeRabbit and arnx and Greptile.
The cheap step: arnx check, locally and in CI
arnx check runs the accepted tests in Docker, in a throwaway copy
of the repository, with no model calls. That makes it the step to repeat:
after each fix, before each push, and in CI if your runner has Docker.
| Exit | Meaning |
|---|---|
| 0 | All accepted tests pass |
| 1 | Some accepted tests fail |
| 2 | Some tests did not report, are unproven or were not run |
| 3 | Nothing accepted yet |
| 4 | An accepted test changed since accept; nothing ran |
Commit .arnx/config.toml, .arnx/review.yaml and
.arnx/baseline.json so teammates and CI reuse the environment
that was proven on your machine. If you gate CI on
arnx review instead, read result in
arnx review --json: exit 0 does not mean no findings. Confirmed
findings are reported and do not fail the run. Exit 1 means a finding the
second opinion could not check, 2 incomplete, 3 setup needed.
Limits and trade-offs
- A review before the commit adds minutes to finishing a change. For a one-line fix it may not be worth it.
-
Each review stops writing tests at
review_usd, $3.00 by default. On the small checkout demo, one observed first review took 29 seconds and $0.03 to set up and 42 seconds and $0.10 to review. Larger changes cost more; our own ranged from $0.17 to $3.19. - A passing check covers only the accepted tests. It is not a claim about the rest of the change.
- Finding nothing is weak evidence. The review lists changed code no test reached. Read that list. See what a failing test does and does not show.
- The diff, the files the reviewer reads and test output go to your model providers or arnx Cloud. See data and execution boundaries.
Try it: install arnx, or run the
checkout demo, where
the discount-codes branch is a ready-made unmerged change. Costs
are covered in the quickstart.
Last reviewed 2026-11-12 against arnx 0.1.11. The release documentation is canonical for your installed version.