Table of Contents

7. AI‑Generated Code: When to Trust It, When to Rewrite It

AI drafts.
We decide what survives
.

AI can produce PHP quickly,
but not all output deserves to survive.
Some drafts are solid foundations
while others are better thrown away and rebuilt with clarity.

This page helps us develop the quiet judgment that tells us when to keep AI’s work
— and when to start over.


1. Trust AI When the Shape Is Right

AI’s code is trustworthy when:

If the structure feels coherent, we can refine the details.

Signal of trust:
We can describe the code in one or two sentences
without apologizing for it
.


2. Trust AI When It Uses Modern PHP With Purpose

AI is on the right track when modern features appear
but only because they express meaning,
not because they “look modern.”

Examples of good signals:

If the features match the architecture,
the draft is worth keeping
.


3. Trust AI When the Code Is Boring

This is one of the strongest signals.

Good AI‑generated code is:

If the code feels “boring in the right way,”
it’s usually safe
.


4. Rewrite When the Shape Is Wrong

If the architecture is off, don’t fix it
— replace it.

Rewrite when we see:

Trying to patch a bad shape
only makes it worse
.


5. Rewrite When AI Over‑Engineers

AI sometimes produces:

If the code feels ceremonial or noisy,
start over with a simpler request
.


6. Rewrite When AI Imports Patterns From Other Languages

AI often drifts into:

If the code feels foreign to PHP,
rewrite it with a clear constraint:

“Use PHP 8+ idioms only.
No patterns from other languages.”

7. Rewrite When the Code Is Hard to Explain

A simple test:

“Can I explain this code to another developer in one breath?”

If the answer is no, the architecture is wrong.

Rewrite from the top.


8. Rewrite When the Code Fights the Mental Model

Modern PHP has a quiet rhythm:

If AI’s draft breaks that rhythm,
it’s easier to start fresh than to salvage it.


9. Trust AI for Drafting, Not Designing

AI is excellent at:

AI is not excellent at:

Trust AI for speed.
Trust yourself for structure
.


Summary

Trust AI when:

Rewrite when:

AI drafts.
We decide what survives
.


This page describes common behaviors observed in AI models when generating PHP code.
These patterns are not guarantees, but they are consistent enough to be useful when reviewing or guiding AI output.