Skip to content

Incident Report CLI Builder

A CLI tool to streamline incident report creation using interactive forms.

Usage

Build and run the CLI application:

bash
cd /Users/zilizhang/code/sre/et/docs/incidents/incident-report-builder
go build -o incident-cli main.go
./incident-cli

Or run directly with Go:

bash
cd /Users/zilizhang/code/sre/et/docs/incidents/incident-report-builder
go run .

The application will guide you through:

  1. 📋 Incident Summary - Basic incident information

    • Date (defaults to today)
    • Environment (sg-cdg/ap1/us1/za1/id1/eu1)
    • Status (Resolved/Investigating/Mitigated)
    • Severity (P0/P1/P2/P3)
    • ✨ Duration and Detection Delay are automatically calculated from timeline events
  2. 💥 Impact Assessment - Multi-line text area for:

    • User Impact description
  3. ⏰ Timeline Builder - Interactive timeline creation across all phases:

    • 🚨 Start Phase - Initial symptoms and trigger events
    • 🔍 Detection Phase - How incident was discovered and escalated
    • 🔧 Investigation Phase - Root cause analysis and findings
    • ⚡ Resolution Phase - Mitigation steps and fixes applied
    • ✅ End Phase - Service restoration and all-clear confirmation
    • For each phase: Enter what happened, when (HH:MM format), add multiple events
    • Time validation: Ensures proper HH:MM format (e.g., 10:40)
    • Smart calculations: Duration = End Phase time - Start Phase time, Detection Delay = Detection Phase time - Start Phase time
    • Automatically formats as - **HH:MM** - description
  4. 📄 Report Details - Specify the output filename

Output

Generates a markdown file in the parent incidents/ directory with:

  • Filled-in Incident Summary, User Impact, and Timeline sections
  • Preserved template structure for manual completion of other sections
  • User-specified filename

Example Timeline Output

Input across phases:

  • Start Phase: "we saw many 503 gateway timeout errors on cloudflare" at "10:40"
  • Detection Phase: "monitoring alerts triggered for high error rate" at "10:42"
  • Investigation Phase: "identified database connection pool exhaustion" at "11:15"

Output in markdown:

markdown
## Timeline

### Start Phase

- **10:40** - we saw many 503 gateway timeout errors on cloudflare

### Detection Phase

- **10:42** - monitoring alerts triggered for high error rate

### Investigation Phase

- **11:15** - identified database connection pool exhaustion

### Resolution Phase

[Empty sections show placeholder text for manual completion]

### End Phase

[Empty sections show placeholder text for manual completion]

Requirements

  • Go 1.24+
  • Terminal with TTY support for interactive forms

Implementation Details

  • Uses text/template for clean, maintainable markdown generation
  • Custom template functions for title formatting and multiline text processing
  • Template-driven approach eliminates repetitive string concatenation
  • Structured data binding with the incident report template
  • Time validation with regex pattern matching for HH:MM format
  • Automatic calculations for duration and detection delay based on timeline events
  • Smart handling of day rollovers and multiple events per phase