| name | summarize |
| description | Track and summarize problems solved by Claude Code with full context for knowledge sharing |
| version | 1.0.0 |
| author | Claude |
| tags | ["knowledge","documentation","history","problem-solving"] |
Summarize Command - Claude Code Problem-Solving Tracker
Track, document, and share problems solved by Claude Code across sessions with comprehensive context.
Core Functionality
This command creates a structured knowledge base of problems Claude Code has solved, enabling:
- Future Claude sessions to understand past solutions
- Team knowledge sharing and collaboration
- Problem-solving pattern recognition
- Solution reusability and adaptation
Command Structure
claude summarize add [--title "Problem Title"] [--auto-detect]
claude summarize list [--category <category>] [--recent <n>]
claude summarize show <problem-id>
claude summarize export [--format md|html] [--output <path>]
claude summarize sync [--since <date>] [--branch <branch>]
claude summarize search <query>
claude summarize report [--period <week|month|all>]
Storage Structure
Problems are stored in changelog/ with this organization:
changelog/
├── index.yaml # Master index of all problems
├── 2025-01/ # Organized by date
│ ├── problem-001.yaml
│ └── session-summary.md
├── by-category/ # Symbolic links by category (optional)
│ ├── bug-fixes/
│ ├── features/
│ ├── refactoring/
│ └── performance/
└── latest.md # Symlink to most recent summary
Problem Entry Schema
Each problem is stored as a YAML file with comprehensive context:
id: "2025-01-18-001"
title: "Implement parallel test execution"
category: "performance"
severity: "medium"
created_at: "2025-01-18T10:30:00Z"
updated_at: "2025-01-18T11:45:00Z"
problem:
description: |
Test suite taking too long to run, blocking development workflow.
Sequential execution causing 15-minute wait times.
context:
files_affected:
- src/test-runner.js
- tests/config.js
error_messages:
- "Timeout: Test execution exceeded 900 seconds"
user_request: |
"The tests are taking forever to run. Can you make them faster?"
constraints:
- "Must maintain test isolation"
- "Cannot modify test logic"
- "Must work with existing CI/CD"
solution:
approach: |
Implemented parallel test execution using worker threads.
Grouped tests by module for optimal parallelization.
implementation:
changes:
- file: "src/test-runner.js"
description: "Added worker pool management"
lines_modified: 145
- file: "tests/config.js"
description: "Configured parallelization settings"
lines_modified: 23
code_snippets:
- language: "javascript"
description: "Worker pool implementation"
code: |
const { Worker } = require('worker_threads');
const pool = new WorkerPool({ size: os.cpus().length });
patterns_used:
- "Worker thread pool pattern"
- "Test sharding strategy"
- "Promise-based coordination"
results:
performance_improvement: "75% reduction in test execution time"
metrics:
before: "15 minutes"
after: "3.5 minutes"
validation:
- "All tests passing"
- "CI/CD integration successful"
- "No flaky tests introduced"
git_info:
commits:
- hash: "abc123def"
message: "feat: implement parallel test execution"
timestamp: "2025-01-18T11:30:00Z"
files_changed: 2
insertions: 168
deletions: 12
- hash: "def456ghi"
message: "fix: resolve race condition in parallel tests"
timestamp: "2025-01-18T11:45:00Z"
files_changed: 1
insertions: 8
deletions: 2
branch: "feature/parallel-tests"
pr_number: 142
pr_url: "https://github.com/user/repo/pull/142"
session_info:
session_id: "session-2025-01-18-093000"
duration_minutes: 75
commands_used:
- "/test diagnose"
- "/test optimize"
- "/git commit"
agents_spawned:
- type: "test-fixer"
purpose: "Analyze test bottlenecks"
- type: "general-purpose"
purpose: "Research parallelization patterns"
tags: ["performance", "testing", "parallelization", "worker-threads"]
lessons_learned:
- "Worker threads provide excellent test isolation"
- "Sharding by module size optimizes resource usage"
- "Promise.all with timeout prevents hanging workers"
related_problems:
- "2025-01-10-003"
- "2024-12-22-018"
Implementation Details
Duplicate Detection and Smart Merge
check_existing_problem() {
local problem_id="$1"
local problem_file="changelog/$(date +%Y-%m)/${problem_id}_problems_solved.yaml"
[[ -f "$problem_file" ]]
}
generate_next_problem_id() {
local base_date="$(date +%Y-%m-%d)"
local counter=1
local changelog_dir="changelog/$(date +%Y-%m)"
mkdir -p "$changelog_dir"
while check_existing_problem "${base_date}-$(printf '%03d' $counter)"; do
((counter++))
done
echo "${base_date}-$(printf '%03d' $counter)"
}
check_recent_summarization() {
local session_file=".milestones/sessions/current-summary.txt"
if [[ -f "$session_file" ]]; then
local last_run=$(stat -f %m "$session_file" 2>/dev/null || stat -c %Y "$session_file")
local now=$(date +%s)
if [[ $((now - last_run)) -lt 300 ]]; then
return 0
fi
fi
return 1
}
update_session_timestamp() {
local session_file=".milestones/sessions/current-summary.txt"
mkdir -p "$(dirname "$session_file")"
date +%s > "$session_file"
}
merge_git_commits() {
local existing_file="$1"
local new_commits="$2"
if command -v yq &>/dev/null; then
yq eval ".git_info.commits += $new_commits" -i "$existing_file"
else
sed -i.bak '/^git_info:/,/^[^ ]/ {
/commits:/ {
a\
'"$new_commits"'
}
}' "$existing_file"
rm -f "${existing_file}.bak"
fi
}
handle_duplicate_problem() {
local problem_id="$1"
local problem_file="changelog/$(date +%Y-%m)/${problem_id}_problems_solved.yaml"
if [[ "$FORCE_OVERRIDE" == "true" ]] || [[ "$2" == "--force" ]]; then
echo "🔄 Force override enabled - replacing existing problem"
return 0
fi
if check_recent_summarization; then
echo "⏭️ Problem recently summarized (< 5 minutes ago) - skipping"
return 1
fi
echo "📝 Problem already exists: $problem_id"
echo "Options:"
echo " 1) Append new information (merge)"
echo " 2) Replace existing entry"
echo " 3) Create new entry with different ID"
echo " 4) Skip"
read -p "Choice [1-4]: " choice
case $choice in
1) echo "🔀 Merging new information..."; return 2 ;;
2) echo "🔄 Replacing existing entry..."; return 0 ;;
3) echo "➕ Creating new entry..."; return 3 ;;
4) echo "⏭️ Skipping..."; return 1 ;;
*) echo "⏭️ Invalid choice - skipping"; return 1 ;;
esac
}
Adding Problems (summarize add)
claude summarize add
claude summarize add --auto-detect
claude summarize add --title "Fixed authentication bug" --category "bug-fix"
claude summarize add --force
The command will:
- Check for existing problems with duplicate detection
- Generate unique problem ID with auto-increment
- Extract context from current git state
- Analyze recent commits for relevant changes
- Check session history for commands and agents used
- Handle duplicates intelligently (merge/replace/skip)
- Update session timestamp to prevent re-summarization
- Store in structured YAML format
Duplicate Handling Flow:
problem_id=$(generate_next_problem_id)
if check_existing_problem "$problem_id"; then
handle_duplicate_problem "$problem_id" "$@"
case $? in
0)
backup_existing_problem "$problem_id"
create_problem_entry "$problem_id"
;;
1)
exit 0
;;
2)
merge_problem_data "$problem_id"
;;
3)
problem_id=$(generate_next_problem_id)
create_problem_entry "$problem_id"
;;
esac
else
create_problem_entry "$problem_id"
fi
update_session_timestamp
Listing Problems (summarize list)
claude summarize list
claude summarize list --category "performance"
claude summarize list --recent 10
claude summarize list --verbose
Output format:
📊 Claude Code Problem-Solving History
════════════════════════════════════════
🔧 Recent Problems Solved:
[2025-01-18-001] Implement parallel test execution
Category: performance | Severity: medium
Impact: 75% test execution time reduction
Git: 2 commits, PR #142
[2025-01-17-003] Fix memory leak in data processor
Category: bug-fix | Severity: high
Impact: Reduced memory usage by 60%
Git: 3 commits, PR #138
[2025-01-16-002] Add real-time collaboration features
Category: feature | Severity: medium
Impact: New WebSocket-based collaboration
Git: 8 commits, PR #135
Total: 127 problems solved | 89% success rate
Viewing Problem Details (summarize show)
claude summarize show 2025-01-18-001
claude summarize show 2025-01-18-001 --include-code
claude summarize show 2025-01-18-001 --browser
Exporting Documentation (summarize export)
claude summarize export
claude summarize export --since "2025-01-01"
claude summarize export --format html --output docs/problems-solved.html
claude summarize export --format md --category "all" --include-lessons
Syncing from Git History (summarize sync)
claude summarize sync
claude summarize sync --since "2025-01-01"
claude summarize sync --branch "main"
claude summarize sync --dry-run
The sync process:
- Parses git log for Claude Code signatures
- Extracts problem context from commit messages
- Analyzes file changes for solution patterns
- Links related commits and PRs
- Creates problem entries with git metadata
Searching Problems (summarize search)
claude summarize search "authentication"
claude summarize search "error.*timeout"
claude summarize search --in "solution" "worker threads"
claude summarize search --full-text "performance optimization"
Generating Reports (summarize report)
claude summarize report --period week
claude summarize report --period month --verbose
claude summarize report --metrics
claude summarize report --patterns
Report includes:
- Problems solved by category
- Success/failure rates
- Common patterns identified
- Performance improvements achieved
- Lessons learned summary
- Team collaboration metrics
Integration Points
Git Integration
- Automatic commit extraction with
git log --format
- PR linking via GitHub CLI (
gh pr view)
- Branch analysis for feature tracking
- Diff analysis for solution patterns
Session Management
- Links to session summaries in
changelog/
- Command history tracking
- Agent utilization metrics
- Duration and complexity analysis
Milestone System
- Cross-references milestone completions
- Tracks problems within milestone context
- Aggregates milestone-level metrics
- Enables project-wide problem tracking
Documentation System
- Exports integrate with
/docs command
- Generates team knowledge base
- Creates searchable problem database
- Supports multiple output formats
Advanced Features
Problem Pattern Recognition
claude summarize analyze-patterns
claude summarize suggest --for "current problem description"
Team Collaboration
claude summarize share --team
claude summarize import --from <path>
claude summarize merge --with <remote-path>
Metrics and Analytics
claude summarize metrics --type performance
claude summarize metrics --type complexity
claude summarize metrics --type effectiveness
Multiple Execution Handling
Intelligent Duplicate Management
The /summarize command is designed to handle multiple executions intelligently:
Session Awareness:
- Tracks recent summarizations (< 5 minutes) to prevent accidental duplicates
- Session state stored in
.milestones/sessions/current-summary.txt
- Automatically skips if recently executed unless
--force flag used
Smart ID Generation:
- Automatically generates unique IDs:
YYYY-MM-DD-001, YYYY-MM-DD-002, etc.
- Increments counter for same-day problems
- Prevents ID collisions even with rapid execution
Duplicate Detection:
- Checks if problem file already exists before creation
- Offers intelligent options when duplicate detected:
- Merge: Append new git commits and update timestamps
- Replace: Backup existing and create fresh entry
- New Entry: Generate next available ID
- Skip: Leave existing entry unchanged
Force Override:
claude summarize add --force
FORCE_OVERRIDE=true claude summarize add
Example Scenarios:
-
Immediate Re-execution (< 5 minutes):
$ claude summarize add
⏭️ Problem recently summarized (< 5 minutes ago) - skipping
-
Same Day, Different Problem:
$ claude summarize add
Generated ID: 2025-01-18-002 # Automatically incremented
-
Updating Existing Problem:
$ claude summarize add
📝 Problem already exists: 2025-01-18-001
Options:
1) Append new information (merge)
2) Replace existing entry
3) Create new entry with different ID
4) Skip
Choice [1-4]: 1
🔀 Merging new information...
Best Practices
When to Add Problems
- After solving significant bugs or issues
- When implementing new features
- After performance optimizations
- When refactoring complex code
- After debugging difficult problems
Documentation Quality
- Include specific error messages
- Document before/after metrics
- Capture user's original request
- Note constraints and requirements
- Record lessons learned
Knowledge Sharing
- Export weekly summaries for team review
- Create category-specific documentation
- Share patterns and solutions
- Build searchable knowledge base
- Enable cross-session learning
Implementation Notes
Storage Adapter Pattern
Uses the proven hybrid storage approach:
- File-based for < 100 problems
- File + SQLite indexing for 100-1000 problems
- Full database for > 1000 problems
Performance Optimization
- Lazy loading of problem details
- Indexed search capabilities
- Cached export generation
- Incremental sync updates
- Parallel git analysis
Error Handling
- Graceful degradation without git
- Automatic recovery from corrupted entries
- Validation of problem schema
- Rollback capabilities for sync
- Comprehensive error logging
Example Workflow
claude session start --goal "Optimize database queries"
claude summarize add --auto-detect
claude summarize list --recent 7
claude summarize export --format md --output docs/
claude summarize search "database optimization"
claude summarize report --period month
Future Enhancements
Planned Features
- AI-powered pattern recognition
- Automatic solution suggestions
- Problem complexity scoring
- Success rate predictions
- Integration with issue trackers
Extensibility
- Plugin architecture for custom analyzers
- Webhook support for external systems
- API for programmatic access
- Custom export templates
- Multi-language support
Troubleshooting
Common Issues
Problem: Sync not finding Claude commits
Solution: Ensure commits include Claude signature in message
Problem: Storage directory not accessible
Solution: Check permissions on .milestones/ directory
Problem: Export formatting issues
Solution: Verify markdown processor compatibility
Problem: Search not returning results
Solution: Rebuild search index with summarize reindex
Command Aliases
For convenience, these shorter aliases are available:
claude sum → claude summarize
claude problems → claude summarize list
claude solved → claude summarize list --recent
Conclusion
The /summarize command provides comprehensive problem-solving documentation, enabling:
- Knowledge preservation across sessions
- Team learning and collaboration
- Pattern recognition and reuse
- Continuous improvement tracking
- Effective problem-solving strategies
By maintaining a structured database of solved problems, Claude Code becomes more effective over time, learning from past solutions to provide better assistance in future sessions.