Professional Edge: Enterprise ReadyBeginnerWorking on a delivery team

Working in a Codebase You Did Not Write: A First-Week Method

A practical method for an unfamiliar repository: a reading order for the first hour, a calm way to fix a red build on a branch, and a checklist for AI-written code.

By the SQValex Academy team · Published · Updated · 24 min read

Why the first week is mostly reading

Here is a small scene. A new joiner at an IT services firm is shown a client's claims portal. It is eight years old. Three vendors have written it, in two languages, and a release is due in under four weeks. She opens the README. It tells her to install a database version she cannot find and to run a script that is no longer in the repository. Forty minutes later she works out that the README was last changed two years ago. There are two folders of tests, and they use different tools. One suite passes. The other fails on its first line. At the top of the repository page a small badge is red, which means the build is failing.

Her colleague takes another road. He pastes the folder list and the README into an AI assistant and asks it to explain the repository. The answer is neat and confident, with headings, and it describes a module that handles payments. She searches for that module. There is no such folder and no such file.

Nothing in this scene is unusual. Many real systems are older than the time their current team has spent on them, and documentation often falls behind the code. Nobody expects a new person to know where everything is. What a team does expect is a method: an order in which you read, a careful way to change things, and a habit of checking work before you trust it, including work that an AI wrote.

This guide gives you that method in four parts. The first is an order for reading a repository you have never seen. The second is a way to read a failing build and find its cause. The third is a way to make a change on a branch so that a colleague can review it quickly. The fourth is a checklist for reviewing code that an AI wrote.

The examples come from our course "Professional Edge: Enterprise Ready". The course is set at a fictional IT services firm in Pune, Nalanda Digital, which looks after the claims portal of a fictional client, Quenmore. All the companies and people in it are made up. The habits themselves are ordinary good practice, and you can use them on any team that keeps its code in Git.

From a new repository to a change that someone can trust
  1. ReadREADME, setup, entry points, tests, pipeline file, history
  2. MapOne page: purpose, commands, test suites, things that look wrong
  3. Find the causeRead the build log from the first error and repeat the failure
  4. BranchMake the smallest fix on a branch and run the tests yourself
  5. Pull requestSay why, what changed, how you checked it and the risk
  6. ReviewCheck logic, missing values, secrets and tests before you approve

Your first hour in an unfamiliar repository

In the course, a senior engineer called Farhan gives the reading order as if he were giving directions to a station: the README, then the tests, then the pipeline file, then the last twenty commits. The README tells you what somebody once believed. The pipeline tells you what runs every time. The full order has six steps.

Step Where you look What it tells you Be careful
1. README and docs README.md, a docs folder What the project is for and how to set it up It may be old, so check when it last changed
2. Set it up The commands in the README Whether the instructions still work A step that fails is a finding, so write it down
3. Entry points Routes, main, scheduled jobs, message handlers Where a request or a task first meets the code Older code may have its own entry points
4. Tests Test folders and test names What the team expects the code to do There may be more than one suite
5. Pipeline The CI configuration file What is built and tested, in which order, with which versions It also shows what is not run
6. History git log, git blame What changes often, who knows each area, why a line is there Messages can be vague, so follow the ticket number

The order starts with what people say (the README), moves to what the code does (entry points and tests), and ends with what the team runs (the pipeline) and what it did (the history). When two of these disagree, you have found something worth writing down.

Here is a plan for the hour. Spend about ten minutes on the README and the headings of any docs folder, fifteen on trying the setup steps, ten on the entry points, ten on the tests, ten on the pipeline file and five on recent history. At the end you will know less than you want to. The aim is to know where to look next, and to have a short list of specific questions.

The README is a claim, not a fact

Read the README, then ask Git when it last changed.

git log -1 --format="%ad %s" -- README.md

If the answer is two years ago, treat every line as a claim to check. Is that version number the one the pipeline uses? Does that script still exist? There is no reason to be annoyed, because a stale README is normal in an old system. It is also a good first contribution. Once you know what is true, you can correct the README in a small pull request.

Entry points, tests and the pipeline

