Gating AI-Generated Laravel Code with AST Scanning and PHPStanGating AI-Generated Laravel Code with AST Scanning and PHPStan
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
The biggest lie in AI-assisted software development: "If the prompt is good enough, the code quality will take care of itself." Anyone running AI coding agents in production knows the reality. AI writes code with insane speed, but it also writes with subtle "slop": • Unchecked nullable properties and loose types • Hidden N+1 Eloquent queries masked behind clean-looking syntax • Redundant boilerplate and swallowed exceptions • Code that compiles and passes surface tests, but decays the architecture over time Relying on another LLM to review an LLM is like asking a hallucinating student to grade their own exam. You don't solve probabilistic errors with more probabilistic guessing.
Here is how we tightened our AI feedback loop and eliminated AI code drift:
Catching AI quirks with heyosseus/sloppy: We integrated heyosseus/sloppy directly into our pre-commit hooks and agent toolchains. Because it is an AST-level scanner built specifically for Laravel & PHP to detect patterns left behind by coding agents, it intercepts anti-patterns, Eloquent traps, and code rot on the git diff—with zero token overhead and zero hallucination.
Turning PHPStan up to "Level 11": (Yes, Spinal Tap style.) We paired maxed-out PHPStan levels with bleedingEdge and strict rules. If an AI agent tries to be lazy with untyped arrays, implicit mixed, or sloppy generics, the static analyzer rejects the commit before a human reviewer ever sees the PR.
The Closed Loop: The agent writes ➔ sloppy & PHPStan immediately fail fast with exact line diagnostics ➔ the agent self-heals against the compiler errors ➔ only clean, robust code enters the PR.
The result? We kept 100% of the AI velocity without inheriting the technical debt.
Speed is a vanity metric if your team spends their Fridays untangling AI regressions. Build strict deterministic fences, and let the agents run wild inside them.
How is your team gating AI-generated code before review?
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started