Error Postmortem Drafter Skill
Drop in the artifacts of a resolved incident — timeline, logs, optional Slack thread — get back a first-draft postmortem that's 80% of the way there. Blameless tone, structured sections, ready for human editing and circulation.
The Problem
The hardest part of writing a postmortem is starting. By the time the incident is over, the on-call is exhausted, the timeline is fragmented across PagerDuty, Slack, and Datadog, and the writeup gets pushed to "next week" and then "next sprint." A first draft generated automatically the moment the incident closes turns a 2-hour blank-page slog into a 30-minute edit.
How It Works
- After incident resolution, an on-demand or auto-triggered job collects: - The PagerDuty incident timeline (or your equivalent) - The relevant Slack/Teams response thread - Log excerpts from the incident window
- The
error-postmortem-drafterskill produces the markdown draft - The draft is delivered to the on-call (email or Slack DM) for editing
- After review, the on-call publishes to your postmortem repo / Confluence / wiki
Setup
- Install this skill
- Set up integrations to gather the inputs: - PagerDuty / Opsgenie API (incident timeline) - Slack API (thread export) - Log source (CloudWatch Insights, Loki, Grafana)
- Use the YAML below; trigger on-demand or via a button in your incident-management tool
Example YAML Job
name: postmortem-draft
version: 1.0.0
description: Draft a postmortem from incident artifacts
notifications:
- userNames: [intouch]
alertOnError: true
tasks:
- name: fetch-incident
tool: http
credentialName: pagerduty
properties:
method: GET
url: "https://api.pagerduty.com/incidents/${INCIDENT_ID}/log_entries?include[]=channels"
headers:
Authorization: "Token token={{credential.secret}}"
Accept: "application/vnd.pagerduty+json;version=2"
- name: fetch-slack-thread
tool: http
credentialName: slack
properties:
method: GET
url: "https://slack.com/api/conversations.replies?channel=${INCIDENT_CHANNEL}&ts=${INCIDENT_THREAD_TS}"
headers:
Authorization: "Bearer {{credential.secret}}"
- name: fetch-logs
tool: runtimeenv
properties:
credentialNames: ["aws"]
scriptContent: |
#!/bin/bash
# Pull error-level logs from the incident window
START_MS=$(($(date -d "${DETECTED_AT}" +%s) * 1000))
END_MS=$(($(date -d "${RESOLVED_AT}" +%s) * 1000))
aws logs filter-log-events \
--log-group-name /myapp/prod \
--start-time "$START_MS" \
--end-time "$END_MS" \
--filter-pattern '?ERROR ?FATAL' \
--output text \
--max-items 500
- name: draft
tool: skill
properties:
skillName: error-postmortem-drafter
input: |
incident: "${INCIDENT_TITLE}"
severity: "${INCIDENT_SEVERITY}"
detectedAt: "${DETECTED_AT}"
resolvedAt: "${RESOLVED_AT}"
customerImpact: "${CUSTOMER_IMPACT}"
timeline:
{{fetch-incident.responseBody}}
chatThread:
{{fetch-slack-thread.responseBody}}
logs:
{{fetch-logs.output}}
- name: send-draft
tool: message
properties:
subject: "Postmortem draft — ${INCIDENT_TITLE}"
body: "{{draft.answer}}"
userNames: "intouch"
Customization
- Auto-create a wiki page — replace the message task with a
http POSTto your Confluence/Notion API to create the postmortem page directly - Severity-aware verbosity — for SEV3 incidents, prompt the skill to keep the postmortem short (Summary + Prevention only); SEV1/2 get full sections
- Multi-incident retros — concatenate inputs from multiple recent incidents and prompt the skill to find common-cause patterns
- Customer-comms version — chain a second skill call that produces a customer-facing version (less internal jargon, no log excerpts)
Safety notes
- The DRAFT requires human review before publishing. The SKILL.md emphasizes blameless tone and not inventing root causes, but human judgment is irreplaceable for tone-checking and verifying the timeline
- Be careful about including logs that contain customer data, secrets, or PII — sanitize before passing to the AI
Cost
- AI assistant: ~$0.05-0.20 per postmortem with Claude Sonnet (longer context, deeper synthesis)
- A few times a month if you're well-run, weekly if you're not — either way, trivial vs the value of a culture of writing postmortems