Skip to content
← Back to blog

How we audit an AI-generated codebase

A walk through what actually happens when we sit down with an AI-built repo. What we look at, what we look for, and what the output looks like.

When a team reaches out to us, it usually starts the same way: “We built this with AI, it works, but we’re not sure what’s in there.”

Fair enough. Neither are we, until we look. Here’s what that looks like in practice.

We start by reading

Not skimming. Not running a linter and calling it a day. We clone the repo and actually read it - the way an engineer joining your team would, except we’re specifically looking for the patterns that AI-generated code tends to produce. The same patterns are written up as the five signs your AI codebase is becoming a liability, if you want to check your own repo first.

This takes time. Depending on the size of the codebase, it takes three to five working days, longer for a large one. There’s no shortcut for this part. Automated tools catch syntax issues. They don’t catch “this entire module exists because someone prompted the AI twice for the same thing.”

Dependency analysis

We map out what your project actually depends on and whether those dependencies make sense.

AI tends to install packages liberally. Need to format a date? Here’s a library. Need to merge objects? Here’s another library. Six months later, your requirements.txt or go.mod lists dozens of packages, and the Terraform pulls in community modules nobody pinned. You’re using 10% of what any of it offers.

We look at:

  • Direct vs. transitive dependencies - what did you choose vs. what came along for the ride?
  • Redundant packages - are there three libraries doing the same job?
  • Outdated or unmaintained dependencies - is anything a security risk?
  • Size impact - what’s actually contributing to your bundle?

Architecture review

This is where we zoom out. Not individual functions or files, but the overall shape of the system.

  • Where are the boundaries? Does the codebase have clear modules, or is everything tangled together?
  • How does data flow? Can you trace a request from entry point to response without getting lost?
  • What patterns are in use? More importantly: is it the same pattern, or did the AI use three different approaches for the same type of problem?
  • What’s the coupling situation? If you need to change module A, how many other modules break?

AI-generated code frequently has what we call “accidental architecture.” The structure exists because of the order prompts were given, not because someone designed it. This isn’t always bad - sometimes the AI stumbles into a reasonable structure. But usually there are seams in weird places and coupling that shouldn’t exist. That is the pattern we explain at length in why AI writes code but never makes the decisions.

Dead code scan

We look for:

  • Functions that are never called
  • Components that are never rendered
  • Files that nothing imports
  • Routes that nothing links to
  • Environment variables that nothing reads
  • Feature flags that were never cleaned up

This is more than running a tool. Static analysis catches some of it, but AI-generated dead code is sneaky. Sometimes a module looks alive because another dead module imports it. You have to follow the chains.

Test assessment

If tests exist (and sometimes they don’t), we evaluate them honestly:

  • Do they test behavior or implementation? If every test breaks when you refactor, they’re testing the wrong thing.
  • What’s the actual coverage? Not line coverage - meaningful coverage. Are the critical paths tested?
  • Are there tests that always pass? This sounds good but it’s a red flag. If a test can never fail, it’s not verifying anything.
  • Are there tests that are flaky? Intermittent failures erode confidence in the entire suite.

Security check

This is a check, not a security audit. We don’t do penetration testing or compliance work, and the report says so. What we do look for is the short list of things AI-generated code gets wrong again and again:

  • Hardcoded secrets in the codebase
  • Missing input validation
  • Authentication/authorization gaps
  • SQL injection or XSS vulnerabilities
  • Overly permissive CORS or API configurations

AI works one prompt at a time, and security is a property of the whole system. It secures whatever you ask it to secure and ignores everything else. This creates gaps that are easy to miss if you’re not looking for them.

If something we find suggests a deeper problem, we say that plainly and recommend a proper security review. A cleaned-up codebase is also a much cheaper one to pen-test.

The output

You get a report. Not a 50-page PDF that nobody reads - a clear, prioritized document that answers three questions:

  1. What’s actually wrong? Specific issues, ranked by severity and risk.
  2. What should you fix first? A practical prioritization based on impact and effort.
  3. What’s the plan? Concrete next steps, whether you handle them yourself or want us to help.

We also flag what’s working well. Not everything AI generates is bad. Some of it is fine, some of it is even good. The point isn’t to throw everything away - it’s to know what you’re working with.


How long does it take?

Depends on the codebase. A small project (a few thousand lines) might take 2-3 days. A larger one (50k+ lines, multiple services) might take a week or two.

Past that, we don’t pretend to read everything at once. Tooling maps the whole codebase, we agree with you which services carry the most risk, and we read those closely first. Findings arrive in batches, and the report says which parts we read line by line and which we only mapped.

We’re not in a rush. The whole point is to be thorough enough that you can make good decisions about what happens next.

If that sounds useful, reach out. We’ll have a look.

If you would rather start on your own, the AI codebase health checklist turns the same areas into twelve checks you can run yourself.

If you want to see what the report itself looks like first, the sample audit shows the twelve checks, five findings in the delivered format, and how they get ranked.