Search Sreeni's Insights

Filter by content type
ai crafting July 22, 2026 4 min read

I Shipped a Feature That Didn't Match Our Codebase

AI assistants write code that looks like it belongs, but they work from context we never gave them. That invisible gap between what the model assumed and what our codebase does is context debt, the second of seven AI debts.

Share:

I Shipped a Feature That Didn’t Match Our Codebase

AI Debt 2/7 - I Shipped a Feature That Didn't Match Our Codebase. When the pattern fits the requirement but not the codebase.
AI Debt 2/7 - I Shipped a Feature That Didn't Match Our Codebase. When the pattern fits the requirement but not the codebase.

When the code works but doesn’t look like anything else in the repo.


TL;DR: AI assistants are brilliant at writing code that looks like it belongs — but they’re working from context we never explicitly gave them. That invisible gap between “what the model assumed” and “what our codebase actually does” is context debt, and it shows up the day someone else has to touch the code.


A teammate pinged me on Teams: “Hey, this function we merged last month — is it intentional that it retries 3 times with exponential backoff? We don’t do that anywhere else in the codebase.”

I opened the file. Stared at it.

I had no idea.

I mean, I wrote it — in the sense that I prompted it, reviewed the diff, and clicked merge. But the retry logic? The backoff curve? The three-attempt cap? I never asked for any of that.

The AI just… added it. Because somewhere in its training, “calling a flaky external API” implies “retry with backoff.” It pattern-matched on the world, not on our repo.

The Quiet Mismatch

Our codebase has conventions. Specific ones.

  • We use a central RetryPolicy wrapper. Always.
  • We never retry inside the business logic — retries live at the transport layer.
  • We log every retry to a specific metric. Required for our SLA dashboards.

The AI-generated code did none of those things. It did the generally correct thing. Which is the specifically wrong thing for us.

And here’s the part that stings: the code worked. Tests passed. Code review approved. Production was happy. The mismatch only surfaced when someone else tried to extend it and asked the question I should have asked at merge time.

Why It Happens

The model doesn’t know our repo. Not really.

It knows:

  • The 200-line file we pasted into the chat.
  • A vague summary of “we’re a Node.js backend.”
  • Whatever our IDE shoved into the context window — usually the current file and maybe a couple of imports.

It does not know:

  • Our team’s conventions.
  • The three internal libraries that already solve this problem.
  • The architectural decision we made last quarter about where retries live.
  • The post-mortem from six months ago that explicitly banned ad-hoc backoff loops.

So it fills the gaps with the average of the internet. Sometimes that average matches our codebase. Often it doesn’t. And every time it doesn’t, we’ve quietly accepted a foreign convention into our repo — usually without noticing.

The Compounding Part

One mismatch is a code review catch.

A steady drip of mismatches, merged month after month, across a whole team, each engineer prompting in isolation? That’s not a codebase anymore. That’s a museum of every default the model has ever had.

  • Three different retry patterns.
  • Two competing error-handling styles.
  • A logging convention that drifts file-by-file.
  • “Helper” utilities re-invented because the AI didn’t know utils/ already had one.

None of it is wrong. All of it is inconsistent. And inconsistency is the tax we pay forever.

What “Paying It Down” Looks Like

Context debt isn’t a prompt problem. It’s a context-supply problem. Fix the supply.

  • Repo-level context files. A CONVENTIONS.md, ARCHITECTURE.md, or .cursorrules / .github/copilot-instructions.md that the model reads every time. Stop relying on engineers to remember to paste them.
  • Point at existing code. “Use the pattern in src/transport/retry.ts” beats “add retries” every single time.
  • Ban defaults in review. If a PR introduces a pattern the codebase doesn’t already use, that’s a discussion — not a merge.
  • Index our own repo for the AI. Tools that actually search our codebase before generating (Cursor, Sourcegraph, Continue) close the gap that pure-chat workflows leave wide open.

The Real Lesson

The AI didn’t write bad code. It wrote generic code in a codebase that needed specific code.

And the gap between those two — the things our repo knows that the model doesn’t — is where context debt lives.

Every time we let the model fill in a blank we should have filled, we ship a small piece of someone else’s codebase into ours.

That’s debt number two of seven.

Related Posts