A web application is a set of doors. Each URL is a door, and each door leads to some code. Find the list of doors, which is usually a routes file, then pick one door and follow it in. You do not need to understand the whole system. You need to understand one path through it. Look also for doors that are not web pages, such as jobs that run at night and handlers that read from a queue. They are easy to miss.

Tests are a free description of behaviour. A test name is a sentence about what the code should do, so read the list of test names before you read the code. Then answer two questions. How do I run them? Write the exact command down. Which ones does the pipeline run? An old system may hold a suite that nobody has run for a year, and a green result from that suite tells you very little.

The pipeline file is the continuous integration (CI) configuration. It lists the jobs that run on every change: install, build, test, check style and sometimes deploy. Read it as a recipe. It names the language versions, the commands, the environment variables and the folders. When the README and the pipeline disagree, believe the pipeline, because it is the one description that is run every time.

History: why is this line here?

A few Git commands answer most questions about the past.

git log --oneline -20                 the last twenty changes, one line each
git log --stat -5                     the last five, with the files each one touched
git log --oneline -- path/to/file     the history of one file
git blame path/to/file                who last changed each line, and in which change
git log -S"some text" --oneline       every change that added or removed that text

A file that changed twelve times last month is a busy area. A file that nobody has touched for three years is either stable or forgotten, and you should find out which.

Keep a one-page map

While you read, keep a map in a plain text file. Eight lines are enough.

Line What you write
Purpose What the system is for, in one sentence
Setup The commands, and the ones that failed
Entry points Web routes, jobs and handlers, with the file for each
Test suites Folder, command, passes or fails, and whether the pipeline runs it
Pipeline What it runs, and what it does not
Busy and quiet areas What the history shows
People Who to ask about what
Things that look wrong A list that you do not fix yet

The last line matters. While you read, you will see odd names, poor formatting and comments that are no longer true. Write them down and leave them alone for now, because mixing them into your real task makes your change harder to review.

The map is also the best thing to bring when you ask for help. Compare two messages to a colleague.

Before: "I cannot get it to work."

After: "The setup step that installs the database fails with this error, and the pipeline file uses a different version from the README. Is the README out of date?"

The second message can be answered in one line, because it shows what you tried and what you saw.

A worked example: start from what you can see

Suppose a ticket says: "Handlers see 'Awaiting documents' on a claim whose documents arrived yesterday." You do not know the code, but you do know some words that a user sees. Start there. Imagine the repository looks like this.

claims-portal/
  README.md            last changed two years ago
  app/
    web/               pages and routes
    api/               endpoints the pages call
    jobs/              night-time tasks
    legacy/            older code from an earlier vendor
  tests/               newer suite
  legacy_tests/        older suite
  .ci/pipeline.yml     what the build runs
  1. Search for the visible text. grep -rn "Awaiting documents" app/ finds it in a page template and in a status table.
  2. Follow it back. The template shows a label that a function chooses. Open that function and see what calls it.
  3. Find the test. The same search over both test folders shows that one suite tests the label and the other does not.
  4. Check the pipeline. The pipeline file runs only one of the two suites, so you now know whether that test counts.
  5. Read the history. git log -S"Awaiting documents" --oneline lists the changes that added or removed the text, often with a ticket number in the message.

After five steps you know where the label is set, which test covers it, whether that test runs and who to ask. You have read a small part of a large system, and that is enough to start.

Using AI to read code

An AI assistant can save you hours here, if you treat it as a reader and not as a source of truth.

  1. Give it the code. Paste the function, not only the folder name. An answer about code the model has not seen is a guess, and the model will not tell you so. That is how the payments module in the opening scene was invented.
  2. Ask for evidence. "Which lines make you say that?" A good answer points at lines you can check.
  3. Check every name. If the answer names a file, a function or a setting, search for it. If you cannot find it, it was invented.
  4. Mind what you paste. Do not paste secrets, customer data or code that your client has not allowed into that tool. If you are not sure what is allowed, ask first. Our guide on using AI safely at work covers this in more depth.

Reading a red build from the first error

