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:

bash
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:

AreaWhat to checkRed flag
SecretsRepository history for keys, .env files in gitLive keys in any commit, ever
Access controlEvery API route checks the user and their permission on the serverChecks only in the front end
Data separationEvery query is scoped to the right customerRecords readable by changing an ID in the URL
AuthenticationLibrary or provider used, password storage, session handlingHome-made password hashing
Input handlingQueries parameterised, uploads validatedSQL built from strings
DependenciesKnown vulnerabilities, abandoned packagesPackages 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:

bash
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:

  1. Risks, ranked. Each finding with its severity, what could happen, and the fix. Security and data-loss risks first.
  2. Quick wins. Fixes that take hours and reduce risk: rotating keys, adding error tracking, a working README, a tested backup.
  3. 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?

Questions

Frequently asked.

How long does a codebase audit take?

For a typical web app or SaaS MVP, three to ten working days, depending on size, documentation and how cooperative the previous team is. Getting it to run is often the longest part. An audit that takes more than two weeks is usually turning into a rewrite plan; keep the first one short and specific.

What if the previous developer will not hand over access?

Start with what you control: the domain registrar, the payment provider and any cloud account in the company's name. If the code repository or hosting is in the developer's personal account, check your contract for ownership and handover terms. Without access to the code, the options narrow to negotiation, legal advice or a rebuild, so talk to a lawyer early.

Should we rewrite it instead?

Decide after the audit, not before. Most inherited codebases are better than their reputation, and a rewrite resets years of fixes. Rewrite only when the platform is unsupported, the design no longer fits the product, or the code is small enough that rebuilding is a few weeks. Otherwise, stabilise and improve in place.

Sohail Hussain

Founder, MSH Technologies

Sohail has designed and built websites, web apps and AI products for over 12 years, for clients from Singapore-based industrial groups to early-stage SaaS startups. He writes about what actually worked.

Keep reading

Related guides.

All posts

Your next move

Like what you see? Tell us about it.

A process that takes too long, a website that undersells you, or an idea ready to take shape. Tell us where you are and we will suggest a useful next step.

India · Working with clients worldwide

Sohail, Founder, replies within 1 working day (Mon–Sat, IST). Free and no obligation.