Why AI code is “almost right, but not quite”
AI coding tools are everywhere: 84% of developers in Stack Overflow's 2025 survey use them or plan to. But more of those developers distrust the accuracy of what the tools produce (46%) than trust it (33%), and their biggest frustration, named by 66%, is code that's “almost right, but not quite”. That gap is expensive, and hard to see from the inside. In a randomised trial by METR, experienced open-source developers took 19% longer to finish tasks when they used AI, while believing it had made them about 20% faster.
It isn't only about speed. Veracode tested more than 100 AI models and found they chose an insecure way of writing code 45% of the time. And GitClear's analysis of 211 million changed lines found that copy-pasted code now outstrips code that's been tidied up and reused, for the first time. The common thread is unchecked output: code produced quickly and accepted without enough scrutiny. This project flips that around. I wrote the code, used AI to scrutinise it, and checked every finding myself.
AI didn't write this game. It read it.
Most talk about AI and code is about writing more of it, faster. I think the more useful skill is the opposite: using AI to read code you already have, find what you missed, and fix it without losing what made it yours. The engineer's job moves from typing to judgement.
-
Build me
I designed and hand-coded the game: grid, obstacles, food, growth and auto-move.
-
Review AI
I asked Claude to check the logic. It traced each code path and reported 6 bugs, ranked by impact.
-
Decide me
I read the findings and chose what to fix, and kept Version 1's bugs in place for comparison.
-
Fix & test AI
It rewrote the game logic and tested it in a simulated browser, including 1,000 random games.
-
Own it me
I play it, check it and ship it. The judgement, and the result, are still mine.
Six bugs I'd never noticed
Every one of these is still in Version 1. Most hide in edge cases you'd only hit by luck, which is exactly why a second pair of eyes helps.
-
Game-breaking
The game could start already lost
Obstacles were placed at random, sometimes right in front of the snake. It crashed on the first move, restarted in the same spot and crashed again, forever. Roughly 1 in 30 page loads.
Obstacles keep clear of the start and the path ahead, and move on every restart.
-
Broken feature
The restart key never worked
The code had an Enter-to-restart handler, but the game restarted itself before you could ever press it, so that branch could never run.
Show the code
// On a crash alert('Game Over!'); restartGame(); // sets isGameActive = true // In the key handler if (!isGameActive && key === 'enter') { restartGame(); // never runs }A crash now pauses the game. Enter or Space starts a new one.
-
Wrong outcome
Winning ended in "Game Over"
Filling the board showed a congratulations message, but the game kept running, so the very next move crashed into the snake. You won and lost in the same second.
Winning stops the game.
-
Edge case
A URL could break the board
The board size comes from
?size=in the URL, with no checks. In Version 1,?size=1makes you "win" instantly, then lose, then win, forever. See it happen.Sizes are rounded and kept between 5 and 100. Try
?size=1in Version 2. -
Game feel
Quick turns were lost
Only one turn could wait for the next move. Press Up then Left quickly and Left was ignored, so tight turns felt unresponsive.
Up to 3 key presses are queued and each one counts.
-
Game rules
Chasing your tail was fatal
Moving into the square your tail was leaving counted as a crash, even though the tail moves out of the way on the same step.
Allowed now, as in most snake games, unless the snake is eating.
Under the hood: Version 1 redrew all 900 cells on every move. Version 2 updates only the cells that change, and uses fast lookups for collisions, so it stays smooth on boards of up to 10,000 cells.
Trust, but verify
- bugs fixed
- 6
- random games tested, with no instant crashes
- 1,000
- cells redrawn per move, down from 900
- ≤ 3
- Version 1 games that crashed on the very first move
- 1 in 31
Pick a version
Hand-built
The game as I wrote it, bugs and all. See whether you can find any of the six. (One change: the pop-up alerts are now on-screen messages.)
Play Version 1 Version 2 · human + AIAI-reviewed
Same idea, same look, after the review: fair starts, a working restart, sharper controls and faster rendering. Now with a score, and playable on phones.
Play Version 2Steer with the arrow keys. On a phone or tablet, Version 2 has swipe and on-screen controls; Version 1 needs a keyboard.
AI made this faster, but the parts that mattered were knowing what to ask, checking the answers, and deciding what to keep.