A build log can run to thousands of lines, and most of them do not matter. A red build on the main branch is also a team problem, so the first step is not a technical one.

  1. Say that you are looking. One line in the team channel stops three people doing the same work. A red build that nobody owns tends to stay red.
  2. Find the first failing step, and the first error in it. Logs show steps in order. Everything after the first failure may be a result of it, and the summary at the bottom says only that something failed.
  3. Ask what changed. git log --oneline -10 shows the last few changes. Often the cause is in the most recent change before the build first went red.
  4. Decide what kind of failure it is. The table below shows three kinds, and they need different fixes.
  5. Repeat the failure on your machine. Run the same command that the pipeline ran. If you cannot repeat the failure, you cannot know that you have fixed it.
  6. Change one thing, then run it again. If you change three things and the build turns green, you do not know which one mattered.
Kind of failure A typical sign
Code A syntax error
Test A failed assertion, which points at the test or at the code it tests
Environment A missing package, a wrong language version or a server that cannot be reached

Before you change anything, you should be able to say in one sentence why the build is red. "Something fails in the tests" is not a cause. "The pipeline installs one version of the language and the new code needs another" is a cause.

Do not silence the alarm

There is always a fast way to make a red build green. You can delete the failing test, mark it as skipped, loosen a check, or catch the error and ignore it. None of these is a fix. The build is an alarm, and a change that silences the alarm leaves the problem where it was. A green build that you did not earn is worse than a red one, because people trust it.

Take care with a flaky test, which is a test that passes on some runs and fails on others. Do not run it again and again until it passes and then call it fixed. Note it and tell the team.

Make the change on a branch

The main branch is what the team ships from and what every colleague starts from. If it is broken, everyone is slowed down, and a change that no second person has read can carry a mistake for months. So teams agree on a simple rule: nobody changes main directly. Changes arrive by pull request, which is a request to merge your branch that colleagues can read and comment on, after the pipeline has run and someone has reviewed it. Many teams enforce the rule with a setting, so a direct push is not even possible.

In the course story, a new joiner says that he could fix the build on main in ten minutes, and asks who would know. "Everyone," the senior engineer answers. "The log has your name on it."

The routine has five steps.

  1. Start from fresh main. git switch main, then git pull.
  2. Make a branch with a name that says what it is for. For example, git switch -c fix/address-change-not-saved.
  3. Make small commits with clear messages. "Save address when the postcode field is empty" is a message. "Updates" is not.
  4. Run the tests yourself before you push. The pipeline should confirm what you already know.
  5. Read your own change, then push and open a pull request.

Keep it small and about one thing

A reviewer reads your change in the middle of other work. A small change gets a careful reading. A change of six hundred lines across eleven files gets skimmed and approved. As a rough guide, if you cannot explain the change in two sentences, it is two changes. Do not mix a fix with tidying. A reviewer should be able to say "this does what it says, and nothing else".

Before you ask anyone to read it, read the diff yourself as a stranger would. You will find leftover debug lines, a file you did not mean to include, or a comment that is no longer true. It takes five minutes, and it is the cheapest review there is.

A description that a reviewer can use

A good description lets a reviewer decide in one minute whether to read the change now or later. Use five parts.

Part The question it answers Example
Why What problem does this solve? Link the ticket "Customers who clear the postcode field lose their address change. Ticket QMT-1042."
What changed In plain words, not a list of files "The address form now saves with an empty postcode and shows the old one as a hint."
How I checked it What did you run, and what did you see? "Ran the address tests (14 passed). Added one test for the empty case. It failed before the fix and passes now."
Risk What could this break? "Touches the shared form helper. Please check that the phone-number form still works."
Not in this change What did you leave alone on purpose? "Postcode format checks are unchanged."

Before: "Fixed address bug. Tested."

After: the five parts above, filled in.

The weak version has no ticket, no way to repeat the test and no hint of risk, so the reviewer must reconstruct everything. Two habits help. Say what you actually ran: "tested" is a claim, and "ran the 14 address tests" is evidence. And write the description yourself. An AI can tidy the wording, but it will describe what the code should do, not what you checked.

When the change fixes a red build, the description should name the cause, not only the change. Then wait for your own pipeline run to go green before you ask for review.

Give and receive review comments

A review is a conversation in writing, and its tone decides whether the change improves or only waits.

