If the user passes `--help` as an argument, display this help and stop:
/plugin marketplace add FrancisVarga/coconut-claude-code-plugins/plugin install coconut-rules@coconut-claude-code-pluginsIf the user passes --help as an argument, display this help and stop:
/coconut-rules:retrospective - Session Retrospective Analysis
DESCRIPTION
Analyze the current session to extract learnings, mistakes, patterns,
and decisions. Proposes updates to rules and knowledge graph.
USAGE
/coconut-rules:retrospective [--depth LEVEL] [--dry-run]
/coconut-rules:retrospective --help
OPTIONS
--depth LEVEL Analysis depth: quick, deep, ultrathink (default: ultrathink)
--dry-run Show proposed changes without applying them
ANALYSIS CATEGORIES
M - Mistakes: Errors and their root causes
G - Good Decisions: What worked and why
P - Patterns: Recurring code/workflow patterns
D - Debugging: Investigation techniques that worked
A - Architecture: Design decisions and rationale
OUTPUT
Grouped by action type:
- Rules to add (with placement: CLAUDE.md or .claude/rules/)
- Rules to update
- Knowledge graph entries to add
- Items skipped (with reason)
EXAMPLES
# Full retrospective with ultrathink
/coconut-rules:retrospective
# Quick analysis
/coconut-rules:retrospective --depth quick
# Preview changes without applying
/coconut-rules:retrospective --dry-run
Run a retrospective analysis on the current session to extract learnings and update rules/knowledge graph.
Extract options from $ARGUMENTS:
--depth quick|deep|ultrathink (default: ultrathink)--dry-run flag (default: false)Execute the retrospective in phases:
.claude/retrospectives/ directory exists:
mkdir -p .claude/retrospectives
YYYY-MM-DD-HHmm.mdLaunch three agents in parallel using Task tool:
[session-analyzer] - Analyze conversation for learnings
[rule-reviewer] - Review current rules against learnings
[knowledge-updater] - Propose knowledge graph updates
All agents receive the same depth setting.
Wait for all agents to complete. Collect outputs:
Format results for user review:
## Retrospective Results
### Session Summary
- Events analyzed: [count]
- Learnings extracted: [count by category M/G/P/D/A]
### Rules to Add
| Rule | Placement | Rationale |
|------|-----------|-----------|
| [text <50 words] | [CLAUDE.md/.claude/rules/X.md] | [why] |
### Rules to Update
| Current | Proposed | File |
|---------|----------|------|
| [old text] | [new text] | [path] |
### Knowledge Graph Entries
| Type | Content | Tags |
|------|---------|------|
| [decision/pattern/convention] | [text] | [relevant tags] |
### Skipped Items
- [Item]: [Reason - too specific/already covered/low impact]
Use AskUserQuestion to get user confirmation:
Review the proposed changes above.
Options:
1. Apply all changes
2. Apply rules only
3. Apply KG entries only
4. Review individually
5. Cancel
If user confirms (and not --dry-run):
For rules:
/coconut-rules:add-rule or Edit toolFor knowledge graph:
/coconut-knowledge-graph:add commandSave retrospective summary to .claude/retrospectives/YYYY-MM-DD-HHmm.md:
# Retrospective: [Date Time]
## Session Focus
[Brief description of what was worked on]
## Learnings by Category
### Mistakes (M)
- [learning]
### Good Decisions (G)
- [learning]
### Patterns (P)
- [learning]
### Debugging (D)
- [learning]
### Architecture (A)
- [learning]
## Changes Applied
### Rules
- Added: [list]
- Updated: [list]
### Knowledge Graph
- Added: [list]
## Notes
[Any additional context]
Also sync to knowledge graph if available:
/coconut-knowledge-graph:add "retrospective-YYYY-MM-DD" --type decision --content "[summary]"
For Task tool invocations:
session-analyzer: "Analyze this conversation session to extract learnings. Categories: Mistakes (root cause), Good Decisions (why worked), Patterns (recurring), Debugging (techniques), Architecture (decisions). Use [depth] analysis level. Output structured learnings."
rule-reviewer: "Review .claude/rules/ and CLAUDE.md against the session learnings. Identify: rules to add (with placement), rules to update, rules to remove. Use concise-rule-writing skill. Each rule <50 words."
knowledge-updater: "Propose knowledge graph updates based on session learnings. Use /coconut-knowledge-graph:search to check existing entries. Avoid duplicates. Output: entries to add with type (decision/pattern/convention) and tags."
--depth quick for short sessions with obvious learnings--dry-run to preview before applying