All posts

How to verify AI-written code before you merge it

Build a change-specific verification checklist and identify whether tests, review and QA evidence apply to the commit you will ship.

· CodePress

Verify AI-written code by starting with required behavior, inspecting the full diff, testing the effects that could break and independently reviewing evidence for the current commit. Passing generated tests alone does not establish that the requirement was understood or that an integration works. A reviewer needs to know what was checked, on which revision, in which environment and what remains unknown.

GitHub's review tutorial recommends checking functionality, project intent, quality and dependencies. It also calls out deleted or skipped tests and plausible-looking code that misses the requirement. Use that as a starting point, then select evidence for the actual change rather than repeating a generic checklist on every PR.

1. Translate the request into observable behavior

Replace “fix permissions” with a statement about who may do what to which resource. Define the allowed case, the denied case and the state that must remain unchanged after denial. Establish the intended response from the application's documented contract; a reviewer should not invent a status code solely to match the implementation.

For example: an account member may update their own saved report; another account may neither read nor change it; and the UI explains a denied operation without exposing report content. These are hypothetical requirements. A real owner must confirm the roles, resource relationships and expected behavior before they become acceptance criteria.

2. Inspect what changed, including the tests

Read the complete diff and its relevant callers. Check whether an authorization decision moved from the service to the UI, a query lost its account scope, or a dependency was added for a small change. Follow the affected path far enough to understand the boundary. A correct helper is insufficient if an endpoint bypasses it.

  • Explain unrelated files, generated artifacts, permission changes and configuration edits before accepting them.
  • Check that test edits preserve the intended behavior. Removing a failing assertion can make a suite green while hiding the defect.
  • Verify unfamiliar dependencies, licenses and APIs against their actual upstream sources.
  • Trace data reads and writes, including error paths, background work and external calls affected by the change.

3. Match evidence to each effect

Hypothetical authorization evidence matrix: the checks below are a proposed plan, not executed results. All rows begin as unperformed. Fill in artifact links and actual outcomes only after running the relevant checks.

Required effect Proposed evidence What it leaves open
Allowed request API check: owner updates their report; read back persisted value. Other roles and write paths.
Denied request API check: unauthorized role is denied; data stays unchanged. Unexamined permissions.
Cross-user boundary Two isolated accounts; account B targets A's report identifier. Other resources and bulk endpoints.
UI feedback Browser check: denial is readable and no protected content appears. Other devices and assistive technology.
Commit identity Report records full tested revision and PR head. Any subsequent edit.

A unit test can cover a permission predicate cheaply. An API test exercises the route and data boundary. A browser check proves that the displayed feedback and user interaction work together. Use each where its observation matters. A screenshot of an error does not establish server-side enforcement, and a passing API check does not establish keyboard usability.

For credential, tool-access or cloud-environment questions, inspect the vendor's stated controls and your own configuration. The CodePress security brief is a place to begin that assessment; this matrix is not a security audit or proof that every attack path was tested.

4. Make results inspectable

Record the exact command or reproducible interaction, working context, environment and fixture assumptions. Include the result and a link to the relevant output. Avoid exposing secret values or private customer data in a public PR. A named synthetic fixture is usually more useful to a reviewer than an unexplained screenshot from a populated account.

Proposed report fields — not a run result
Revision: full commit identifier
Environment: local or named test deployment
Criterion: observable behavior being checked
Method: actual command or browser interaction
Result: PASS / FAIL / BLOCKED / NOT RUN
Evidence: accessible artifact reference
Limits: behavior and integrations not checked
Next action: named owner and concrete step

Keep result meanings distinct. A failed assertion is a failure to investigate. A database that never started is a setup blocker. An unperformed check is unknown. None becomes a pass because the agent ran out of time. Code coverage describes exercised code; it cannot tell you whether an omitted requirement matters. A benchmark answers only the workload and conditions it actually measures.

5. Reconcile evidence when the branch changes

Suppose commit A passed the planned API checks, then commit B changes the account-scoping query to address a review comment. The old report proves something about A. Check the new diff, rerun the affected permission and persistence checks on B and update the report. Keep the earlier report as history with its original revision.

Even a small edit needs an explicit assessment of which evidence still applies. A documentation correction may leave runtime checks unaffected; a fixture, dependency or configuration edit may change their meaning. Record that assessment rather than silently attaching an old PASS to the new head. Review again when the repair changes the assumptions the reviewer relied on.

6. Give the reviewer a decision, with limits

Before merge, confirm that each acceptance criterion has evidence or an explicit gap, the report identifies the current head, findings have a resolution and someone owns the residual risk. Ask a reviewer who can challenge both the interpretation of the task and the relevance of the evidence. Independence provides another perspective; it does not guarantee correctness.

CodePress describes review and independent completion judgment that check current-head QA and call out missing coverage. Its Software Factory CLI page describes commit-specific evidence and a separate verdict before human review. These are stated workflow capabilities, not a claim that the example above was run or approved.

How do I review a pull request an AI wrote?

Review it in two passes. First confirm the machine checks: the build, the tests and static analysis have run on the current commit and are green. Then read the change as a reviewer, asking whether it solves the right problem, whether any test was deleted or skipped instead of fixed, and whether every new dependency is real, maintained and licensed compatibly. GitHub’s tutorial on reviewing AI-generated code recommends this order and also suggests automating style, security and coverage checks in CI so that the human pass can concentrate on intent. The numbered steps above turn those questions into evidence you can attach to the PR.

FAQ

What is the difference between verifying and reviewing AI-generated code?

Verifying produces evidence: checks run against a named commit in a named environment. Reviewing is a person judging the diff and the evidence. You need both, because a green check does not show that the right problem was solved and a careful read does not show that the code runs.

Are the tests an AI wrote enough to trust its code?

Not by themselves. Tests written by the same agent can encode its own misreading of the requirement, and a failing assertion can be removed to make a suite pass. Check the test changes in the diff and tie at least one check to the stated acceptance behavior.

What should I check first on an AI-generated pull request?

Confirm the automated build, tests and static analysis passed on the latest commit, then read the diff for unrelated files, deleted or skipped tests and new dependencies before reading the logic.

Is there a checklist for reviewing AI-generated code?

The six numbered sections above work as one: observable behavior, the whole diff including tests, evidence matched to each effect, an inspectable record, evidence reconciled to the current head, and a decision with limits. Adapt them to the change instead of applying the same list to every PR.

Does a QA report from an earlier commit still count?

Only for that commit. After a new push, check what the new diff touches and rerun the affected checks, as described in section 5.

Inspect the CLI delivery approach if you want to bring that evidence contract into an existing agent workflow. When review finds a defect, use the finding-to-repair runbook to keep the next fix and recheck connected.