Memory Health logo

Memory Health

Community
alexknowshtml
memory-health

Audit Claude Code's MEMORY.md index — check size, orphaned files, broken links, and staleness candidates. Keeps the memory index clean and under the 200-line hard limit.

Overview

Publisheralexknowshtml
Repositoryclaude-memory-health
Skill namememory-health
Stars
63
Forks
1
Bundled files
9
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 9 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by alexknowshtml on GitHub. Read the source before you install it.

Installation

Install the Memory Health AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/alexknowshtml/claude-memory-health/tree/main
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/alexknowshtml/claude-memory-health.git \
  .claude/skills/memory-health
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Memory Health in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Memory Health on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Memory Health is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

/memory-health

Audit Claude Code's MEMORY.md index. Catches size creep, orphaned files, broken links, and stale entries before they silently get truncated out of context.

Limit: Claude Code loads up to 200 lines of MEMORY.md at session start. Lines past 200 are silently truncated. Soft warn at 175, hard limit at 200. Aim to stay ≤195.

Setup

This skill is installed at .claude/skills/memory-health/ in your project. Scripts run from that directory.

Assumes Claude Code's file-based memory system:

~/.claude/projects/<your-project>/memory/
├── MEMORY.md          # index file — one pointer per memory
├── feedback_*.md      # individual memory files
└── ...

Set your memory directory (or hard-code in scripts):

bash
MEMDIR="$HOME/.claude/projects/$(basename $PWD)/memory"
COLDDIR="$(git rev-parse --show-toplevel)/cold-storage"  # project root cold storage

Phase 1 — MEMORY.md Audit

Step 1 — Check Size

bash
wc -l "$MEMDIR/MEMORY.md"

Report the count. Soft warn at 175, hard limit at 200.

Step 2 — Audit Inline Bloat

Find sections with 3+ lines of inline content and no file link — these are extraction candidates. Run:

bash
bun run scripts/check-bloat.ts

Set MEMDIR to override the default memory directory path. See scripts/check-bloat.ts for the full script.

Step 3 — Audit Orphans

Find memory files not referenced in MEMORY.md. If you're using a cold-storage/ folder (see cold-storage/_index.md), also scans those files — a demoted entry isn't an orphan, it's just cold.

bash
bun run scripts/check-orphans.ts

Set MEMDIR and COLDDIR env vars to override defaults. See scripts/check-orphans.ts for the full script.

Step 4 — Audit Broken Links

Find index entries that point to non-existent files:

bash
cd "$MEMDIR" && grep -oP '\(([^)]+\.md)\)' MEMORY.md | tr -d '()' | while read f; do
  [ ! -f "$f" ] && echo "BROKEN LINK: $f"
done

Step 5 — Flag Staleness

Scan for and present staleness candidates:

  • Lines with explicit past dates (e.g. "expires YYYY-MM-DD", "soak delete after YYYY-MM-DD")
  • Lines containing "awaiting", "pending approval", or "TODO" that are old
  • Completed one-off operations described as active
  • Sections for projects/features that no longer exist
  • Deprecated systems — entries for tools/services replaced or removed
  • One-time debug fixes — single incident root causes, not recurring patterns
  • Redundant with code — rules now baked into config or skill files directly

Present candidates with a brief reason for each. Do not remove anything without explicit approval.

Step 6 — Present Findings

