How to take over an existing codebase: the audit we run first
Taking over an app from another developer? Secure access first, get it running, map the system, check security and deploys, then write a risk-ranked plan.
By Sohail Hussain21 November 20266 min read
To take over an existing codebase safely, first secure access to everything in the company's name and rotate every secret, then get the app running from scratch, map how the system fits together, check dependencies, security, deployment and backups, read the code where risk concentrates, and write a short, risk-ranked report with a plan for the first month. Do not change features until that is done. The first job is to make sure nothing breaks, and that you could recover if it did.
We run this audit whenever a client brings us an app built by someone else, as part of our web app and SaaS development work. The steps below are the ones that matter most, in the order we do them.
Step 1: secure access and ownership
Before reading a line of code, make sure the company, not a person, controls every account the product depends on. Previous developers leave, and accounts in their personal names leave with them.
Collect and transfer:
- Code repositories, moved into an organisation the company owns. GitHub's repository transfer keeps history, issues and redirects.
- Hosting and cloud accounts, with billing on a company card.
- Domain registrar and DNS. Who owns your website covers why this one causes the most trouble.
- Database, including direct access and backup locations.
- Payment provider, email service, error tracking, analytics, app store accounts and every other third-party service.
Then rotate every secret the previous team could have known: API keys, database passwords, webhook signing secrets, OAuth client secrets. Do it carefully, one at a time, with the app watched after each change. It is tedious, and it is the only way to be sure the old access is gone.
Step 2: get it running locally and on staging
Clone the repository onto a clean machine and follow the README. Write down every step that is missing or wrong: environment variables nobody listed, a database seed that does not exist, a service that must be running. That list becomes the new README.
If the app cannot be run from scratch, that is the first finding, and fixing it comes before anything else. A codebase only one machine can run is one hardware failure from being lost.
Then set up a staging environment that mirrors production but uses its own database and test keys for payments and email. Every later fix is tested there first.
Step 3: map the system
Draw the parts and how they connect. For a typical web app: the front end, the API, the database, background jobs, scheduled tasks, file storage, and each external service. Note where each runs and how it is configured.
Then list the data model: the main tables or collections, their relationships, and roughly how many records each holds. And list every integration: what it does, which credentials it uses, and what happens when it fails. Scheduled jobs and webhooks are the parts most often missed, because nothing in the interface shows them.
Step 4: check dependencies and security
Start with what tools can find. In a Node.js project:
npm outdated
npm audit --omit=dev
The first shows how far behind each dependency is; the second lists known vulnerabilities in production dependencies, described in the npm audit documentation. Note the framework version especially. A framework several major versions behind is a planning item, not a quick fix.
Then check by hand:
| Area | What to check | Red flag |
|---|---|---|
| Secrets | Repository history for keys, .env files in git | Live keys in any commit, ever |
| Access control | Every API route checks the user and their permission on the server | Checks only in the front end |
| Data separation | Every query is scoped to the right customer | Records readable by changing an ID in the URL |
| Authentication | Library or provider used, password storage, session handling | Home-made password hashing |
| Input handling | Queries parameterised, uploads validated | SQL built from strings |
| Dependencies | Known vulnerabilities, abandoned packages | Packages with no release in years on critical paths |
Broken access control tops the OWASP Top 10, and in inherited apps it is the finding we see most. Test it directly: sign in as one user and try to read another's records through the API.
If .env files or other secrets are tracked in the repository, remove them, rotate what they contained, and add them to .gitignore. Our .gitignore generator builds a sensible starting file for your stack.
Step 5: check deployment, backups and monitoring
Find out exactly how code reaches production. Is there a pipeline, or does someone run commands from their laptop? Are there tests, and do they run before deploys? Can a bad release be rolled back in minutes?
Then backups. Do they exist, where are they stored, how old is the latest, and has anyone ever restored one? Restore one to staging during the audit. A backup that has never been restored is a hope, not a backup.
Finally, monitoring. Are errors tracked? Would anyone know if the site went down at night, or if payments stopped? If not, what to log and monitor from day one is the minimum to add before changing anything else.
Step 6: read the code where it matters
You cannot read everything, and you do not need to. Focus on two places.
The hotspots. Files changed most often are where future work will happen and where problems cost the most. Version control shows them:
git log --since="12 months ago" --name-only --format="" | grep -v '^$' | sort | uniq -c | sort -rn | head -20
The high-risk paths. Anything that handles money, permissions, personal data or deletes records. Read these line by line. Note missing tests, duplicated logic and places where errors are silently swallowed.
Everything else gets a skim for structure and consistency. Record what you find as a list of specific items, not impressions. Technical debt explains how to turn that list into a register you can plan from.
Step 7: write the audit and the first month's plan
Keep the report short enough to read in one sitting. Three sections:
- Risks, ranked. Each finding with its severity, what could happen, and the fix. Security and data-loss risks first.
- Quick wins. Fixes that take hours and reduce risk: rotating keys, adding error tracking, a working README, a tested backup.
- Larger work. Upgrades, missing tests, structural problems, each with a rough size.
Then agree a plan for the first thirty days: fix the critical risks, make deployment safe, add monitoring, and only then start on features. Most clients want features in week one. The ones who wait a month for stability ship faster for the rest of the year.
If you are on the other side, handing a product to a new team, how to hand over a website lists what to prepare. For ongoing work after the audit, a dedicated team often fits better than a project, and the pillar guide on how to build a SaaS product covers what comes next for the product itself.
Was this guide useful?