Skip to content
Back home

Article — Onboarding

How to get productive in a codebase you’ve never seen

How to get up to speed in an unfamiliar codebase: use git history to find what matters, get it running, trace one request, and keep an AI agent honest.
Reading time
8 min
Topics
Onboarding · Codebase · Architecture · AI agents
Published
20 November 2026
Go deeper
Codebase Onboarding Pack skill pack

Sooner or later you inherit a codebase. You join a new team, take over a client project from another agency, or get asked whether a system is worth buying. The usual advice is to read the README and then read the code. The README is often out of date, and reading top to bottom teaches you a little about everything and not enough about anything.

This article is the order of work I use instead. It takes you from a fresh clone to a first useful change, and it works whether you do the reading yourself or hand most of it to an AI agent.

What productive means

You do not need to understand the whole system. You need answers to five questions:

  1. How do I run it, and its tests, on my machine?
  2. What actually runs in production: which processes and which data stores?
  3. What happens, file by file, when a user does the most important thing?
  4. Where is it dangerous to make a change?
  5. What do I still not know, and who can tell me?

Each section below answers one of them. Anything that does not can wait.

Start with git history, not the folder tree

A folder tree gives every file the same weight. History shows where the team actually works. Before reading any code, ask git which files changed most often in the last year:

git log --since="12 months ago" --no-merges --name-only --pretty=format: \
  | grep -v '^$' | sort | uniq -c | sort -rn | head -20

Then list the largest source files, adjusting the extensions to the language:

git ls-files -z '*.js' '*.ts' | xargs -0 wc -l | sort -rn | head -20

Files near the top of both lists are where you will spend your time: they change constantly and they are big enough to be hard to change. Read those first. This is hotspot analysis, the idea behind Adam Tornhill's book Your Code as a Crime Scene.

Three things distort the lists:

  • Lockfiles and manifests top the churn list in most repositories. Skip them.
  • Generated and vendored code inflates size and churn: API clients, ORM output, copied libraries, sometimes a committed dependency folder. Exclude those paths by adding a pathspec such as ':!vendor/' to the command.
  • Shallow clones have incomplete history. If git rev-parse --is-shallow-repository prints true, run git fetch --unshallow before trusting any history-based number.

History also tells you who to ask:

git shortlog -sn --no-merges --since="12 months ago" HEAD

If one name has nearly all the commits, write that down. It is the person to talk to, and it is a risk in its own right.

Get it running, and treat the README as a hypothesis

Setup instructions go stale faster than any other documentation, because the people who wrote them have had a working machine ever since. Follow the README, but check each claim against the repository.

Runtime version. Look for pins: .tool-versions, .nvmrc, .python-version, engines in package.json, the go line in go.mod, the FROM line in a Dockerfile and the setup step in CI. If they disagree, use the version CI uses, because that is the one known to pass.

Dependencies. Install with the command that respects the lockfile. In a Node project that is npm ci, not npm install. According to the npm documentation, npm ci never writes to the lockfile and exits with an error if the lockfile and package.json disagree. That error is worth knowing about on day one.

Environment variables. The example env file lists the variables someone remembered to add. The code is the authority:

git grep -IhoE 'process\.env\.[A-Z0-9_]+' | sort -u

