| name | prune |
| description | Clean up old events and manage card lifecycle |
| args | [--dry-run] [--events] [--cards] |
| user_invocable | true |
/session-memory:prune — Clean Up Memory
Manage memory storage: remove old events, detect duplicate cards, suggest deprecations.
Operations
1. Event Cleanup (--events or default)
Remove events older than maxDaysToKeep (default: 30 days):
- Show: "Found X events older than 30 days in Y files"
- Ask user confirmation before deleting
- Interest signals (.interest.jsonl) are also cleaned
2. Card Dedup Detection (--cards or default)
Scan .claude/memory/cards/*.md for potential duplicates:
Similarity check:
- Same file references (files[] overlap >= 50%)
- Similar titles (common words >= 60%)
- Same tags overlap >= 50%
- Same type
For each duplicate pair found:
Potential duplicates:
1. mem_20260309_a1b2c3.md: "Auth null check"
2. mem_20260312_d4e5f6.md: "Auth middleware guard"
Overlap: files=[src/auth.ts], tags=[auth]
Suggested action:
- Merge into card 1 (older, more evidence)
- Deprecate card 2
- List all potential duplicates
- Ask user which action to take for each pair
- Never auto-delete cards — always ask first
3. Card Lifecycle Review
List cards by status and activity:
- Stale cards: active cards with no evidence additions in 60+ days
- Draft cards: cards still in draft status (suggest review → active or deprecate)
- Deprecated cards: list for awareness
Display Format
=== Session Memory Prune Report ===
Events:
Total: 450 events across 3 files
Stale (>30 days): 120 events
Action: [Delete stale events? y/n]
Cards:
Total: 12 cards (8 active, 3 draft, 1 deprecated)
Potential duplicates: 2 pairs
Stale (no activity 60+ days): 1 card
Duplicate pair 1:
- mem_20260309_a1b2c3.md: "Auth null check" (active, imp:2)
- mem_20260312_d4e5f6.md: "Auth middleware" (draft, imp:1)
Suggestion: Merge evidence into first, deprecate second
Stale cards:
- mem_20260201_x1y2z3.md: "Old config pattern" (last evidence: 2026-02-01)
Suggestion: Review — deprecate if no longer relevant
Storage:
Events: 45 KB
Cards: 12 KB
Summaries: 28 KB
Total: 85 KB
Important Rules
- NEVER delete cards without user confirmation
- NEVER delete events without showing count and asking
- --dry-run shows what would happen without making changes
- Deprecated cards are kept (not deleted) for history
- When merging duplicates, combine Evidence sections