Post-Mortem Command for Claude Code Self-Improvement
/ 1 min read
Table of Contents
We’re all getting tired of Claude Code’s meme-worthy behavior sometimes: Considering something done when it’s not, deleting tests to “fix” CI, overall just doing things you told it multiple times to not do.
I thought about how we could make use of chat histories that include that back and forth between user and agent when things go sideways. So I built a /post-mortem command that analyzes chat histories and then tries to self-improve system prompts and documentation.
/post-mortem
The command works in four phases. First, it loads and parses a conversation to categorize successful versus failed interaction patterns. Then it identifies root causes of friction points - like when Claude repeatedly fails to find the right build command or misunderstands project structure.
The third phase generates specific recommendations for improving CLAUDE.md
files and system prompts (like your custom slash commands). Finally, it lets you tweak or approve the changes before updating the files.
You can run it on the current chat session with just /post-mortem, or point it at exported conversations: /post-mortem ~/Downloads/chat-export.txt
. It should also consider focusing on specific issues like /post-mortem focus on build process issues
.
To give it a try, just grab post-mortem.md and throw it in your Claude Code slash commands folder.