/postmortem:postmortem-writingfrom postmortem
Guides writing blameless postmortem documents for code fixes, with structured YAML frontmatter and markdown sections for root cause analysis and prevention.
Ships in postmortem. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill provides guidance for writing effective postmortem documents that learn from code fixes and prevent future regressions.
Postmortem documents serve as a knowledge base for preventing code regression in AI-assisted development. Each postmortem analyzes a bug fix to extract:
Blameless principle: Focus on learning and prevention, not blame. Never include author attribution.
Postmortem documents follow a standard structure with YAML frontmatter and markdown sections.
Required metadata fields:
---
commit: abc123def456 # Full commit hash
date: 2026-01-13 # Commit date (YYYY-MM-DD)
severity: medium # low, medium, high, critical
tags: [authentication, race-condition] # Descriptive tags
files_changed: 5 # Number of files modified
related_commits: [] # Related fix commits (hashes)
---
Severity levels:
Tags: Use descriptive, searchable tags for categorization:
authentication, database, apirace-condition, null-pointer, memory-leakpostgres, redis, reactboundary-check, input-validation, error-handlingEach postmortem includes these sections in order:
Format: # Postmortem: [Brief Description]
Use imperative form and be specific:
Fix null pointer in user authentication flowResolve race condition in cache invalidationBug fixUpdate codeDescribe the observable symptom and broken functionality.
What to include:
Keep it concise: 2-3 sentences maximum.
Example:
## Problem Summary
Users were unable to log in after password reset. The authentication
service returned a 500 error when validating reset tokens. This affected
all users who attempted password reset between 2026-01-10 and 2026-01-12.
Explain WHY the problem occurred, not just what was wrong.
Structure:
## Root Cause Analysis
**Root cause category**: [Logic Error | Missing Validation | Race Condition |
Architecture Flaw | Dependency Issue | Configuration Error | Other]
**Why it happened**:
- [Primary reason - dig deep, not surface]
- [Contributing factors]
- [Missed edge cases or incorrect assumptions]
Go beyond surface symptoms: Identify the underlying cause, not just the immediate trigger.
Good analysis:
**Root cause category**: Logic Error
**Why it happened**:
- Token validation logic assumed tokens were always 32 characters
- Password reset flow generates 64-character tokens
- No length validation on token input
- Original implementation only supported session tokens (32 chars)
Poor analysis:
**Why it happened**:
- The code had a bug
- Token check failed
Describe what was modified to fix the issue.
Structure:
## Code Changes
**Modified files**:
[List files with change summary]
**Key logic changes**:
- [Describe algorithmic or logical changes]
- [What was added, removed, or refactored]
**API/Interface changes**:
- [Function signature changes]
- [Data structure modifications]
- [Impact on callers or dependencies]
Be specific: Mention actual file names, function names, and logic changes.
Example:
## Code Changes
**Modified files**:
- `src/auth/token_validator.py`: Updated validation logic
- `tests/auth/test_token_validation.py`: Added test cases
**Key logic changes**:
- Removed hardcoded 32-character length check
- Added flexible token length validation (16-128 chars)
- Improved error messages to distinguish token types
**API/Interface changes**:
- `validate_token()` now accepts optional `token_type` parameter
- Return value includes token type for better error handling
Identify patterns to watch for in future changes.
Structure:
## Risk Pattern
**File/module risk**:
- Files: [Specific files prone to similar issues]
- Modules: [Components or services]
**Code pattern risk**:
- [Vulnerable code structures or patterns]
- [Common mistakes in this area]
**Common mistake**:
- [What assumption led to this bug]
- [What developers might miss]
Make it actionable: Describe patterns that can be detected in code changes.
Example:
## Risk Pattern
**File/module risk**:
- Files: `src/auth/*.py`, especially token handling
- Modules: Authentication service, session management
**Code pattern risk**:
- Fixed-length string assumptions without validation
- Token handling without type checking
- String operations assuming specific formats
**Common mistake**:
- Assuming all tokens have the same format
- Not validating token length before operations
- Forgetting that token formats evolve over time
Focus on automation and systematic prevention.
Critical: This section should emphasize automation without human intervention, not manual processes.
Structure:
## Prevention Strategy
### Automated Testing
- [ ] [Specific test case with input/expected behavior]
- [ ] [Integration test scenario]
- [ ] [Recommend test framework]
### AI Coding Context
- **When to load**: [Specific trigger for loading this postmortem]
- **What to load**:
- [ ] [This postmortem document]
- [ ] [Related postmortems]
- [ ] [Architecture docs]
- **Context strategy**: [What AI should pay attention to]
### Automation Hooks
- **Pre-commit checks**: [Linter rules, static analysis]
- **CI/CD checks**: [Build-time validation]
- **Claude Code hooks** (future): [PreToolUse/PostToolUse recommendations]
### Code Review Checklist
- [ ] [Specific review item]
- [ ] [Second item]
Automated Testing:
AI Coding Context:
Example:
### Automated Testing
- [ ] Test tokens of various lengths: 16, 32, 64, 128 characters
- [ ] Test invalid token formats (empty, too short, too long)
- [ ] Test mixed token types in same session
- [ ] Property-based testing: generate random valid tokens
### AI Coding Context
- **When to load**: When modifying `src/auth/*.py` or token-related code
- **What to load**:
- [ ] This postmortem (token length assumptions)
- [ ] `docs/auth/token-formats.md` (token specifications)
- [ ] Related postmortem: `2026-01-05-xyz789-session-token-expiry.md`
- **Context strategy**: Verify no fixed-length assumptions in new code. Check all string operations for token length validation.
### Automation Hooks
- **Pre-commit checks**:
- [ ] Linter rule: Flag hardcoded length checks on token strings
- [ ] Static analysis: Detect string operations without length validation
- **CI/CD checks**:
- [ ] Run token validation test suite on all auth changes
- [ ] Property-based tests must pass
Connect to related problems and areas.
Structure:
## Related Issues
**Similar commits**:
- [Commit hash]: [Brief description]
**Potential problem areas**:
- [Files or modules that might have same pattern]
**Follow-up work**:
- [ ] [Additional hardening needed]
- [ ] [Documentation updates]
Provide technical background for understanding the issue.
Structure:
## Technical Context
**Affected components**:
- [Service/module/layer affected]
**Dependencies**:
- [External libraries, services, systems]
**Testing challenges**:
- [Why this was hard to catch]
- [How testing was improved]
**Additional notes**:
- [Other relevant context]
Write for developers who will read this months or years later.
Good:
The authentication service validated tokens using a fixed-length
comparison, assuming all tokens were 32 characters. When password
reset tokens (64 characters) were introduced, the validation logic
failed silently.
Bad:
There was a problem with the token thing. The code didn't work right
for some tokens.
Explain reasoning and assumptions, not just symptoms.
Good:
The original implementation assumed all tokens came from the session
service, which always generates 32-character tokens. The password reset
service was added later and generates longer tokens for security, but
the validation logic was never updated.
Bad:
The token was the wrong length and failed validation.
Provide actionable, automatable prevention strategies.
Good:
### Automated Testing
- [ ] Add property-based test: generate tokens of length 16-128, verify all validate correctly
- [ ] Add integration test: complete password reset flow with token validation
- [ ] Test framework: Use hypothesis for property-based testing
Bad:
### Prevention
- Write tests
- Be careful with tokens
- Review code carefully
Write instructions, not descriptions.
Good: "Add test cases for token length validation" Bad: "We should add test cases" or "You should add test cases"
Assign severity based on impact and scope.
Example: Database connection leak causing service crash
Example: Users unable to log in after password reset
Example: Export function fails for files >10MB
Example: Button alignment off by 2px on mobile
Use consistent, searchable tags.
Technical components affected: authentication, database, api, frontend, cache
Nature of the issue: race-condition, null-pointer, memory-leak, deadlock, off-by-one
Specific technologies: postgres, redis, react, python, docker
Code patterns: boundary-check, input-validation, error-handling, concurrency, resource-management
Example tag set:
tags: [authentication, password-reset, input-validation, string-handling]
❌ Don't identify who wrote the buggy code ❌ Don't criticize individuals or decisions ✅ Focus on what happened and how to prevent it
❌ "The bug was in line 42" ❌ "The code was wrong" ✅ Explain why the code was written that way ✅ Identify assumptions that proved incorrect
❌ "Write better tests" ❌ "Be more careful" ✅ Specific test cases to add ✅ Concrete automation strategies
❌ "Developers should remember to check token length" ❌ "Reviewers should watch for this pattern" ✅ Linter rules to catch the pattern ✅ Tests that fail if pattern recurs
For detailed best practices and advanced techniques:
references/best-practices.md - Comprehensive postmortem writing guidereferences/severity-guide.md - Detailed severity classificationComplete postmortem examples:
examples/sample-postmortem.md - Full annotated exampleexamples/good-vs-bad.md - Good and bad examples comparedGenerate initial postmortem template using:
${CLAUDE_PLUGIN_ROOT}/scripts/postmortem-template.sh <commit-hash> output.md
This creates a structured template with commit metadata populated. Fill in the analysis and prevention sections.
Follow these guidelines to create postmortem documents that effectively prevent regression and build a valuable knowledge base for AI-assisted development.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
postmortem, incident-documentation, bug-analysis, code-review
2 skills in this plugin
npx claudepluginhub shfc/open-claude-plugins --plugin postmortemOther plugins' skills for the same job