Report all findings as a structured list:

  • Inline bloat candidates: section name, line count, proposed new filename
  • Orphans: filename, brief description of what it contains
  • Broken links: entry text, what file is missing
  • Staleness candidates: entry, reason it might be stale
  • Section-merge candidates: pairs of small related sections where collapsing saves 2+ lines (each ## Header + blank line costs ~2 lines)

Ask the user which items to act on. Get explicit approval for each category before proceeding.

Step 7 — Execute Approved Changes

For inline bloat extraction:

  1. Create a new file {type}_{slug}.md with proper frontmatter:
    markdown
    ---
    name: <descriptive name>
    description: <one-line description used for relevance matching>
    type: user|feedback|project|reference
    ---
    
    <content>
  2. Replace the multi-line section in MEMORY.md with a single pointer: - [Description](filename.md) — one-line summary

For orphans: Either add a pointer to MEMORY.md in the correct section, or if truly stale, confirm with user before deleting.

For broken links: Either fix the path or remove the dead entry.

For staleness: Remove the flagged lines/sections after explicit user approval.

Step 8 — Verify

bash
wc -l "$MEMDIR/MEMORY.md"

Confirm: under 200 lines (aim for ≤195), no orphans, no broken links. If still over ~160 lines after cleanup, proceed to Phase 2.


Phase 2 — Cold Storage Demotion

When the index is clean but still large, demote individual memory files to domain-specific cold storage files and remove their index entries. See cold-storage/_index.md for the pattern and example domain files.

Autonomous alternative: Run bun run scripts/scheduler.ts to demote without user interaction. The scheduler invokes Claude CLI headlessly — Claude reads the files, makes semantic decisions, and executes the file operations using real tools. Use DRY_RUN=true to check the line count without triggering demotion. Requires the Claude CLI installed and authenticated. See scripts/scheduler.ts.

Step D1 — Record starting line count

bash
wc -l "$MEMDIR/MEMORY.md"

Step D2 — Classify entries

Read MEMORY.md. For each [Title](filename.md) entry, read the linked file and classify as keep or demote.

Keep (always-on behavioral rules):

  • Always/never rules that apply across many sessions
  • Communication anti-patterns and tone corrections
  • Safety gates and critical protocols
  • Lessons from repeated mistakes (corrected 2+ times across sessions)

Demote (non-behavioral):

  • Technical facts: port numbers, API fields, credential formats, command syntax
  • Project context: active migrations, one-time decisions, completed events
  • Single-incident root cause fixes
  • Situational knowledge that only applies in specific rare contexts

For each demotion, identify which domain file it belongs to (e.g. cold-storage/infrastructure.md, cold-storage/development.md).

Step D3 — Execute demotions

For each entry to demote:

  1. Read $MEMDIR/FILENAME.md
  2. Strip the YAML frontmatter (content between and including the two --- delimiters)
  3. Append to the appropriate cold-storage/DOMAIN.md:
    ### entry-slug
    
    <body content>
  4. Delete $MEMDIR/FILENAME.md
  5. Remove the corresponding line from MEMORY.md

If no matching domain file exists, create one following the format in cold-storage/_index.md.

Step D4 — Commit

bash
git add cold-storage/ && git add "$MEMDIR" && git commit -m "chore(memory): demote N entries to cold storage"

Replace N with the actual count.

Step D5 — Verify

bash
wc -l "$MEMDIR/MEMORY.md"

Report: final line count, how many entries demoted, which domain files received entries.


File Naming Conventions

TypePatternExample
feedbackfeedback_{slug}.mdfeedback_verify_before_acting.md
referencereference_{slug}.mdreference_discord_thread_ids.md
projectproject_{slug}.mdproject_auth_rewrite.md
useruser_{slug}.mduser_timezone_preference.md

What NOT to Extract

  • Single-line entries — already index format, leave them
  • Sections that already link to a file — even with a couple extra inline lines, the file is canonical; move extras there instead

Memory System Rules

  • MEMORY.md = index only. No content, only pointers.
  • Each memory file has frontmatter: name, description, type
  • Keep index under the 200-line hard limit; ~195 is the practical working ceiling
  • Transitive links are fine (file A links to file B — both don't need to be in the index)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Memory Health AI skill do?

Audit Claude Code's MEMORY.md index — check size, orphaned files, broken links, and staleness candidates. Keeps the memory index clean and under the 200-line hard limit.

Why use Memory Health on TypingMind?

Because you install it once and use it with any model. Memory Health is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Memory Health in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/alexknowshtml/claude-memory-health/tree/main. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Memory Health?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Memory Health?

As many as you like. As long as a model supports skills, you can use Memory Health with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Memory Health AI skill free?

It is published on GitHub by alexknowshtml. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