Skip to content

    Source control and code review

    Default

    Small changes, reaching the main line often, each one seen by another person before it lands. That is most of how we keep a code base safe to change.

    • Work on a short-lived branch. A branch lives a day or two, not a fortnight. If the work will not fit, that is a sign to slice it smaller, possibly across a few branches in turn, rather than to let one branch run for weeks.
    • Protect the main line. Changes reach it only through a pull request, with an approving review and a green build. That rule holds for everyone, leads included; nobody merges straight to main.
    • Tie the change to the work. Put the item’s identifier in the branch name and the commit messages, so anyone can trace a line of running code back to the item that asked for it.
    • Squash on merge by default, so the history of main reads as one clear change per item rather than every keystroke on the way there.
    • Keep secrets out of it entirely. Credentials, keys and tokens never go into source control; use the platform’s secret manager, and if one is ever committed, rotate it rather than just deleting it. This is set out in the Access Control Policy and secure engineering.

    Review is how we share understanding and catch problems early, not a gate one person guards. Four things:

    • Egalitarian. Anyone reviews anyone, and everyone’s code is reviewed, whatever their seniority. Reviews are kind, and phrased to teach rather than to score points.
    • Small. A change nobody can hold in their head cannot really be reviewed, which is another reason to keep items thin.
    • Meets the need. Does it do what the item asked, handle the awkward cases, and guard the obvious security, performance and robustness risks?
    • Good enough to inherit. Is it clear and simple, consistent with the code around it, and something the next person could change without fear?

    Pairing is the other way we get a second pair of eyes, and it shares knowledge faster than review alone. As a rough guide an even split of paired and solo work suits most teams, more when a team is forming or someone is onboarding. Work done as a pair has already been reviewed as it was written, so it often does not need a separate review, as long as the team agrees that up front.

    • Long-lived branches. The longer one runs, the more painful the merge and the weaker the review.
    • A giant change held open for days. It is slower overall, not faster, and it gets a worse review.
    • Review as gatekeeping or nitpicking. Argue the things that matter; let style go to the linter and the formatter.
    • Force-pushing a shared branch, which rewrites history under other people. Keep it to branches only you are on.