DEV Community

Taras Hanych
Taras Hanych

Posted on

AI code verification for Laravel.

Claude Code, Cursor, Codex, Copilot or Gemini says the change is done. php artisan ai:verify checks whether it is.

It runs only the tests, Larastan, Pint and Laravel boot checks the diff actually needs. It fails the change if the agent deleted, skipped or weakened a test to get green. It returns one verdict the agent must act on: pass, fail or incomplete. One more command writes the instructions into AGENTS.md and CLAUDE.md. For Claude Code it also adds a Stop hook, so the agent cannot finish while verification fails. Verified commits get a trailer that CI can check.

Before the agent edits anything, php artisan ai:graph gives it a code graph of the Laravel app. It covers routes → controllers → form requests → models → tables → policies → views → tests, and events → listeners. It also does impact analysis: what a change affects and which tests cover it.

composer require --dev semitexa/laravel-ai-verify
php artisan ai:verify:install --hook

How it works: ai:verify reads what changed (uncommitted work, a git ref, or a file list). It works out the smallest set of checks that can vouch for that change and runs them with timeouts. The verdict comes as streamed NDJSON for agents, a JSON envelope or terminal text.

Top comments (4)

Collapse
 
kornatzky profile image
Yoram Kornatzky •

I used local Test Impact Analysis in Household Manager, while CI still ran the full suite. Mutation testing provided another check on whether the tests caught broken behaviour. Does ai:verify integrate mutation results into its verdict? My implementation notes: Household Manager

Collapse
 
syntaxwanderer_26 profile image
Taras Hanych •

Sorry for the very late answer. No, ai:verify has no mutation step. It runs the tests the diff needs plus static analysis, style and boot checks, and it fails on a deleted, skipped or weakened test. A test that was weak from its first line gets past that, which is what mutation testing would catch. In your notes mutation stays local while CI runs the full suite: would you let a surviving mutant block a commit, or is the score something you read and act on yourself?

Collapse
 
kornatzky profile image
Yoram Kornatzky •

Thanks, Taras. I would treat surviving mutants as something to inspect, not an automatic block. Some are equivalent changes; others expose a real gap in the assertions.

For a changed piece of business logic, a surviving mutant that exposes a missing requirement check would be a reason to strengthen the test before committing. I would not use the overall mutation score alone as the gate.

Keeping that local and targeted, while CI runs the full suite, seems a practical balance. Do you see mutation testing fitting as an optional check, with its result separate from the main pass/fail verdict?

Thread Thread
 
syntaxwanderer_26 profile image
Taras Hanych •

Yes, that's where I'd start: outside pass/fail, only on the changed lines, listing each surviving mutant instead of a score. The verdict already has a gaps list for checks it skipped, and survivors belong somewhere that visible. My worry is that an agent may treat anything that doesn't block as done, so a person should see that list too. In your experience, how many survivors turn out to be equivalent changes? That ratio decides whether people keep reading them.