Last year I shipped a feature with a search function that Claude wrote for me. It worked perfectly in staging. In production, with real data, it turned our 300ms page into a 12-second timeout.
The function was O(n²). I had accepted it without checking. Claude never mentioned it was quadratic.
The problem isn't that AI writes bad code
Modern AI coding assistants write code that works. That's actually the problem. When something runs without errors, your brain marks it as "done" — even if it's secretly going to fall apart at scale.
AI assistants are trained to produce code that satisfies your immediate request. They're not trained to proactively say "by the way, this is O(n²) and there's an O(n log n) version." That would require second-guessing your requirements, which most of the time you don't want.
So you get working code, no complexity disclosure, and a hidden assumption that you'll catch the performance issues yourself. Most of us don't.
Why the usual fixes don't stick
I've tried a few approaches:
"Just ask Claude/ChatGPT about complexity after." Works, but only if you remember to do it, only for code you're actively suspicious of. In practice I forget for 80% of snippets I accept.
"Review every snippet manually." I'm using AI to go faster. Manually reviewing every line for Big-O is slower than writing it myself.
"Run benchmarks." Great for functions you already know are suspect. Doesn't help with the ones you don't know to benchmark.
The issue is the friction. The check has to happen at the point of acceptance, not as a separate later step.
What I built
I made a Chrome extension — AI Code Explainer — that runs the analysis at exactly the moment you're reading a code block.
Hover over any code block on ChatGPT, Claude, or GitHub for 1.5 seconds. A panel drops in below the code showing:
- Algorithm name (e.g., "Binary search", "Depth-first traversal", "Sliding window")
- Time complexity (e.g., O(n log n))
- Space complexity (e.g., O(1) auxiliary)
- Alternative — if there's a meaningfully faster approach, it names it and sketches the idea
You bring your own API key (Claude, GPT-4o mini, Gemini 2.0 Flash, Groq, or DeepSeek — Groq's free tier works with no credit card). Nothing routes through a server I run. Free tier is 10 analyses/day; Pro is $5 one-time, no subscription.
The hover-trigger was a deliberate choice. A button you have to click is something you skip. A panel that appears while you're already reading the code intercepts you before you've scrolled away.
The checklist I use now
Even if you don't use the extension, here's what I check on every AI-generated snippet before accepting it:
What's the input size in production? If the function touches a list, how long is that list at max load? Quadratic is fine for 100 items. Catastrophic for 100,000.
Does it nest loops? Nested loops over the same collection are the most common source of accidental O(n²). Count them.
Is there a sort hiding inside a loop?
list.sort()inside aforloop = O(n² log n). AI does this more often than you'd expect.Does it rebuild a data structure per iteration? Converting a list to a set inside a loop is O(n) work per iteration. Should be done once before the loop.
Ask for the alternative. If you're not confident about complexity, ask the AI: "Is there a more efficient version of this? What would the time complexity be?" Most of the time it knows — it just didn't offer.
The extension automates steps 1-4 for me. Step 5 still needs a human question, but it at least gives you the vocabulary to ask it well.
One example that changed how I use AI for code
I was using Claude to write a deduplication function. It gave me something that iterated over a list and checked each element against a running list of seen items. Readable, obvious, correct.
The extension flagged it as O(n²) and suggested a set-based approach — iterate once, check membership in O(1), total O(n). Two-line change. Same logic, 1000x faster on large inputs.
I knew the set trick. I just hadn't thought to apply it because I was reading Claude's code, not writing my own. The check happened at the wrong time.
That's the whole product: make the check happen at the right time.
AI Code Explainer — Chrome extension, works on ChatGPT / Claude / GitHub, BYOK, $5 one-time.
Install: https://chromewebstore.google.com/detail/lcfaenfeajomoombkjcoelpjmmhknlid













