The knowledge from last Tuesday's 2 a.m. replication incident currently lives in one engineer's shell history and fading memory. This playbook turns that raw material — commands, timeline, chat log — into a structured runbook that AI drafts, and a game-day run validates before it earns a place in the wiki.
Tier: Foundation · Workflow area: Reliability & Incident Ops · ~30 minutes
Runbooks written from memory are fiction; runbooks written from shell history are evidence. The workflow here is deliberately narrow: collect the actual artifacts of a resolved incident, have AI reorganize them into a runbook with decision points and verification steps, then prove the runbook by walking it against a rehearsal environment. The validation run is not optional polish — it is the step that separates documentation from decoration.
Harvest the raw material while it exists. Three sources, collected verbatim:
# The responder's shell history with timestamps
HISTTIMEFORMAT='%F %T ' history | tail -200 > incident-2318-shell.txt
# Postgres log slice for the incident window
awk '$1" "$2 >= "2026-08-02 01:45" && $1" "$2 <= "2026-08-02 04:30"' \
/var/log/postgresql/postgresql-*.log > incident-2318-dblog.txt
Export the incident channel's chat log too — the "try restarting the wal sender" messages carry the decision sequence the shell history alone loses.
Prompt for a runbook shape, with invention forbidden. The critical instruction is that gaps become questions, not filler:
Below: shell history, database log slice and chat transcript from a
resolved incident (replication lag cascade, Postgres 15 streaming
replica). Draft a runbook titled "Replication lag: diagnose and
recover" with EXACTLY this structure:
1. SYMPTOMS — what pages/alerts/user reports look like.
2. VERIFY — read-only commands that confirm this is the same failure,
each with the expected healthy vs unhealthy output.
3. DIAGNOSE — ordered checks narrowing the cause, as a decision tree
(if X shows Y, go to step N).
4. RECOVER — the fix steps, each with: the exact command, what output
indicates success, and what to do if it fails.
5. VERIFY RECOVERY — how to prove the system is healthy again.
6. ESCALATE — the point at which this runbook stops and a human
decision (with role named) takes over.
Rules: use ONLY commands that appear in the provided material or are
standard read-only diagnostics you can name confidently. Where the
material does not show a step clearly, insert "[GAP: question for
responder]" instead of inventing. Mark every state-changing command
with [DANGER].
[paste the three files]
Resolve every GAP with the responder — in one sitting. The gaps are the runbook's honesty markers. A ten-minute review with the engineer who was there converts each [GAP] into either a real step or an explicit "unknown — investigate live." Zero gaps survive to publication.
Audit the [DANGER] steps for guardrails. Every state-changing command gets three additions, by hand: a precondition check that must pass first, the blast radius in one sentence, and the undo. Example of the finished form:
**Step 7 [DANGER]: restart the WAL sender**
- Precondition: step 5 confirmed `sender_pid` stuck (no WAL position
advance for 5+ min) — do not restart a merely slow sender.
- Blast radius: brief reconnect for all replicas on this primary.
- Command: `SELECT pg_terminate_backend(<sender_pid>);`
- Success: new sender pid within 15 s, `pg_stat_replication` advancing.
- Undo: none needed — sender restarts automatically; if it does not
within 60 s, go to ESCALATE.
Run the game day — the runbook is unvalidated fiction until someone follows it cold. Reproduce a facsimile of the failure in a rehearsal environment (a lag-injected replica works: SELECT pg_wal_replay_pause(); on the standby). Then a different engineer — not the author, not the original responder — executes the runbook literally, noting every place they had to improvise. Each improvisation is a defect; fix the text, not the person.
Publish with a validation stamp and an owner. The wiki entry carries: validated by K.S. against lag-injected replica 2026-08-06; next review 2027-02; owner: db-oncall lead. A runbook without a review date is scheduled to rot.
sys.dm_hadr_database_replica_states snapshots into the VERIFY section.SHOW REPLICA STATUS fields, and have the model annotate which fields changed meaning across 5.7/8.0 — then verify those annotations against the docs for your version.Shell history and chat logs routinely contain passwords typed into the wrong window, connection strings and customer identifiers. Scrub the harvest before it reaches an external model, and again before the runbook lands in a wiki with broader read access than the incident channel.
AI compresses incident artifacts into a runbook draft in minutes, but the game-day cold read is what makes it a runbook at all. Draft from evidence, forbid invention, guard the dangerous steps, and let a stranger's walkthrough be the ink that signs it.