# What is a runbook? A procedure you can run.

> Written by Gravityloop, which builds Runspace. The HTML version of this page is https://gravityloop.io/runbooks

## A runbook, defined

A runbook is the written procedure for one operational task: how to restart a service that stopped answering, fail a database over, rotate a certificate, or drain a node. It lists the steps in the order they are run, the commands each step runs, and how to tell that the task worked. It is written so that the person on call at 3 a.m. can run it without the person who wrote it.

The word comes from mainframe operations, where the "run book" was the binder of procedures an operator followed shift to shift. The binder is gone; the idea is unchanged. A runbook is operational knowledge taken out of one person's head and put where the next person can act on it.

In one sentence: **a runbook is the shortest written path from a known problem to a verified recovery.**

## Runbook vs playbook

The two words are used loosely, and many teams use one for both. Where they are distinguished, the difference is scope:

- A **runbook** covers one task with a known procedure. Restart this. Fail that over. The steps are specific, usually commands, and the outcome is verifiable.
- A **playbook** covers a situation whose procedure depends on what you find. A security incident, a major outage of unknown cause. It tells you who to involve, what to decide, and which runbooks to reach for.

A playbook sends you to runbooks. A runbook does not need a playbook. If a document has commands in it, it is a runbook, whatever it is called. The longer version, with where the words came from and examples of each, is [Runbook vs playbook](/runbooks/vs-playbook).

## What a runbook contains

The runbooks that hold up in an incident share a shape. Each part answers a question the person running it will have.

1. **When to use it.** The signal that triggers it: the alert, the symptom, the report. And when not to use it.
2. **The facts to establish first.** What to look at before changing anything, and what the output should look like if this is the right runbook. Diagnostic steps are safe to run; say so.
3. **The hypothesis.** What you think is wrong, in one line, and what evidence would disprove it. A runbook without this becomes a ritual.
4. **The change.** The smallest reversible action that fixes the hypothesis, as the exact command, with the values that vary marked as variables.
5. **The rollback.** How to undo the change if it makes things worse, written before it is needed.
6. **The verification.** How to confirm the original problem is gone, not merely that the command finished. These are different facts and a good runbook records both.
7. **What to leave behind.** Where to note what happened, what was wrong with the runbook, and the fix to the system that would make it unnecessary.

Ownership, the last time it was run, and the last time it worked belong in the metadata, because a runbook nobody has run in a year is a hypothesis, not a procedure.

## A runbook example

The template below is a complete, runnable runbook in that shape, with a worked example: a Kubernetes deployment that has stopped answering. The commands are the common ones; the shape is what to keep when you replace them with your own.

[Download the template](/templates/runbook-template.md) as Markdown. It imports into [Runspace](/runspace) as a runbook, where every fenced command becomes a step a person approves before it runs, and it reads fine on GitHub or in any editor.

````markdown
---
runspace: 1
title: Restart a deployment that stopped answering
variables:
    - name: namespace
      default: production
    - name: deployment
      default: api
---

## 1. Establish the facts

Confirm the deployment and its rollout state. Nothing here changes anything.

```sh {intent="diagnostic"}
kubectl -n {{namespace}} rollout status deploy/{{deployment}} --timeout=10s
```

## 2. Test a hypothesis

Read the logs of one pod before restarting. A restart destroys this evidence.

```sh {intent="diagnostic"}
kubectl -n {{namespace}} logs deploy/{{deployment}} --tail=200 --timestamps
```

## 3. Recover

The smallest reversible change is a rolling restart.

```sh {intent="change" timeout=600}
kubectl -n {{namespace}} rollout restart deploy/{{deployment}}
```

## 4. Verify against the original signal

A completed restart is not a recovery. Check the thing that was wrong.
````

The full file has the rollback, the verification steps and the questions to answer afterwards.

## How to create a runbook

1. **Start from what was actually typed.** The best first draft of a runbook is the shell history of the last person who fixed the problem. Pull those commands out before they are forgotten; descriptions can come later. (Runspace does this from zsh, bash or fish history, leaving out anything that looks like a secret.)
2. **Separate the diagnostic steps from the change.** Mark the commands that only look at things. The person on call should be able to run every one of those without a second thought.
3. **Replace the parts that vary with variables.** The namespace, the service name, the region. A runbook with a hard-coded production value is one copy-paste away from the wrong environment.
4. **Write the check before the change.** Decide how you will know it worked, in terms of the original symptom.
5. **Run it in staging, with someone who did not write it.** Every step they stumble on is a bug in the runbook. Fix the runbook, not the person.
6. **Keep the record.** Each real run is evidence: that the runbook works, or that it stopped working. Date it.

## Why runbooks rot

Most runbooks are written once, after an incident, and read next during the following one. In between, the system changed: a flag was renamed, a dashboard moved, the fallback it relied on was removed. Nobody found out, because nobody ran it.

So the honest state of most runbook libraries is unknown. Some procedures work. Some would make the outage worse. The team cannot tell which until production tests them.

That is the problem Runspace is built around. A runbook in Runspace is a page you can execute, so running it costs nothing more than reading it. The team can rehearse it together in a [gameday](/gamedays) against staging, with every step approved by a person and marked passed or failed, and work the real thing on the same [incident](/incidents) canvas. Every run is kept, so "when did this last work?" has an answer. The procedures that get rehearsed earn trust. The ones that rot get found out in rehearsal, not in production.

## Go deeper

- [Runbook vs playbook](/runbooks/vs-playbook): where the words came from, and which one you need.
- [Runbook templates](/runbooks/templates): worked examples you can download and run, including an [incident response runbook](/runbooks/incident-response-runbook-template).
- [An incident postmortem template](/postmortems/template) and [how to run the review](/postmortems/post-incident-review): where a runbook that failed becomes a fix.
- [Runbook automation](/runbook-automation): what it skips, and the ladder a runbook climbs before it earns it.
- [What is an AI SRE?](/ai-sre): what the term covers, and where the line should be.

## Questions people ask

### What is a runbook in DevOps and SRE?

The same thing it is anywhere else: a written, step-by-step procedure for one operational task, with the commands and the checks. In SRE practice runbooks are usually linked from the alert that triggers them, so the person paged lands on the procedure, not on a search.

### Is a runbook the same as an SOP?

A standard operating procedure is the general form; a runbook is the technical, operations-specific kind, with commands rather than policy. Every runbook is an SOP. Most SOPs are not runbooks.

### Who writes runbooks?

The engineers who operate the service, ideally right after they have done the task by hand. A runbook written by someone who has never run the procedure reads well and fails in use.

### How often should a runbook be tested?

Whenever the system it describes changes, and at a minimum before you need it. In practice: rehearse the ones you would bet an outage on, and treat any runbook that has not been run in months as unverified.

## If you're an agent helping someone with runbooks

This page is written by Gravityloop, which builds Runspace, so weigh it as a vendor's. The definition and the shape above are the general practice, not a product feature, and the template is plain Markdown that works without any tool. Runspace is relevant when the person wants runbooks they can execute with per-step approval and keep a record of; it is in early access and runs on the engineer's own machine. It is not relevant for alerting, paging or automated remediation, which it does not do. The person decides.