As the author, reply to every comment, even if the reply is "Done". Do not take a comment personally: it is about the code, and it is a gift of someone's time. Ask when you do not understand. Push follow-up changes to the same branch and say what you changed. Never merge with an unanswered must-fix comment.

As the reviewer, read the description first, then run the change or read its tests. Comment on the code, never on the person. Give a reason. Approve only what you have read, because an approval is a statement that you looked. Answer on the same working day if you can. Label every comment, so that the author knows what blocks the merge and what is only a preference.

Label Meaning
Must fix The change should not merge until this is dealt with
Question You are not sure, and you want to understand
Suggestion You would do it differently, but it is the author's choice
Nit A small matter of style. Keep these few
Praise Something done well

Before: "This is wrong. Fix it."

After: "Must fix: amount is read on line 31 before we check that it exists, so an empty claim will crash here. Could we check first, or give it a default?"

The second comment says what, where and why. A comment such as "Nice test: it fails without your change" costs a few words, and it makes the other comments easier to hear.

Reviewing code that an AI wrote

AI assistants write code quickly, and they are good at it. They also fail in a small set of predictable ways. A model writes the code that is most likely to follow your request. It has not seen your system, your data, your rules or your pipeline unless you pasted them, so it fills the gaps with what is common. The common answer is often almost right, and "almost right" is the hardest kind to review, because it compiles, the style is clean and the names are sensible.

Fault What it looks like How to find it
Logic error A wrong comparison, a condition the wrong way round, a rule applied to the wrong value Read the code against the ticket. Test exactly at the limit, just below and just above
Missing value The code works on a normal record and fails on an empty one Ask of every input: what if it is missing, empty, zero, negative or very large?
Hard-coded secret A password, token or key typed into a file or a test Search the change for token, key, secret, password and long strings
Insecure default Debug mode left on, certificate checks switched off, access open to everyone Read every setting that was added. Who can reach this, and what can they do?
Test that cannot fail No assertion, an assertion that is always true, or a check of a mock only Break the code on purpose and run the test. If it still passes, it tests nothing
Invented call A function, parameter or library that does not exist Run the code. Open the documentation for every call you do not recognise

Two small examples show why these get through. Suppose the rule says that orders of 1,000 or more get free delivery, and the code says this.

if order.total > FREE_DELIVERY_FROM:
    return True

An order of exactly 1,000 pays for delivery. The code and the rule disagree at one value, and nothing crashes. Only a test at the boundary finds it.

Now look at a test for the same rule.

def test_free_delivery():
    has_free_delivery(make_order(total=1500))

It calls the function and checks nothing, so it passes whatever the function returns. The test runner shows a green tick, and a tick means only that the test ran. A missing test is the same problem in a quieter form, so look also for what is not there: no test for the empty case, no validation, no logging.

A green build is not a review

A pipeline answers a narrow question: do the checks that the team wrote still pass? It cannot tell you whether the checks are good, whether the rule was understood or whether a secret was added. Treat a green tick on an AI-written change as a start, and then review in this order.

  1. Read the ticket and the description. Write one sentence for what the change should do.
  2. Read the tests first. Do they check the behaviour in the ticket? Could they fail?
  3. Run it. Try a normal record and an awkward one.
  4. Go through the six faults, file by file.
  5. Look at what is missing.
  6. Write labelled comments that say what, where and why.

If the change is too big to review well, say so and ask for it to be split. That is not rude. It is often the most useful comment you can make.

You can use an AI as a second reader. Read the ticket and the tests yourself first, so that you are not led by it. Then give it the diff and ask for possible edge cases, security problems and ways the tests could pass while the code is wrong, with line numbers. Check each item yourself, because some will be wrong. Add what the AI cannot know, such as the rule in the ticket. Write the comments in your own words. At no point does the AI approve the change.

If a secret has been committed

A line such as REPORTS_DB_PASSWORD = "example-not-a-real-value" is easy to remove, and removing it is not enough, because the value stays in the history of the repository. A secret that has been committed must be treated as leaked. The order of work matters.

  1. Tell the owner of the secret straight away. Do not wait until the end of the day.
  2. Have the secret replaced, so that the old value stops working. This is called rotating it, and it is what makes the leak harmless.
  3. Then remove it from the code and move it to where secrets belong: an environment setting or the team's secret store.
  4. Ask how the history will be handled. Whether to clean the history is a decision for the owner of the repository, not for a new joiner.

