Skip to content

Insights — Engineering

Why we write the runbook before the code

A page describing how the system will be operated, written before it is built, finds problems that no design review does and makes handover a non-event.

A runbook is the page someone opens when something is wrong and they did not build the system. It says what the thing does, how to tell whether it is healthy, what to do when it is not, and who to call. Most teams write it last, in a hurry, if at all. We write the first version before we write the code, and it has changed how our projects go.

It forces the awkward questions early

Writing 'how do we know this is working?' on a blank page is uncomfortable if you have no answer. So is 'what do we do if this job fails halfway?' or 'who can turn this off?'. Those questions would otherwise appear during an incident. Raising them in week one costs a conversation; raising them in production costs a customer.

What goes in it

  • What the system does, in two paragraphs a new colleague could follow
  • Where it runs, what it depends on, and what happens if each dependency is down
  • How to see its health: the dashboards, the logs, the alerts, and what normal looks like
  • The common failures and the steps to recover from each
  • How to deploy, roll back, restore from a backup and rotate a secret
  • Who owns it, and how to reach them

It does not need to be long. A page or two is plenty at the start, and it grows as we learn. The test is whether a competent person who has never seen the system could follow it at night with a worried client waiting.

It makes handover boring

The projects that end badly are the ones where knowledge lives in two people's heads. When the runbook has been used, tested and corrected during the build, handing the project over is a walk-through of a document the client has already read. We also ask someone on the client side to try the recovery steps once, in a calm moment. The first time is always instructive, and it is much better to find the missing step on a Tuesday afternoon than on a Saturday night.

What it looks like in practice

Our first-draft runbook for an automation project might say: the system receives orders from the shop, books a courier and emails the customer. It is healthy when the queue is empty and the last order was processed within ten minutes. If orders stop arriving, check the shop's webhook settings first. If orders arrive but are not processed, look at the stuck items screen and retry them. If the courier service is down, orders will wait, and the customer does not need to be told unless it exceeds a day. That is perhaps a dozen lines, and yet writing it exposes at least three decisions that nobody had made.

Keep it honest and findable

A runbook is only useful if people can find it and trust it. We store it where the team already works, link to it from alerts and dashboards, and put a date at the top. When something happens that the runbook did not cover, adding the lesson to it is part of closing the incident. Over a year it turns into a record of how the system really behaves, which is worth far more than the diagram from the kickoff.

The runbook stays in the repository next to the code, so a change to the system is not finished until the page is updated too. It is one of the cheapest habits we have, and it is the one clients mention most often when we ask what they would keep.

Keep reading

More notes.