AI Post-Mortems: Faster Drafts That Stay Blameless

AI Post-Mortems: Faster Drafts That Stay Blameless

An AI post-mortem draft takes over the slowest part of incident follow-up: scrolling back through Slack, alerts and deploy logs to rebuild what happened. The risk is a model that confidently writes “the engineer forgot”. You will build a pipeline that assembles the timeline in code, drafts the story with a blameless prompt, and leaves contributing factors and action items to the people who were there.

How an AI post-mortem pipeline works

A post-mortem is the written review after an incident: what happened, the impact, why, and what changes. Blameless means it explains how the system and process allowed the failure, instead of looking for someone to punish. The diagram shows the pipeline.

Data flow: Slack incident channel, Prometheus ALERTS series and GitHub deployments feed timeline.py, which pseudonymises and sorts events; an LLM drafts a blameless Markdown pull request; a CI lint and human reviewers check it before it is published and added to a search index for future triage
Code collects the facts, the model writes prose, people decide.

Notice where the LLM sits. It never queries Slack or Prometheus itself and only sees pseudonymised events, so it cannot quote a name. Its one narrow job is turning sorted facts into prose. The draft lands as Markdown in Git, where your team already reviews changes.

You need Python 3.11+ with pip install slack-sdk requests anthropic, a Slack bot token with channels:history (groups:history for private channels), read access to Prometheus, and a GitHub token that can read deployments. The access an AI triage co-pilot already has is enough.

Step 1: Build the timeline from chat, alerts and deploys

The timeline is where a model hallucinates most if it reconstructs events from a pasted chat log. So build it in code. This script pulls the incident channel, the alerts that fired and the production deploys from two hours before the start, then merges them into one sorted list.

# timeline.py
import json, os, sys, requests
from datetime import datetime, timezone
from slack_sdk import WebClient

START, END = float(sys.argv[1]), float(sys.argv[2])   # incident window, Unix seconds
env, roles = os.environ, {}                           # roles: Slack user ID -> responder-N

def chat():
    for page in WebClient(token=env["SLACK_BOT_TOKEN"]).conversations_history(
            channel=env["INCIDENT_CHANNEL"], oldest=str(START), latest=str(END), limit=200):
        for m in page["messages"]:
            who = roles.setdefault(m["user"], f"responder-{len(roles) + 1}") if "user" in m else "bot"
            yield float(m["ts"]), "chat", f"{who}: {m.get('text', '')[:300]}"

def alerts():
    r = requests.get(f"{env['PROM_URL']}/api/v1/query_range", timeout=10, params={
        "query": 'ALERTS{alertstate="firing"}', "start": START, "end": END, "step": 30})
    for s in r.json()["data"]["result"]:               # first sample = started firing
        yield float(s["values"][0][0]), "alert", f"{s['metric']['alertname']} firing"

def deploys():
    r = requests.get(f"https://api.github.com/repos/{env['GH_REPO']}/deployments", timeout=10,
                     params={"environment": "production", "per_page": 100},
                     headers={"Authorization": f"Bearer {env['GH_TOKEN']}"})
    for d in r.json():
        t = datetime.fromisoformat(d["created_at"]).timestamp()
        if START - 7200 <= t <= END:                   # include 2 h before the start
            yield t, "deploy", f"{d['ref']} @ {d['sha'][:7]} reached {d['environment']}"

for t, src, text in sorted([*chat(), *alerts(), *deploys()]):
    hhmmss = datetime.fromtimestamp(t, timezone.utc).strftime("%H:%M:%S")
    print(json.dumps({"t": hhmmss, "src": src, "text": text}))

Looping over the conversations_history response follows Slack’s pagination cursors for you. Each Slack user ID becomes responder-1, responder-2 and so on, so names never reach the model. Prometheus keeps a synthetic ALERTS series for every pending or firing alert, and the first firing sample marks the start. The GitHub deployments API supplies each deploy’s time, ref and commit.

Export the five environment variables, then run python3 timeline.py 1795510800 1795518000 > timeline.jsonl for 09:00 to 11:00 UTC on 24 November. Expect lines like these:

{"t": "09:12:04", "src": "deploy", "text": "v142 @ 3f9c2ab reached production"}
{"t": "09:14:30", "src": "alert", "text": "CheckoutHighErrorRate firing"}
{"t": "09:16:02", "src": "chat", "text": "responder-1: checkout 5xx climbing, looking"}
{"t": "09:31:47", "src": "chat", "text": "responder-2: rolling back to v141"}

See the 15 silent minutes after 09:16? That is the classic gap. conversations.history returns only top-level messages, and the debugging happened in a thread, so fetch busy threads with conversations.replies too. People also type names in free text, so replace roster names before the file goes anywhere. Alerts already firing before the window appear at its start, so widen it if the first alert looks early.

Step 2: Draft with a blameless prompt, people own the causes

