Remove stale or low-confidence patterns from the memory store. Consolidate similar patterns and rebuild the index. Triggers: prune patterns, clean memory, remove stale, consolidate patterns, memory cleanup
neural-pattern-score flags a pattern with confidence < 0.1memory/patterns/ directory contains pattern JSON filesmemory/patterns/index.json exists and is populatedRead memory/patterns/index.json and load full details from each pat-*.json file. Build a complete inventory:
A pattern is a removal candidate if ANY of these conditions are true:
| Condition | Threshold |
|---|---|
| Low confidence AND stale | confidence < 0.1 AND last_used > 90 days ago |
| Zero usage AND old | usage_count == 0 AND created > 60 days ago |
| High failure rate | failure_count > success_count AND usage_count >= 3 |
| Superseded | A newer pattern with the same tags has confidence > 0.7 |
Two patterns should be consolidated if:
When consolidating:
Before deleting any pattern, produce a removal list:
## Patterns Flagged for Removal
| ID | Name | Reason | Confidence | Last Used |
|----|------|--------|-----------|-----------|
| pat-old-approach | ... | low confidence + stale | 0.05 | 2025-01-15 |
If running in interactive mode, present the list to the user for confirmation. If running as part of automated maintenance, proceed with deletion.
For each confirmed removal:
memory/patterns/pat-[slug].json filememory/patterns/index.jsonFor each consolidation pair:
memory/patterns/index.jsonAfter all removals and consolidations:
memory/patterns/ for all remaining pat-*.json filesmemory/patterns/index.json from scratch to ensure consistencyAppend to logs/claude_log.md:
### Memory Pruned — [timestamp]
- Patterns before: [N]
- Removed: [N] (low confidence: [N], stale: [N], superseded: [N])
- Consolidated: [N] pairs merged
- Patterns after: [N]
memory/patterns/ directory with stale patterns removedmemory/patterns/index.jsonlogs/claude_log.md