How to Take Over a Codebase Nobody on Your Team Wrote
If you inherit a legacy codebase that nobody on your team wrote, resist the urge to fix it right away. Use the first week to make it build and deploy from a clean machine. Next, let git history show you the handful of files where changes and defects pile up, lock down how they behave today with characterization tests, and only after that start shipping small changes that can be rolled back.
Last updated November 2026
Why is taking over a legacy codebase harder when nobody can hand it over?
Nearly all takeover advice takes a handover for granted. Consider the Thoughtworks account of taking over a 20-year-old payment gateway: more than 100 services and 300 repositories changed hands in about two months, with every incoming engineer paired with someone from the outgoing client team. The approach worked, and incidents dropped from 11 to 3 a month once the takeover was done. Still, it only works when people who already know the system can sit beside your engineers.
What we hear about more often is a takeover with nobody to pair with. Maybe the founding engineer walked out, or the agency relationship ended on bad terms. Maybe most of the code came out of Cursor, Claude Code, or Lovable, and whoever wrote the prompts has no idea why it works. Whatever the cause, the only knowledge left is in the code, the git log, and how production behaves.
This matters because reading code already takes up most of a developer’s time. In a field study by Xia and colleagues, “Measuring Program Comprehension,” published in IEEE Transactions on Software Engineering, researchers followed 78 professional developers across 3,148 working hours and found that 58% of their time went to program comprehension. Those developers had colleagues they could ask. With an orphaned codebase, comprehension fills nearly the entire first month, so budget for it rather than treating it as overhead.
What should you do in the first 30 days of a legacy codebase takeover?
Split the work into four phases, and give each one an exit criterion. Do not start a phase until the previous one has met its criterion, even when the business wants features now. We use the schedule below as a starting point for a small to mid-sized product. Larger systems need more time per phase, but the order stays the same.
| Days | Phase | Work | Exit criterion |
|---|---|---|---|
| 1 to 3 | Secure | Inventory every credential, domain, cloud account, and third-party service. Rotate anything a departed person could still use. Take a backup you have actually restored. | No live access held by anyone outside the current team |
| 4 to 7 | Reproduce | Build, test, and deploy from a clean machine using only what is written down. Write down every step that was missing. | A new engineer can deploy to staging from the README alone |
| 8 to 15 | Map | Draw the system context and containers. Rank files by change frequency and size from git history. List every scheduled job, queue, and webhook. | A one-page map and a ranked hotspot list |
| 16 to 25 | Pin | Write characterization tests around the top hotspots and the money, auth, and data-deletion paths. Add error tracking and basic dashboards. | Critical paths covered by tests that describe current behavior |
| 26 to 30 | Change | Ship small, reversible fixes. Decide what to fix, rewrite, or leave alone. | Three or more production deploys with a tested rollback |
How do you secure an inherited codebase before touching the code?
In a takeover, the first risk is usually access, not a bug. When an engineer or vendor leaves on bad terms, API keys, cloud root accounts, DNS registrar logins, and app store credentials are often locked inside one person’s password manager. Before anyone opens the code, write down every outside system the product relies on and confirm who controls each.
Next, scan both the repository and its history for secrets. Hardcoded keys and committed .env files are especially common in AI-generated code, since the assistant is tuned to produce something that runs on the first attempt. Treat anything you find in history as leaked and rotate it, even if it was removed from the current branch later.
How do you understand a legacy codebase you did not write?
Skip the top-to-bottom read. Let version control point you to the right places. Adam Tornhill’s hotspot analysis weighs how often a file changes against how big and complex it is. By his analysis, the top hotspots make up a small part of the code but are responsible for 25% to 70% of reported and resolved defects, and in open source projects the prioritized hotspots account for just 2% to 3% of total code size. If there is only time this month to understand 20 files in depth, make them those 20.
A sensible reading order:
- Use the product the way a customer would, from start to finish, covering signup, payment, and account deletion.
- Start with the data model. The tables and how they relate reveal what the business really does, whatever the code says.
- For every critical flow, follow a single request from the edge down to the database and back.
- Pull a ranked list of the most-changed files from the git log and start reading at the top.
- Watch for files that always change together even though neither imports the other. That kind of coupling is usually a business rule nobody wrote down.
- Go through the last 50 bug-fix commits. They point to the places where the system has already caused someone pain.
If the codebase was built with AI, add one more step: look for the same concept implemented in more than one place. Assistants usually write a fresh helper instead of finding the one that exists, so a pricing or permission rule may live in several places that do not agree. The metrics worth collecting during this phase are in our guide to measuring technical debt in a codebase you did not write.
Should you write tests before changing legacy code?
Yes, though they are different from the tests you would write for new code. Michael Feathers defined legacy code as code without tests, and he answered it with the characterization test, which records what the code does today rather than what anyone believes it should do. If a function produces a rounding error on refunds, your first test asserts that rounding error. You correct it later, on purpose, and update the test in the same commit.
It feels backwards, yet it is what makes changes safe in a system whose intended behavior nobody knows. Phase four is not about a coverage percentage. It is about putting a net under the paths where an unnoticed change would cost money, leak data, or lock users out. Be skeptical of AI-generated test suites at this stage, because they frequently check that a function was called instead of checking that it returned the right result.
When should you rewrite instead of fixing the legacy codebase you took over?
Not during the first 30 days. Deciding to rewrite before you understand the system is guesswork, and the old system has to keep running while the new one gets built. By day 30 you will have the evidence you need: the hotspot list, the test net, the incident history, and a realistic estimate of how long an ordinary change takes.
Putting off the decision has a real cost. Stripe’s Developer Coefficient report, drawn from a 2018 survey of more than 1,000 developers and more than 1,000 C-level executives, found that the average developer spent 17.3 hours of a 41.1-hour week dealing with maintenance issues. The number comes from before AI coding tools, so use it as a baseline and not a current measurement, but an inherited codebase without tests or a map will land near the top of that range. The complete decision process is in our rewrite or rescue framework for AI-built applications.
What are the warning signs that a takeover is going wrong?
- Features are being promised before anyone has managed a deploy from a clean machine.
- A single engineer has turned into the new single point of knowledge. Rotate ownership of each area and have people write it down.
- Fixes are going in without a test that failed first.
- Customers find production errors before your monitoring does.
- Nobody knows which third-party services the product cannot run without.
Those last two are where an outside view earns its keep. Our pillar guide on AI code rescue: what it is, what it costs, and when you need one covers when an internal team should bring one in. A TopDevz Rescue Audit fits the secure, reproduce, and map phases into 10 business days for a fixed $4,950, and that fee is credited toward remediation if we handle the fixes. When you need a team to keep the work going, our Delivery Pods start at $15K per month with 30-day notice and are staffed by engineers who average 10+ years of experience.
Frequently asked questions
How long does it take to take over a legacy codebase?
Expect roughly 30 days before a new team can safely change a small to mid-sized product, and more for large systems. Week one is for access and reproducible builds, and the following two weeks are for mapping and tests. Teams that skip those phases ship faster and break more things.
What is the first thing to do when you inherit a codebase?
Lock down access first. Take inventory of every credential, cloud account, domain, and third-party service, rotate anything a former team member could still use, and make sure a backup can actually be restored. Reading the code can wait until you control it.
Is taking over AI-generated code different from other legacy code?
The method does not change, but there is no author you can ask, and AI-generated code usually carries more duplicated logic, more hardcoded secrets, and tests that check calls instead of results. Set aside extra time for duplication searches and secret scanning.
Book a Code Review
If you just inherited a codebase and nobody can explain how it works, begin with evidence, not opinions. Book a Code Review to get a ranked list of the hotspots, risks, and first fixes in the system that is now yours.