---
name: memory-organize
description: Use when user says "reorganize memory", "clean up memory", "audit memory", or wants to maintain the structured memory system. Consolidates duplicates, updates index, and ensures consistency.
version: 0.1.0
---

# Memory Organize Skill

When invoked, audit and reorganize the entire .claude/memory/ system to remove duplicates, outdated entries, and keep index current.

## Activation

Trigger when:

- User says "reorganize memory"
- User says "clean up memory" or "audit memory"
- User asks to consolidate/merge memory entries
- User wants summary of what's in memory

## Process

### 1. Read All Files

- Open memory.md (index)
- Read all files referenced in index:
  - general.md
  - domain/\*.md
  - tools/\*.md
- Note any missing entries in index

### 2. Detect Issues

Flag:

- **Duplicates**: Same fact in multiple files (merge into one location)
- **Outdated**: Entries with dates >6 months old that are no longer relevant (delete)
- **Miscategorized**: Entry in wrong file (move to correct location)
- **Stale whys**: Entries with outdated reasoning ("temporary fix" that's still there)
- **Index gaps**: Files referenced in index but don't exist (remove from index)
- **Orphaned files**: Files in directory but not in index (add to index or delete)

### 3. Consolidate

For duplicates:

- Keep newer version or most specific version
- Merge "why" sections if both have different reasoning
- Delete redundant copies
- Note in one location which file has canonical version if split is intentional

For topics that grew too large:

- domain/authentication.md with 50 entries → split into domain/authentication.md and domain/jwt-patterns.md
- Move related entries together, update file headers

### 4. Clean Outdated

- Delete entries where "why" is no longer valid
- Delete entries about tools/approaches no longer used
- Keep historical entries only if they contain lessons (not just "used X for task Y")
- Mark as deleted in summary so user can confirm

### 5. Sort

Within each file:

- Sort entries by date (newest first)
- Ensure all entries have [YYYY-MM-DD] format
- Fix any formatting inconsistencies

### 6. Update Index

Rebuild memory.md:

- List all files currently in system
- One-line description per file (topic coverage)
- Alphabetical: general first, then domain/_, then tools/_
- Add any missing files
- Remove any obsolete entries

Example:

```markdown
- [general.md](general.md) — preferences, workflow, environment
- [domain/api-design.md](domain/api-design.md) — REST patterns, status codes, versioning
- [domain/authentication.md](domain/authentication.md) — JWT, session mgmt, CORS
- [tools/bash.md](tools/bash.md) — bash idioms, parameter expansion, process substitution
- [tools/git.md](tools/git.md) — workflows, cherry-pick, rebase, merge strategies
```

### 7. Report Changes

Show user:

```
## Memory Reorganization Summary

**Files processed**: 6 (general.md, domain/react.md, domain/api-design.md, tools/git.md, tools/bash.md, tools/postgres.md)

**Changes made**:
- Merged 3 duplicate entries (JWT patterns consolidated)
- Deleted 2 outdated entries (deprecated tool configs)
- Moved 1 entry (authentication → domain/authentication from tools/)
- Fixed 4 formatting inconsistencies
- Split domain/testing.md into domain/unit-testing.md + domain/integration-testing.md (17 entries each)
- Updated memory.md index

**Removed entries** (deleted as outdated):
- tools/old-framework.md — Framework no longer used
- domain/react.md entry about deprecated lifecycle method

**New organization**:
- 6 files, 87 total entries
- domain/ (4 files, 42 entries)
- tools/ (2 files, 31 entries)
- general.md (14 entries)

**Suggest next**:
- Review "Authentication" entries in domain/authentication.md (8 entries, high activity)
- Consider splitting if grows much larger
```

## Notes

- **Be conservative**: Don't delete entries unless clearly outdated or duplicated
- **Preserve reasoning**: "Why" sections are valuable for future context
- **Ask before deleting**: If uncertain whether to delete, show user first
- **Respect user intent**: If user has 50 entries on one topic, maybe that's intentional clustering

