Grand Diomande Research Β· Full HTML Reader

Memory Defrag πŸ§ πŸ”§

Memory Defrag is your AI-powered note janitor. It scans your memory files, finds duplicates and related content, suggests consolidations, and helps reorganize your second brain.

Agents That Account for Themselves research note experiment writeup candidate score 24 .md

Full Public Reader

---
name: memory-defrag
description: AI that reorganizes your notes, finds duplicates, suggests consolidation - keep your second brain clean
homepage: https://github.com/clawdbot
user-invocable: true
command-dispatch: defrag
metadata.clawdbot: {"version": "2.0.0", "hef_generation": 6}
---

Memory Defrag πŸ§ πŸ”§

> _"A cluttered mind can't think clearly. Neither can cluttered notes."_

Memory Defrag is your AI-powered note janitor. It scans your memory files, finds duplicates and related content, suggests consolidations, and helps reorganize your second brain.

What's New in Gen 6

### πŸ”— Reference Graph
- Detects `[[wiki-links]]`, `@mentions`, and file paths
- Maps connections between notes
- Identifies truly isolated content

### πŸ“ˆ Growth Trends
- Tracks memory growth over time
- Visualizes word count and health trends
- Helps identify documentation patterns

### 🌱 Freshness Decay
- Exponential decay model for content freshness
- Highlights stale areas needing attention
- Smarter orphan detection

### πŸ”’ Safe Operations
- Automatic backups before any changes
- Easy restore from any backup
- Non-destructive archive system

### πŸ” N-gram Similarity
- Character n-gram matching for better duplicate detection
- Catches rephrased content that keyword matching misses
- Combined with keyword Jaccard for hybrid accuracy

What It Does

### πŸ” Duplicate Detection
- N-gram + keyword similarity (hybrid approach)
- Finds near-duplicates across files
- Groups related content that should be merged

### πŸ“Š Content Analysis
- Maps your knowledge topology
- Identifies orphaned notes (stale + no connections)
- Finds dense clusters (over-documented areas)
- Spots sparse zones (under-documented areas)
- Tracks content freshness with decay model

### πŸ”— Reference Connectivity
- Detects `[[wiki-links]]` between notes
- Tracks `@mentions` and file references
- Shows connection graph statistics

### πŸ—‚οΈ Smart Suggestions
- Merge: Combine similar content
- Archive: Move stale content safely
- Split: Break up oversized files
- Link: Create topic indexes

Commands

CommandDescription
`/defrag scan`Full scan of memory files
`/defrag scan <path>`Scan specific file/directory
`/defrag duplicates`Show duplicate/similar content
`/defrag clusters`Show content clusters
`/defrag orphans`Find stale disconnected notes
`/defrag refs`Show reference connectivity
`/defrag suggest`Get consolidation suggestions
`/defrag apply <id>`Apply a suggestion (with backup)
`/defrag preview <id>`Preview what a suggestion would do
`/defrag status`Show scan status and stats
`/defrag health`Overall memory health report
`/defrag trends`Show growth over time
`/defrag archive`Show archive candidates
`/defrag backups`List available backups
`/defrag restore <id>`Restore from backup

Quick Start

User: /defrag scan

Memory Defrag πŸ§ πŸ”§ Scan Complete

πŸ“Š Stats:
β€’ Files scanned: 12
β€’ Sections analyzed: 847
β€’ Total words: 42,350
β€’ Duplicates found: 23
β€’ Clusters detected: 8
β€’ Orphans found: 15

🟒 Health Score: 78/100
🌱 Avg Freshness: 72%

πŸ’‘ Next Steps:
β€’ /defrag duplicates β€” see duplicate content
β€’ /defrag suggest β€” get consolidation ideas

Example Workflow

1. Health Check

User: /defrag health

πŸ₯ Memory Health Report

🟒 Overall Score: 78/100

πŸ“Š Stats:
β€’ 847 sections analyzed
β€’ 42,350 total words
β€’ 23 duplicate groups
β€’ 8 topic clusters
β€’ 12 pending suggestions

🌱 Freshness: 72%
πŸ”— Connectivity: 234/847 sections linked (28%)

⚠️ Issues:
  🟑 23 duplicate sections found
  🟑 15 orphaned notes detected

2. Find Duplicates

User: /defrag duplicates

πŸ” Duplicate Content Found

