---
name: slim
description: "Self-audit and slim down Claude Code config to reduce per-turn token overhead. Analyzes CLAUDE.md, MEMORY.md, rules/*.md for bloat — duplicates, inline details that should be pointers, oversized files. Chinese triggers: 瘦身、太肥了、token 太多、context 不夠用、幫我精簡. English triggers: slim down, too bloated, reduce tokens, context too full, audit my config."
---

# Slim — Config Token Audit & Cleanup

Self-diagnose and fix token bloat in your Claude Code configuration files.

## When to Use

- Context filling up too fast
- After adding new rules, memory, or MCP tools
- Periodic maintenance (monthly)

## Audit Process

### Step 1: Measure

Read and measure every file that loads per-turn:

1. **CLAUDE.md** — `~/.claude/CLAUDE.md` + any project-level CLAUDE.md
2. **rules/*.md** — `~/.claude/rules/*.md`
3. **MEMORY.md** — `~/.claude/projects/*/memory/MEMORY.md`
4. **MCP tool count** — count deferred tool names in system prompt

For each file, estimate tokens (bytes / 3.5 ≈ tokens).

Report as table:

```
| File | Bytes | ~Tokens | Target | Status |
|------|-------|---------|--------|--------|
| CLAUDE.md | 2,569 | ~730 | <3,000 | ✅ OK |
| MEMORY.md | 8,200 | ~2,340 | <2,000 | ⚠️ OVER |
```

**Targets:**
- CLAUDE.md: < 3,000 tokens (rules + pointers only, no full procedures)
- MEMORY.md: < 2,000 tokens (index only, each entry < 150 chars)
- Individual rules/*.md: < 500 tokens each
- Total per-turn overhead (all memory files): < 8,000 tokens

### Step 2: Diagnose

For each file over target, identify the cause:

**Common bloat patterns:**
- 📋 **Duplicate**: Content exists in both CLAUDE.md and a SKILL.md file
- 📖 **Inline detail**: MEMORY.md has full paragraphs instead of one-line pointers
- 🔁 **Redundant rules**: Multiple rules/*.md files say the same thing
- 📦 **Stale content**: Outdated info (abandoned tools, old configs) still loaded every turn
- 🗄️ **Should be searchable**: Operational details (commands, configs) that belong in QMD-indexed files, not per-turn loaded files

For each issue found, report:

```
[FILE:LINE] [PATTERN] — description
  → ACTION: move to [destination] / merge into [file] / delete
  → SAVES: ~N tokens/turn
```

### Step 3: Propose

Present a ranked action plan ordered by tokens saved:

```
═══════════════════════════════════
SLIM AUDIT RESULTS
═══════════════════════════════════

Current per-turn overhead: ~X tokens
Target: < 8,000 tokens

Actions (ranked by impact):
1. [~2,000 saved] Move Core Loop from CLAUDE.md → already in SKILL.md
2. [~1,500 saved] Extract MEMORY.md inline blocks → memory subfiles
3. [~800 saved]   Merge rules/testing.md + rules/coding-style.md
...

Total potential savings: ~N tokens/turn

═══════════════════════════════════
```

### Step 4: Execute (after user confirms)

For each approved action:

1. **If moving to memory subfile**: Create the subfile with proper frontmatter, update MEMORY.md pointer
2. **If moving to QMD**: Verify the target collection exists, write file, run `qmd update && qmd embed`
3. **If deleting duplicate**: Verify the canonical copy exists before deleting
4. **If merging rules**: Combine content, delete redundant file

After all changes, re-measure and report the before/after:

```
| Metric | Before | After | Saved |
|--------|--------|-------|-------|
| CLAUDE.md | 3,200 tok | 800 tok | 75% |
| MEMORY.md | 8,000 tok | 2,000 tok | 75% |
| Total per-turn | 14,000 tok | 6,000 tok | 57% |
```

## Rules

- **Never delete content without confirming a copy exists elsewhere** (SKILL.md, memory subfile, or QMD collection)
- **Always ask before executing** — propose first, execute after user says OK
- **MEMORY.md is an index, not storage** — if an entry is more than one line, it's bloat
- **CLAUDE.md is for rules, not procedures** — if it has step-by-step instructions, those belong in a SKILL.md
- **QMD `claude-memory` collection** indexes `~/.claude/projects/-Users-coolthor/memory/*.md` — operational details should live there, searchable on demand
- **Don't touch SKILL.md files** — those are already demand-loaded, not per-turn
