Your AI-generated codebase is becoming a problem.
You shipped fast with AI. Now nobody on your team can explain why half the code exists. We're engineers who work with the same tools, and we clean that up.
- infra/
- ├── main.tf← everything, 1,200 lines
- ├── main_v2.tf← which one runs?
- ├── variables.tf← half of these unused
- ├── modules/
- │ ├── vpc/← network, take one
- │ ├── network/← take two
- │ ├── vpc-new/← take three
- │ └── s3_bucket/← wraps one resource
- ├── iam.tf← "*:*" on everything
- ├── envs/
- │ ├── prod.tfvars
- │ └── prod-copy.tfvars← the real prod?
- ├── providers.tf← no version pins
- └── terraform.tfstate← committed to git
- ansible/
- ├── site.yml← includes site-old.yml
- ├── site-old.yml← still in cron
- ├── inventory/
- │ ├── hosts← raw IPs, no groups
- │ └── hosts.bak← newer than hosts
- ├── roles/
- │ ├── nginx/← shell: apt-get install
- │ ├── nginx2/← same, plus one line
- │ └── common/← 40 tasks, no tags
- ├── group_vars/
- │ └── all.yml← db password, plaintext
- └── ansible.cfg← host key checks off
- app/
- ├── Dockerfile← FROM node:latest
- ├── Dockerfile.prod← 2.1 GB image
- ├── Dockerfile.final← what prod builds
- ├── docker-compose.yml← runs as root
- ├── docker-compose.prod.yml← 90% copy
- ├── .env← committed, has the keys
- ├── scripts/
- │ ├── entrypoint.sh← sleep 30 && hope
- │ └── wait-for-db.sh← sleep 60 && hope
- └── .dockerignore← missing, ships .git
- service/
- ├── main.go← 3,000 lines, one func
- ├── utils/
- │ ├── utils.go← helpers for helpers
- │ └── helpers.go← copy of utils.go
- ├── handlers/
- │ ├── user.go← _ = err, everywhere
- │ └── user_new.go← same route, twice
- ├── db/
- │ └── db.go← global *sql.DB, no ctx
- ├── vendor/← committed, 2 years old
- ├── go.mod← replace => ../local
- └── user_test.go← assert.True(true)
- aws/
- ├── cloudformation/← abandoned 2023
- ├── cdk/← started 2024, half done
- ├── clickops.txt← real source of truth
- ├── lambdas/
- │ ├── handler.py← not what runs
- │ └── handler-fixed.py← uploaded by hand
- ├── iam/
- │ └── ci-role.json← AdministratorAccess
- ├── s3/
- │ └── bucket-policy.json← Principal: "*"
- ├── sg-default.json← 22 open to 0.0.0.0/0
- └── .aws/credentials← committed, root user
- edge/
- ├── workers/
- │ ├── router.js← 900-line if/else
- │ └── router-v2.js← half the routes
- ├── wrangler.toml← API token inline
- ├── dns/
- │ └── zone-export.txt← managed by clicking
- ├── firewall/
- │ └── rules.json← 300 IPs, no comments
- ├── cache.ts← caches /api too
- ├── page-rules.md← "don't touch rule 7"
- └── tunnel.yml← points at a laptop
Here's the pattern we keep seeing
A team uses AI to build something fast. It works. They ship it. A few months later, someone needs to change something and realizes nobody actually understands the code.
Three different auth patterns. Unused dependencies everywhere. Tests that test nothing. A folder structure that makes sense to no one. The AI didn't plan any of this - it just kept generating whatever the next prompt asked for.
The codebase works. But it's fragile, confusing, and getting worse.
We use AI every day. We just don't let it make the decisions.
Coding agents, static analysis, dependency graphs, dead-code finders. We point all of it at your repo so mapping a messy codebase takes days, not weeks. Then an engineer decides what stays, what goes, and why, and writes that down.
When we leave, the codebase is ready for your AI tools too. Tests actually fail when something breaks, there is one way of doing each thing, and CI checks catch drift. Agent rules (like AGENTS.md) keep your assistants following the new structure instead of re-tangling it.
The goal isn't less AI. It's AI working on a codebase that can take it.
We have a process for this.
Four steps, in order. Nothing revolutionary - just solid engineering applied methodically.
Audit, then untangle, then refactor, then sustain.
If that is where you are, AI code cleanup covers what we do about it, how a project starts and where the price comes from.
Not sure yet? The AI codebase health checklist is twelve checks you can run yourself first, with no email required.
Sounds familiar?
Drop us a line. We'll have a look and tell you honestly what we think - no pitch, no deck, no "let's circle back."
Start a conversation