Group 1: πŸ”— (87% similar)
  β€’ 2025-01-29.md:234-267 β€” HEF Evolution Tasks
  β€’ 2025-01-30.md:89-120 β€” HEF Evolution Log
  β€’ 2025-01-31.md:45-78 β€” Today's HEF Work
  β†’ Suggested: merge to memory/hef-evolution.md

Group 2: πŸ”— (92% similar)
  β€’ 2025-01-28.md:156-198 β€” N'Ko Vocabulary Notes
  β€’ 2025-01-31.md:892-934 β€” N'Ko Words Learned
  β†’ Suggested: merge to memory/nko-vocabulary.md

πŸ’‘ Use /defrag suggest for actionable suggestions

3. Preview & Apply

User: /defrag preview sug_merge_dup_1

πŸ‘οΈ Preview: sug_merge_dup_1

Type: merge
Description: Merge 3 similar sections about 'HEF Evolution'
Target: memory/hef-evolution.md

Would affect:
  β€’ 2025-01-29.md β€” HEF Evolution Tasks
  β€’ 2025-01-30.md β€” HEF Evolution Log
  β€’ 2025-01-31.md β€” Today's HEF Work

Preview:
# Merged: HEF Evolution

## From 2025-01-29.md
### HEF Evolution Tasks
[content would be merged here]

...

πŸ’‘ Use /defrag apply sug_merge_dup_1 to execute

User: /defrag apply sug_merge_dup_1

βœ… Suggestion Applied

Created merged file: memory/hef-evolution.md
πŸ”’ Backup created: 20250131_143022

πŸ“ Original sections preserved. Remove from source files manually after review.

Use /defrag restore 20250131_143022 to undo if needed.

4. Track Trends

User: /defrag trends

πŸ“ˆ Memory Growth Trends

01-25 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] 38,200w 🟒
01-26 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘] 39,100w 🟒
01-27 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘] 40,500w 🟒
01-28 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘] 41,200w 🟑
01-29 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ] 42,350w 🟒
01-30 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ] 42,800w 🟒
01-31 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ] 43,100w 🟒

πŸ“ˆ Change over 7 days:
β€’ Words: +4,900
β€’ Sections: +42

5. Check References

User: /defrag refs

πŸ”— Reference Connectivity

Most Connected:
  β€’ MEMORY.md β€” Main Index (12 refs)
  β€’ projects.md β€” Active Projects (8 refs)
  β€’ goals.md β€” 2025 Goals (6 refs)

⚠️ 613 unconnected sections
Consider adding links to integrate these into your knowledge graph.

πŸ“Š Overall: 234/847 sections connected (28%)

Configuration

Create `[home-path]`:

json
{
  "scan_paths": [
    "[home-path]
    "[home-path]
  ],
  "similarity_threshold": 0.70,
  "orphan_days": 30,
  "max_file_kb": 50,
  "freshness_half_life_days": 30,
  "ngram_size": 3
}

Similarity Detection

Uses hybrid approach:
- N-grams (70
-
Keywords (30

SimilarityClassification
> 95
85-95
70-85
< 70

Freshness Model

Content freshness decays exponentially:
- Half-life: 30 days (configurable)
- Fresh (>70
- Aging (40-70
- Stale (<40

Backup System

All destructive operations create automatic backups:
- Stored in `[home-path]`
- Named with timestamp: `YYYYMMDD_HHMMSS`
- Easy restore: `/defrag restore <backup_id>`

Integration

### With Dream Weaver
- Scans dream journals for duplicates
- Suggests merging related dreams
- Identifies stale dreams for composting

### With MEMORY.md
- Monitors growth trends
- Suggests archiving old entries
- Recommends topic-based splits

### With Daily Memory
- Detects repeated patterns
- Suggests templates
- Identifies routine vs. unique events

Files

FileDescription
`defrag.py`Core defrag engine (Gen 6)
`handler.py`Command handler
`[home-path]`Scan state
`[home-path]`Pending suggestions
`[home-path]`Growth trends
`[home-path]`Backup storage

Philosophy

> Your second brain should be as organized as you want your first brain to be.
>
> But organization isn't about perfectionβ€”it's about findability.
> Memory Defrag doesn't impose structure; it reveals the structure that's already there,
> and suggests improvements that match how you actually think.

---

_Version 2.0.0 β€” HEF Generation 6_ πŸ§ πŸ”§

Promotion Decision

Attach run IDs, datasets, metrics, and reproduction commands.

Source Anchor

homelab/clawdbot/skills/memory-defrag/SKILL.md

Detected Structure

Evaluation Β· References Β· Code Anchors