# memory-defrag

Splits bloated memory files, merges duplicates, drops stale entries. Run it on a schedule or when things get messy.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 632 installs · ★ 23
- Author: basicmachines-co
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/basicmachines-co/basic-memory-skills/tree/HEAD/memory-defrag/SKILL.md
- Updated: 2026-04-20
- HTML: https://affpapa.org/en/nevibecode/skills/basicmachines-co-memory-defrag

## What it does

The skill walks your agent's memory files and tidies them. It starts with an inventory: `MEMORY.md`, the `memory/` directory with daily notes and tasks, and `memory/tasks/` underneath. For each file it notes line count, last modified date, and topic coverage.

Then it looks for the usual rot: a file past 300 lines covering half a dozen topics, the same fact sitting in three places, references to finished work, contradictions between files, nested directories like `memory/memory/memory/`. Each problem maps to an action — split, merge, prune, restructure. Before touching anything the skill writes a short plan, then applies changes one at a time and checks that nothing was lost.

Raw daily notes `memory/YYYY-MM-DD.md` stay untouched, because they are the audit trail. Tasks marked `done` older than 14 days can go. When relevance is unclear, the skill advises keeping the entry with a `(review needed)` tag instead of deleting it. A reasonable target is 15–25 topical files: fewer and files bloat, more and everything fragments. The catch: it works against your own memory layout, so on an unusual directory structure you will be editing the plan by hand.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add basicmachines-co/basic-memory-skills --skill memory-defrag -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/memory-defrag/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/memory-defrag/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add basicmachines-co/basic-memory-skills --skill memory-defrag -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/memory-defrag/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add basicmachines-co/basic-memory-skills --skill memory-defrag -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/memory-defrag/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install basicmachines-co/basic-memory-skills memory-defrag
```

2. **Manually: put the files in place**
- File: `.github/skills/memory-defrag/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add basicmachines-co/basic-memory-skills --skill memory-defrag -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/basicmachines-co/basic-memory-skills --path memory-defrag
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/memory-defrag/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add basicmachines-co/basic-memory-skills --skill memory-defrag -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/basicmachines-co/basic-memory-skills/tree/HEAD/memory-defrag/SKILL.md

## When to use it
- split `MEMORY.md` into focused topical files
- merge the same fact repeated across notes
- prune references to finished work and old dates
- resolve contradictions between memory files
- delete nested `memory/memory/` directories

## Example prompts
- defrag my agent memory and show me the plan first
- \`MEMORY.md` is over 500 lines — split it by topic
- clean `memory/tasks/` of `done` tasks older than 14 days

## Similar
- [memory-spring-cleaning](https://affpapa.org/en/nevibecode/commands/memory-spring-cleaning.md) — command · 391 installs
- [para-memory-files](https://affpapa.org/en/nevibecode/skills/para-memory-files.md) — skill · 1800 installs
- [memory-capture](https://affpapa.org/en/nevibecode/skills/memory-capture.md) — skill · 1300 installs
- [memory-intake](https://affpapa.org/en/nevibecode/skills/memory-intake.md) — skill · 766 installs
- [distill-memory](https://affpapa.org/en/nevibecode/skills/distill-memory.md) — skill · 733 installs
- [groove-utilities-memory-log-daily](https://affpapa.org/en/nevibecode/skills/groove-utilities-memory-log-daily.md) — skill · 581 installs

## Other versions with the same name
- [memory-defrag · basicmachines-co](https://affpapa.org/en/nevibecode/skills/memory-defrag.md) — 1200 installs

From the same set: [basicmachines-co/basic-memory-skills](https://affpapa.org/en/nevibecode/by/basicmachines-co/basic-memory-skills.md) — 4 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
