Generate clean, consistent incident postmortems from a structured YAML/JSON incident file.
IPG turns your incident notes into:
postmortem-INCIDENT_ID.md(publishable Markdown)postmortem-INCIDENT_ID.json(structured export)action_items-INCIDENT_ID.csv(easy to import into a tracker/spreadsheet)
Teams often write postmortems in inconsistent formats, which makes learning and follow-up harder.
This tool enforces a repeatable incident schema and produces a standardized postmortem output.
- ✅ YAML/JSON input with strict schema validation (Pydantic)
- ✅ Deterministic Markdown output via Jinja2 templates
- ✅ Exports: JSON + action-items CSV
- ✅ Clear CLI UX + exit codes (0 success, 2 input/schema error, 1 unexpected error)
- ✅ Custom templates supported (
--templates-dir,--template)
incident-postmortem-generator/
examples_in/
incident.sample.yml
src/ipg/
cli.py
models.py
parser.py
renderer.py
exporters.py
templates/default.md.j2
tests/
test_parser.py
test_renderer.py
- Python 3.12+ recommended
Dependencies (installed via your package manager):
- typer
- pydantic
- pyyaml
- jinja2
uv syncRun via:
uv run ipg --helppython -m venv .venv
source .venv/bin/activate
pip install -e .Run via:
ipg --helpipg validate -i examples/incident.sample.ymlipg generate -i examples/incident.sample.yml -o outThis will create (for example):
out/postmortem-INC-2025-0017.mdout/postmortem-INC-2025-0017.jsonout/action_items-INC-2025-0017.csv
ipg generate -i examples/incident.sample.yml -o out --no-json
ipg generate -i examples/incident.sample.yml -o out --no-csvipg generate -i examples/incident.sample.yml -o out --templates-dir ./my-templates --template custom.md.j2See: examples/incident.sample.yml
High-level fields:
incident_id,title,severity,statusservice(name, owner_team, environment, tier)time(start/end/detected/mitigated + timezone)summary,impact,detectiontimeline[]events (sorted ascending by time)root_cause,response,communicationaction_items[],tags,references
Templates live in:
src/ipg/templates/default.md.j2
Templates use Jinja2 and receive:
incident(validated Pydantic model)
You can create your own templates and point to them using --templates-dir.
uv run ipg validate -i examples/incident.sample.yml
uv run ipg generate -i examples/incident.sample.yml -o outuv run pytest-
Add CI workflow to run:
ruff(lint)pytest(tests)
-
Add release workflow:
- build package
- attach artifacts on version tags
- Add snapshot testing for Markdown output (golden file)
- Add tests for JSON/CSV exporters
- Add tests for invalid YAML/JSON parsing edge cases
-
--formatoption (markdown/json/csv selection) - GitHub Issue importer (pull title/body/timeline signals)
- Postmortem quality checks (missing sections detector)
- Action-items “owner resolution” (map team aliases)
MIT License © 2025 Mohamadreza Najarbashi