Skip to content
·8 min read

Why AI Writes Code That Works But Is Not Actually Good

How to recognize the gap between AI code that runs and AI code that is good, the four quality dimensions, and how to close the gap with prompts and review

Share

To recognize why AI writes code that "works" but is not actually good in 2026, understand that AI optimizes for "produces correct output" without optimizing for the four quality dimensions that matter long-term (readability, maintainability, performance characteristics, security posture), develop the habit of evaluating AI output against these dimensions before accepting, and use prompt patterns that explicitly request quality (not just correctness). The gap between "works" and "good" is what separates vibe-coded MVPs from production engineering, and closing the gap is increasingly the human's responsibility.

This piece walks through the four quality dimensions, why AI defaults to working over good, the prompt patterns that improve quality, and the four mistakes that come from accepting AI output as good when it is merely working.

Why "Works" Is Not "Good"

Code that works passes its tests and produces expected output for known inputs. Code that is good additionally handles edge cases gracefully, reads clearly to other developers, performs acceptably under load, and resists common security mistakes. The distinction matters because production systems need both, while AI-generated code routinely delivers only the first.

The 2026 reality is that AI training data is dominated by code that worked (otherwise it would not have been published) but not necessarily code that was good. AI inherits the patterns of average production code, which is "works most of the time" rather than "exemplary in all dimensions."

Key Takeaway

A 2025 Google research study analyzed 100,000 AI-generated code submissions across various tasks and found that 82 percent of submissions passed unit tests on first try while only 27 percent passed expert review for code quality (readability, maintainability, edge case handling, security). The "works" rate is high; the "good" rate is significantly lower. Closing this gap is increasingly the human's job in vibe coding workflows.

The pattern to copy is the way professional editing differs from spell-checking. Spell-checkers catch words that are wrong; editors catch sentences that are awkward, paragraphs that miss the point, and structures that confuse readers. AI is the spell-checker of code; expert review is the editor. Both are needed.

The Four Quality Dimensions That Matter

Four quality dimensions consistently differentiate "works" from "good" code. Each has specific patterns and antipatterns.

Dimension 1, readability. Can other developers understand the code without explanation? Clear naming, appropriate abstraction, comments where genuinely needed. AI defaults are mediocre.

Dimension 2, maintainability. Can the code be changed safely as requirements evolve? Loose coupling, clear boundaries, predictable patterns. AI rarely thinks about future change.

EXPLAINER DIAGRAM titled FOUR CODE QUALITY DIMENSIONS shown as a 2x2 grid of quadrants on a slate background. Top left blue READABILITY sublabel CAN OTHERS UNDERSTAND. Top right green MAINTAINABILITY sublabel SAFE TO CHANGE LATER. Bottom left orange PERFORMANCE sublabel UNDER LOAD AND SCALE. Bottom right purple SECURITY sublabel RESISTS COMMON ATTACKS. Center label reads ALL FOUR SEPARATE WORKS FROM GOOD. Footer reads AI DEFAULTS WORKS NOT GOOD.
Four code quality dimensions that separate working code from good code. AI defaults toward working; humans need to push for good across all four.

Dimension 3, performance. Does the code work at scale, under load, on slower devices? Algorithmic efficiency, query patterns, caching. AI generates correct algorithms; rarely the most efficient ones.

Dimension 4, security. Does the code resist common attacks (injection, XSS, auth bypass, data exposure)? AI sometimes generates code with subtle security issues; reviews catch most.

Why AI Defaults to Working Over Good

Three structural reasons explain why AI consistently delivers "works" rather than "good." Understanding the reasons helps you compensate.

Reason 1, training data is biased toward common patterns. AI sees a lot of average production code. Average code is "works mostly" rather than "exemplary." AI's defaults reflect this average.

Push AI output from works to good

Browse more code quality guides

Read more foundations articles

Reason 2, prompts usually optimize for correctness. Most prompts say "make this work" without specifying quality dimensions. AI delivers what was asked. Adding quality dimensions to prompts shifts the output dramatically.

Reason 3, evaluating quality requires holding the whole system in mind. AI generates code one piece at a time without seeing the system as a whole. Quality dimensions like maintainability emerge from system-level thinking.

The Prompt Patterns That Improve Quality

Three prompt patterns consistently shift AI output from working to good.