Swap the pattern for os.environ, ENV[ or os.Getenv in other languages. Any name the code reads that is missing from the example file is a finding, and often the reason the app will not start.

Scripts. Read a script before you run it. Seed, reset and deploy scripts sometimes point at a shared database. Installs, builds, local tests and a local dev server are safe to run. Anything that could touch a remote system gets read first.

Write down every failure with the exact error message and what fixed it. Those notes are the most valuable thing a newcomer produces, because nobody else on the team can still see these problems.

Find what actually runs

Architecture is processes and data stores, not folders. A repository with a tidy services/ directory may deploy as a single process. One that looks like a single app may deploy a web server, a worker and three scheduled functions.

Look at the places where things get started:

  • scripts in the package manifest, a Makefile or a Procfile
  • CMD and ENTRYPOINT in Dockerfiles, and docker-compose.yml
  • CI and deployment workflows, which show what is built and where it goes
  • Hosting configuration such as netlify.toml, vercel.json, serverless.yml or Terraform files

Each process or data store you can point to in one of those files goes on your list. Then check for the traps that produce a wrong list:

  • Dead code. A module that exists is not a module that runs. Confirm it is imported from an entry point, registered in a router or referenced in configuration.
  • Wiring by convention. File-system routing, autoloading and dependency-injection containers connect code with no import statement. In the Next.js Pages Router, for example, a file added to the pages directory is automatically available as a route, whether or not anything links to it. Learn the framework's conventions before you decide something is unused.
  • Feature flags and environment switches. A code path behind a flag may be switched off in production. Note the flag and its default.
  • Configuration set elsewhere. The effective value often comes from the hosting platform, not the repository. Write "default in the repository", not "production uses".

Trace one request end to end

Pick the single most important thing a user does, such as placing an order or signing in, and follow it through the code. Write one line per step, each with a file path:

  1. Route: the path, the file that defines it and the handler.
  2. Middleware: authentication, validation and rate limiting, in the order they run.
  3. Domain logic: where the handler hands over to the code that makes decisions.
  4. Data access: the queries, transactions and caches it touches.
  5. Side effects: jobs queued, emails sent, third-party services called.
  6. Response: its shape, the status codes and what happens on an error.

One trace teaches you the layering, the naming, where validation lives and how errors are handled. Most other requests follow the same conventions, so the second trace takes a fraction of the time.

Note anything surprising on the way: a third-party call made while the user waits, a write with no transaction, a query inside a loop. You are not fixing these yet. They mark the places to be careful.

Keep confirmed and inferred apart

Everything in your notes is one of two kinds. Confirmed means you read it in code or configuration. Inferred means you deduced it from a name or from partial evidence, for example "REDIS_URL appears in the example env file, but I found no client code". Label each note, and say what an inference is based on. A wrong mental model usually starts as a guess that nobody marked as a guess.

The same applies to anything that lives outside the repository. Backups, monitoring, alerts and firewall rules are often configured in a hosting console. "Not visible in the repository" is accurate. "There are no backups" is a guess.

Keep a running list of open questions and take it to the person the commit history pointed you to. A short map you can defend is more useful than a long one you cannot.

Know where it is dangerous

Before you change anything, spend ten minutes on risk. This is not an audit. It tells you which areas to stay out of in your first week.

CheckWhere to look
Runtime or framework past end of lifeVersion pins, Dockerfile, CI setup
Payments, authentication or permissions without testsTest folders against those modules, and what CI actually runs
Manual deployment steps or no rollbackDeployment workflows, deploy scripts, the README
One person holding all the knowledgeThe author list from earlier
Secrets committed to the repositoryA tracked .env file, keys in CI configuration

If you find a real credential, report the file and the type of secret. Do not paste the value into a ticket or a chat.

Choose a first change

A good first change is small enough to finish in under a day, easy to review, on the main request path so that you learn it, and unlikely to break much if it is wrong. Places to find one:

  • Open issues labelled as good first issues
  • TODO markers in code that is not critical
  • Existing behaviour that has no test
  • The setup instructions you have just proved wrong

That last one is often the best first pull request. You ran every command, so you know the fix is correct, and the next new starter benefits immediately.

Stay away from payments, authentication, migrations on large tables and anything without tests until you have a few changes behind you.

Doing this with an AI agent

An agent can do most of the reading above in minutes, and it is a good use of one. Left without rules, though, it tends to fail in the same few ways:

  • It draws a cache or a queue that does not exist, because applications like this usually have one.
  • It repeats the README's description of the architecture as fact.
  • It summarises the directory tree and calls that the architecture.
  • It copies a secret it found into its answer.
  • It runs a seed or migration script to "check the setup".

A few explicit rules prevent most of that:

Map this repository. Rules:
- Cite a file path for every claim.
- Label every component and integration as Confirmed (read in code or
  config) or Inferred (say what the inference is based on).
- Read-only: do not install, migrate, start services or modify files.
- If you find credentials, report the path and type only, never the value.
- End with the questions you could not answer from the repository.

Then check its work the way you would check a colleague's. Open a handful of the cited files and confirm they say what the agent claims. If several do not, rerun the task rather than correcting the output by hand.

Closing

Getting productive in an unfamiliar codebase is mostly a matter of order. Let history show you where the work happens, get the system running and record what broke, list what really runs, trace one request, and keep what you know separate from what you assume. Then make a small change on the main path.

The full exploration checklist, a repository statistics script and templates for the architecture document, risk register and new-starter guide are in the Codebase Onboarding Pack.

More articles