.claude/commands/kpt.md
code:kpt.md
---
description: Conduct Keep-Problem-Try retrospective and update CLAUDE.md with insights
---
Conduct a Keep-Problem-Try retrospective on the current session and update the repository's CLAUDE.md with actionable insights.
**Keep-Problem-Try Framework**
- **Keep**: What worked well that should be continued
- **Problem**: What didn't work well or caused issues
- **Try**: How to improve AI agentic work quality in future iterations
**Steps**
1. **Keep Analysis**: Review the session to identify what worked well:
- Effective development approaches that produced good results
- Helpful codebase patterns or conventions that aided the work
- Successful tools, commands, or workflows used
- Architectural decisions that proved beneficial
- Focus on codebase-wide insights, not specific implementations
2. **Problem Analysis**: Identify what didn't work well and trace to CLAUDE.md content:
- Review current CLAUDE.md content that may have led to poor decisions or approaches
- Identify specific lines or sections in CLAUDE.md that caused confusion or bad results
- Find missing or outdated information in CLAUDE.md that hindered effective work
- Locate contradictory or unclear instructions that created development friction
- Note gaps in CLAUDE.md that led to repeated mistakes or inefficiencies
3. **Try Analysis**: Based on problems identified, determine how to improve AI agentic work:
- Prompt engineering improvements for better task understanding
- Context or instruction refinements to prevent similar issues
- Better approaches to tool usage or workflow orchestration
- Enhanced communication patterns between AI and user
- Documentation or guidance that would improve future AI sessions
4. **Present KPT Results**: Display the retrospective findings to the user using this format:
NOTE: Use this format in user's language. The below is an example in English.
`
# Session Retrospective - Keep-Problem-Try
## 🟢 Keep (What worked well)
- Specific practice/approach: Why it worked and how it applies to codebase
- Example: Using existing component patterns when creating new features helped maintain consistency
## 🔴 Problem (What didn't work well)
- Specific issue: Reference to CLAUDE.md content that caused the problem
- Example: CLAUDE.md line 45 states "always use Redux" but this led to over-engineering simple components
## 🔵 Try (How to improve AI agentic work on the next session)
- Improvement approach: How it enhances AI task performance or understanding
- Example: Add specific TypeScript patterns to CLAUDE.md to improve type-aware code generation
Do you approve these insights for addition to CLAUDE.md?
`
- Provide specific examples and context for each item
- Explain how each insight applies to the codebase
- Ask for user approval before proceeding to update CLAUDE.md
5. **Locate and Review CLAUDE.md**: Search for the existing CLAUDE.md file to understand:
- Current structure and sections
- Existing knowledge already documented
- Writing style and tone used
6. **Update CLAUDE.md**: Apply approved insights to the appropriate sections:
- **Keep items**: Reinforce or expand existing good practices
- **Problem items**: Document known issues or limitations to avoid repeating mistakes
- **Try items**: Add improvements to AI agentic work and prompt engineering approaches
- Match existing writing style and vocabulary
- Focus on codebase-wide insights that help future Claude sessions
7. **Review and finalize**: Ensure updates maintain consistency and readability
**Important Notes**
- Focus on systemic, codebase-wide insights rather than specific implementations
- Problems should identify root causes, not just symptoms
- Try items should be actionable experiments, not vague aspirations
- Verify consistency with existing CLAUDE.md content before updating
- If conflicts arise, ask for user clarification