When to Reject AI-Generated Code Even If It Works

The Bottleneck Has Shifted from Implementation to Review

AI coding agents have accelerated the speed of implementation, but this has created a new bottleneck: the cognitive load of reviewing large volumes of generated code. When an agent completes a task, the resulting git diff can be overwhelming, especially if the developer has not personally thought through the architectural approach.

Engineering is not merely about making the CI green or ensuring code runs locally; it is about implementing adequate, scalable, and extensible solutions. Code that works but is not understood by the developer is a liability that increases technical debt.

Criteria for Rejecting Working AI Code

Functionality is the minimum requirement for any code to be merged, but it is not the sufficient condition for quality. AI-generated code should be rejected—even if it passes all tests—under the following conditions:

  • Lack of Conceptual Clarity: When the developer cannot explain the approach in their own words.
  • Disproportionate Complexity: When the diff is larger than the problem it intends to solve.
  • Premature Abstraction: When the AI introduces abstractions before they have been proven necessary.
  • Reduced Reasonability: When the code works locally but makes the overall system harder to reason about.
  • Over-reliance on Output: When the developer trusts the AI's output more than their own understanding of the system.

The Risk of "Vibe Coding" and Technical Debt

There is a growing tension between "vibe coding"—looping an LLM until the program appears to work—and rigorous software engineering. Relying on AI to standardize codebases toward "enterprise-level patterns" can lead to a uniform but shallow architecture that reflects average patterns rather than domain-specific expertise.

"Code that kills your project is code that works, and is either misunderstood or unmaintainable. And the industry is rushing towards it, whilst failing to train people who are able to fix it."

This risk is particularly acute when developers prioritize closing tickets over long-term maintenance. In environments without strong human review mechanisms, the accumulation of AI-generated technical debt can grow rapidly.

Strategies for Sustainable AI Integration

To leverage AI without sacrificing system integrity, engineers can adopt several structured workflows:

Plan-First Development

Reviewing a design plan before any code is written is significantly more efficient than reviewing a completed PR. One reported metric suggests that plan reviews average 0.7 hours compared to 16 hours for PR reviews. By approving a plan first, the developer maintains the mental model of the solution, making the final code review a check for "scope drift" rather than a struggle to understand the core logic.

Tiered Trust Based on Criticality

Not all code requires the same level of scrutiny. A tiered approach to trust can be applied based on the impact of the code:

  • Low Criticality: Analytical code, hobby projects, or temporary features can be handled via end-to-end AI implementation.
  • High Criticality: Production code affecting revenue or safety-critical systems (e.g., medical or aerospace software) requires deep human understanding of every line.

Multi-Agent Auditing

Some developers use multiple LLMs (e.g., Claude, GPT, and Gemini) to review each other's design plans and implementations. This adversarial approach can catch bugs or architectural flaws that a single model might miss, though it still requires a human to maintain the overall architecture documentation to ensure the agents have the correct context.

The Human Role in the AI Era

Coding agents are powerful tools, but they are not autonomous engineers. They require a skilled human to guide them toward great solutions. The difference between a failed first attempt and a successful second attempt with AI is often not the model used, but the developer's own consolidation of the problem. The most sustainable path is to treat the AI as a pair-programming partner—a "faster keyboard"—while the human remains the primary architect and guardian of the system's maintainability.

Sources