Logo Memory Health

Memory Health

Cộng đồng
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.

Tổng quan

Nhà phát hànhalexknowshtml
Kho mãclaude-memory-health
Tên kỹ năngmemory-health
Sao
63
Bản fork
1
Tệp đi kèm
9
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 9 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được alexknowshtml công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Memory Health trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/alexknowshtml/claude-memory-health/tree/main
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/alexknowshtml/claude-memory-health.git \
  .claude/skills/memory-health
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Memory Health trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Memory Health ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Memory Health với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

/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)

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Memory Health làm được gì?

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.

Vì sao nên dùng Memory Health trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Memory Health là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Memory Health trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/alexknowshtml/claude-memory-health/tree/main. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Memory Health?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Memory Health với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Memory Health với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Memory Health có miễn phí không?

Kỹ năng này được alexknowshtml phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