EXPLAINER DIAGRAM titled THREE PROMPT PATTERNS THAT IMPROVE QUALITY shown as a vertical numbered list on a slate background. Three rows. Row 1 blue badge SPECIFY QUALITY DIMENSIONS sublabel READABILITY EFFICIENCY SECURITY. Row 2 green badge ASK FOR ALTERNATIVES sublabel COMPARE APPROACHES. Row 3 orange badge REQUEST SELF CRITIQUE sublabel WHAT MIGHT GO WRONG. Footer reads PROMPTS SHAPE OUTPUT QUALITY.
Three prompt patterns that consistently improve AI output quality. Together they shift AI from delivering 'works' to delivering 'good' on quality dimensions.

Pattern 1, specify quality dimensions. "Generate this function. Optimize for readability and edge case handling. Include input validation." Explicit dimensions guide AI toward better defaults.

Pattern 2, ask for alternatives. "Show me three different approaches with trade-offs." Forces AI to consider multiple solutions; you pick the best fit.

Pattern 3, request self-critique. "What might go wrong with this code? What edge cases does it miss?" AI's self-critique often catches issues it would have missed otherwise.

How to Review AI Output Effectively

Three review patterns turn "review AI output" from a vague directive into actual practice.

Pattern A, read for the four dimensions explicitly. Go through the code with each dimension in mind. Note issues for each. Address before accepting.

Pattern B, run the code on edge case inputs. Empty inputs, very large inputs, unusual character sets, concurrent requests. AI rarely tests these proactively.

Pattern C, ask "would I write it this way." If the code is significantly different from how you would have written it, understand why. Often AI's choice is fine; sometimes it reveals a better pattern; occasionally it is worse than your default.

The combination of these patterns turns code review from rubber-stamping into actual quality control. Without explicit review patterns, "review" usually means "does it run."

Common Mistake

The most damaging mistake vibe coders make is treating AI output that runs as if it is finished. The "passes tests" check is necessary but not sufficient. Code that runs can still have security holes, performance problems, maintenance landmines, and readability issues. The fix is to consciously evaluate every AI output against the four dimensions before accepting it. The five extra minutes of review prevents the hours of debugging that follow when "works" code turns out to not actually be good. Make the review explicit, not implicit.

The other mistake is assuming AI quality has improved enough that the "works vs good" gap is closing. AI has improved dramatically at the "works" dimension; the "good" gap is narrower than in 2023 but still real in 2026. Continuing to apply human judgment on quality dimensions remains the difference between professional and amateur output.

How to Build Quality Evaluation Skill

Three patterns help build the skill of evaluating AI code against quality dimensions.

Pattern 1, study expert reviews. Read code reviews from senior engineers. The patterns of what they catch teach you what to look for.

Pattern 2, post-mortem your own bugs. When AI-generated code causes a bug, trace it back to which quality dimension was missed. The pattern reveals your blind spots.

Pattern 3, pair with someone who has the skill. Watch a senior developer review AI output. Their commentary teaches faster than any documentation.

The skill of quality evaluation is fundamentally pattern recognition built through deliberate exposure. Without exposure, the skill atrophies; with exposure, it sharpens over years.

When Good Code Matters Most

Different code in different contexts has different quality requirements. Three contexts demand the highest quality bar.

Context 1, code that handles money or sensitive data. Payment processing, authentication, personal data handling. Bugs here cost money or trust directly.

Context 2, code in critical paths used by everyone. The signup flow, the main product loop, the checkout. Bugs here affect every user.

Context 3, code that other developers will read for years. Core libraries, shared utilities, foundational patterns. Bugs here cost team velocity over time.

For these contexts, the "good" bar matters significantly more than the "works" bar. For prototype code, internal tools, or one-off scripts, "works" is often sufficient. Match the quality investment to the actual context.

What This Means For You

The "works vs good" distinction is one of the most important mental models for vibe coders in 2026. Understanding why AI defaults to working and how to push for good is increasingly central to producing professional output.

  • If you're a founder: Train your engineering team to evaluate AI output against the four dimensions explicitly. The discipline becomes culture.
  • If you're changing careers into engineering: Internalize the four quality dimensions early. They are what employers evaluate you on, not just whether your code runs.
  • If you're a student: Practice the prompt patterns and review patterns on every project. The habits compound across your career.
Push your AI output from works to good

Browse more code quality guides

Read more foundations articles
PJ
Pranay Joshi

20+ years building products at scale. VP of Product & Engineering, startup founder, and AI coach. Helping dreamers turn ideas into reality with vibe coding.

Written forStudents

The Tuesday Shipping Report

Every Tuesday, one focused email:

  • - The tool or technique that's actually working right now
  • - A real problem from the community (and how to solve it)
  • - What changed this week in the vibe coding landscape

Read by 1,000+ founders, developers, and creators building with AI. Free forever. No spam.