Contributing factors and action items are judgement calls. A model sees what was typed in chat, not the trade-offs behind a decision or the dashboard nobody had. If it writes the causes, the team argues with the draft instead of thinking. So the prompt drafts the facts and stops. The flowchart shows who does what.

Flowchart: incident resolved, automation builds the timeline; if there is a gap over 10 minutes a person fills it; the LLM drafts; if blame words are found a person rewords those lines; people write contributing factors and action items; if the review checklist fails it loops back, otherwise the post-mortem is published and indexed
Automation collects and drafts; every decision routes to a person.

Cyan steps are automation and green steps belong to people. Both checks route to a person: a silent gap needs someone who was there, and flagged wording is reworded in the pull request, not regenerated. Save the drafting step as draft.py:

# draft.py: timeline.jsonl in, blameless Markdown draft out
import sys, anthropic

PROMPT_VERSION = "pm-draft-v3"                     # bump on every prompt change
SYSTEM = """You draft blameless post-mortems from a JSON-lines incident timeline.
- Use only facts in the timeline. Cite the timestamp for every claim.
- Refer to people by role (responder-1), never by name.
- Describe what the system or process allowed, not what a person did wrong.
  Never write "human error", "should have", "failed to", "careless" or "forgot".
- Sections: Summary, Impact, Timeline, Questions for the review.
- Do not write contributing factors or action items. The review owns them.
- Mark any gap over 10 minutes as [gap] and ask what happened."""

msg = anthropic.Anthropic().messages.create(
    model="claude-sonnet-5-5", max_tokens=2000, system=SYSTEM,
    messages=[{"role": "user", "content": open(sys.argv[1]).read()[:60000]}])  # input cap
print(msg.content[0].text)
print(f"\n_Draft by {msg.model}, prompt {PROMPT_VERSION}, "
      f"{msg.usage.input_tokens}/{msg.usage.output_tokens} tokens_")

The rules encode blameless writing: facts only, a timestamp per claim, roles instead of names, and sentences about what the system allowed. Run python3 draft.py timeline.jsonl > postmortems/2026-11-24-checkout-5xx.md and open a pull request. A good draft says “09:14:30 CheckoutHighErrorRate fired, two minutes after v142 reached production” and asks “What let v142 reach every pod before the alert fired?”

Treat the prompt as code. The footer records the model, prompt version and token counts, so a bad draft points to the exact prompt that produced it and its cost. Rerun prompt changes on a few past incidents before merging. The usual failure is a cause sneaking into the Summary (“caused by a bad config”): delete it in review and tighten the rule.

Step 3: Lint the wording and review the draft

A prompt reduces blame language but does not remove it, and people add their own while editing. A deterministic check catches both. Run this in CI on every pull request that touches a post-mortem:

PM=postmortems/2026-11-24-checkout-5xx.md
# Blame phrases
if grep -nEiw 'human error|should have|failed to|careless|forgot|blamed?' "$PM"; then
  echo "blame language found"; exit 1
fi
# Names from the team roster, one per line
if grep -nFiwf roster.txt "$PM"; then
  echo "names found: use roles such as responder-1"; exit 1
fi

-n prints line numbers, -E enables the alternation, -i ignores case and -w matches whole words, so “forgotten” does not trip “forgot”. The second check reads fixed-string names (-F) from a file (-f). Strip blank lines from it, because an empty pattern can match every line. A failing run looks like this:

41:The rollback stalled because responder-2 forgot the feature flag.
blame language found

Rewrite the line as what the system allowed: “The rollback runbook did not mention the feature flag.” Expect false positives about systems, such as “the probe failed to detect”, and reword those too rather than growing an allow-list.

Lint covers wording only. Everything else needs reviewers: the incident commander plus one engineer who was not in the incident. Use this checklist on every AI-drafted post-mortem.

Review checklist in two columns. Verify the draft: every line has a source, roles never names, no blame phrasing, impact matches the SLO dashboard. People own this: every gap explained, causes written by people, action items with owner, date and ticket, model and prompt version recorded
No model should tick the right-hand column.

Published post-mortems are also your best input for next time. I built RAG pipelines that automate documentation search, and a Slack bot that investigates incidents with that search plus metric plugins and log APIs. Clean, cited post-mortems make that retrieval and LLM root cause analysis far more useful. For the culture side, see post-mortem culture that works.

Common pitfalls

  • Letting the model write causes. A “because” in the Summary deserves a second look.
  • Real names in the prompt. Pseudonymise first; chat sent to an LLM API is also a data-protection question.
  • Timelines from memory. Only code-collected, timestamped events go in.
  • Skipping the meeting. The draft starts the review; it does not replace it.

Key takeaways

  • Build the timeline in code from chat, alerts and deploys; the model only writes prose.
  • Pseudonymise before the model sees anything, then lint for names and blame phrases.
  • Contributing factors and action items belong to people in the review.
  • Version the prompt and model, and test changes on past incidents.

Related articles