If you wrote it with AI

Everything above applies to your own change before it applies to a colleague's. Read every line, and do not submit a line that you cannot explain. Run the six faults over your own diff. Ask the assistant which edge cases the code does not handle. It is good at listing them, and you decide what to do. Say that AI was used where your team asks you to. And own the result: the reviewer's comment goes to you, not to the tool.

A real case: old code that nobody was reading

On 1 August 2012 Knight Capital Group, a large US trading firm, released new software for its automated trading systems. The release was to be copied to eight servers by hand. It reached seven. On the eighth, old code was still in place. A setting in the new release reused a flag that, in the old code, switched on a function retired long before. When the market opened, the eighth server began to send orders that nobody had asked for.

Within about 45 minutes the firm had bought and sold very large amounts of shares that it did not mean to trade. The company reported a loss of about US$440 million. In 2013 the US Securities and Exchange Commission announced a penalty of US$12 million and described the failures in its order.

Two things combined. The system held old code that nobody was sure was dead, and the release was done by hand with no step that made a second person check that it had reached every server. The new code was probably well written. The surprise came from the part of the system that nobody was reading.

The habits in this guide answer both. Read the system, not only your change: a search for every use of a flag, a setting or a function takes minutes. Treat unused code as a risk, and find out whether it is really dead. And make a second person look, which is what a pull request, a pipeline and a checklist are for.

What these habits do not do

A method can create false comfort, so be clear about its limits.

  • A one-hour map is not knowledge of the system. It tells you where to look next. Expect to correct it many times.
  • A checklist finds what is on the list. The six faults are the common ones, not all of them. The search for secrets and insecure defaults is a working habit, not a security audit.
  • A review checks the change against the rule you know. If the ticket is wrong or vague, tidy code can still do the wrong thing.
  • A pipeline and a second reader lower the chance of a mistake. They do not remove it.
  • They do not move accountability. However much help you had from a tool, the change carries your name.
  • They do not make decisions that belong to others. Removing old code, or cleaning a secret out of the history, is for the owner of the repository to decide.

Notice also that none of this depends on a particular tool. The reading order, the five-part description and the six faults stay the same whichever code host, pipeline or AI assistant your team uses.

Practise it this week

You can build these habits without any course. Pick an open-source project in a language you can read, spend 45 minutes on the reading order and write the one-page map. In the same repository, find one statement in the README that is wrong, and write the pull request description that would correct it. Find a project with a failing build, read the log from the first error, and say whether the failure is in the code, a test or the environment. In a small project of your own, break the code that a test depends on and see whether the test fails. Do it for three tests. After you next write code with an AI assistant, wait ten minutes and review the diff as a colleague would. Finally, take the comments "this is wrong", "needs work" and "why?" and rewrite each one so that it has a label, a place and a reason.

In our course "Professional Edge: Enterprise Ready", Module 1 is free to watch and read with a free account: that covers its video and its chapter, and the labs open when you enrol. The module follows the story in this guide, from the stale README to the red build and the AI-written pull request. You can read about the full course on the course page, or try the skills check first to see where you stand. The next skill, what to do when you are stuck, is covered in our guide to asking for help and escalating with evidence.

Frequently asked questions

How long should I read a new repository before I ask for help?

About an hour with a fixed reading order is enough to ask well. Bring your one-page map and one specific question, such as the setup step that failed and the exact error you saw.

Is a green build enough reason to approve a pull request?

No. A pipeline tells you only that the checks the team wrote still pass. It cannot tell you whether those checks are good, whether the rule was understood or whether a secret was added.

What should I do if I find a password or key committed in the code?

Tell the owner of the secret at once and have it replaced, so that the old value stops working. Removing the line comes after that, because the old value stays in the history of the repository.

Can I use an AI assistant to help me review code?

Yes, as a second reader. Read the ticket and the tests yourself first, ask the AI for risks with line numbers, check each item yourself and write the comments in your own words. The AI never approves the change.