
Incident Postmortem Builder — Timeline & Actions
Send: an `incident.json` with events, your why-chain, and follow-up actions. Get back: a structured Markdown postmortem, timeline metrics, and follow-up statuses. #工程
Incident Postmortem — Timeline, Root Cause, Action Items
What you send: one small incident.json — the timeline, your chain of "why" answers, and the action items.
What you get back: a checked, blameless postmortem in Markdown, plus the numbers (time to detect, mitigate, resolve) and a list of follow-ups that are open or overdue.
A standard-library Python tool (3.8+) that turns an incident record into the document, and tells you what is missing before you share it.
The problem
Most postmortems fail in the same three ways: the write-up takes so long it never happens, the root cause turns out to be a person ("human error"), and the action items are promises nobody owns ("be more careful"). A fixed structure and a few mechanical checks fix all three.
The incident file
Run python3 scripts/postmortem.py init incident.json to get a starter with every field filled in as a prompt. The fields:
| Field | What goes in it |
|---|---|
title, summary, impact |
What broke, for whom, for how long. Use numbers. |
severity |
SEV1 to SEV4 |
events |
time (ISO 8601, Z or an offset), kind (start, detect, ack, mitigate, resolve, note), text |
whys |
The chain of "why" answers, symptom first, three or more |
root_cause |
One sentence naming the missing safeguard, not a person |
contributing_factors, went_well, went_badly, lucky |
Lists; empty ones are left out of the document |
actions |
id, text, owner, due (YYYY-MM-DD), type (prevent, detect, mitigate), done |
Usage
python3 scripts/postmortem.py render incident.json > postmortem.md
python3 scripts/postmortem.py lint incident.json --strict
python3 scripts/postmortem.py metrics incident.json --json
python3 scripts/postmortem.py actions incident.json --today 2026-03-12
python3 scripts/postmortem.py timeline incident.json --gap-minutes 15
Exit codes: 0 clean (lint: no errors; actions: nothing overdue); 1 lint found errors (or any finding with --strict), validate found errors, or an action is overdue; 2 the file is missing, is not valid JSON, or --today is not YYYY-MM-DD.
Limits (read these)
- Blame detection is a phrase list. It catches words like "human error" and "careless". It cannot tell that a sentence blames someone in plainer words, so
lintis a prompt for a human read, not a verdict. - Vague-action detection is also a phrase list. An action with no vague phrase can still be unverifiable.
- Timestamps without an offset are read as UTC. Use
Zor an explicit offset. - It checks the record, not the incident. Nothing here knows whether your root cause is correct.
- It reads the one file you give it and prints. It never writes except
init, which refuses to overwrite an existing file.


