A quality gate for AI-generated code: block merges until the tests pass
Last updated: November 16, 2026
AI coding agents write a lot of code quickly, and they describe it with confidence. A quality gate is how you decide whether to believe them: a check that answers pass or blocked from evidence, the same way for every change, whoever or whatever wrote it. This page explains what a gate for AI-generated code should check, how to wire one into CI so it can stop a merge, and what it cannot do.
What the gate should check
- Every requirement has a named test. A request such as "signed-out visitors are sent to sign-in" is written as a commitment and linked to the exact test that shows it. A requirement with no test is reported as open, not skipped.
- The tests ran for this commit. Results from an earlier version of the code do not count for the new one.
- The results are passing. Failing and skipped tests are reported as they are.
- A person signs off what no test can judge. Whether a screen is clear, or a message reads well, needs a named human to sign off. The agent cannot sign off its own work.
Wiring it into CI
The AvowGate command line sends your test results for the commit and then asks for the verdict. The command exits 1 when the gate is blocked, so your CI job fails when the gate is blocked. Here is the shape of the job:
- run: echo "SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
- run: pytest --junitxml=junit.xml || true
- run: avowgate results ingest --product-id "$PRODUCT_ID" --junit junit.xml --commit-sha "$SHA"
- run: avowgate gate check --product-id "$PRODUCT_ID" --commit-sha "$SHA" --format markdown | tee -a "$GITHUB_STEP_SUMMARY"
Set AVOWGATE_BASE_URL and AVOWGATE_API_TOKEN as variables and secrets in your CI settings. AvowGate posts nothing to your repository and stores no repository
token: the job is yours, and so is the decision about what it blocks.
Making it block the merge
A failing job only blocks a merge if your repository requires it. In your repository's branch rules, make the gate job a required check. Until you do, the job
reports the problem but the merge button still works. Use --format json when a script needs the same answer.
What a gate does not do
- It does not read the code. It checks evidence against requirements. A requirement nobody wrote is not checked.
- It is only as strong as the tests. A weak test passes weak code. Ask for tests to be shown failing before the code exists.
- It does not replace review. It tells a reviewer what is proven and what is open, so the review can spend time on the open parts.
Giving the gate to your agent too
The same gate can be asked from inside an AI agent's own session, so the agent sees blocked before it tells you the work is done. An agent connects over MCP and works in this
order: at_task_start, at_commitment, at_report_results, at_check_gate, then at_task_close, which only succeeds when the gate passes.
The steps are on the page for agents and in the guide, and the reasoning is in
how to make an AI coding agent prove its work with tests. Sign-up is open and a read-only live demo is on the home page.
Questions and answers
What is a quality gate for AI-generated code?
A quality gate is a check that answers pass or blocked from evidence, not from the opinion of whoever wrote the code. For AI-generated code it means the change cannot count as done, or be merged, until the tests that cover what was asked for have passed on that exact commit.
Can a quality gate stop a merge?
Yes, when the check runs in your CI and you make that job a required check in your repository's branch rules. The AvowGate command exits 1 when the gate is blocked, so the job fails and the merge button stays unavailable. AvowGate itself posts nothing to your repository and stores no repository token.
Does a passing gate mean the code is good?
No. It means every requirement you wrote has a named test and the results for this commit are passing. The gate is only as strong as the requirements and tests behind it, and anything that only a person can judge needs a human to sign off.
How is this different from running my tests in CI?
A plain test run passes when the tests that exist pass, even if nothing tests what you asked for. A requirement-level gate also blocks when a requirement has no test, when its test did not run for this commit, or when a person's sign-off is still missing.