memory-compaction

Compact Claude Code's MEMORY.md index to stay under the 12 KB limit.

Updated Apr 17, 2026
One-click install
npx skills add https://github.com/rajnishkhatri/AgentsFramework --skill memory-compaction-rajnishkhatri
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-compaction
Source: https://github.com/rajnishkhatri/AgentsFramework/tree/main/.cursor/skills/memory-compaction
Command: npx skills add https://github.com/rajnishkhatri/AgentsFramework --skill memory-compaction-rajnishkhatri

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill ensures Claude Code's persistent memory index remains optimized and prevents data loss due to index truncation.

Core Features & Use Cases

  • Memory Index Compaction: Shrinks MEMORY.md to stay under the 12 KB limit, preserving memory entries.
  • Trigger Conditions: Automatically run when MEMORY.md exceeds 15 KB or on user request.
  • Use Case: When working with Claude Code, if you notice the memory index growing large, use this Skill to compact it and avoid data truncation.

Quick Start

Run the memory-compaction skill to compact the memory index.

Frequently Asked Questions about memory-compaction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent MEMORY.md data loss when the Claude Code memory index gets too large?

To prevent MEMORY.md data loss, use a memory index compaction process to shrink the file under the 12 KB limit. This resizes hooks and preserves persistent memory entries before truncation occurs.

When should I run memory index compaction for my AI agent?

You should run memory index compaction when your MEMORY.md file exceeds 15 KB or upon user request. Triggering it at this threshold prevents the system from automatically truncating and losing persistent memory data.

What is the best way to compact Claude Code's persistent memory index?

The best way to compact the persistent memory index is to run an automated compaction script that resizes hooks and reduces the MEMORY.md file size. This ensures the index stays under the 12 KB limit without data loss.

Does memory index compaction delete existing hooks in MEMORY.md?

Memory index compaction does not delete existing hooks but resizes them to fit under the 12 KB limit. It specifically preserves memory entries while shrinking the overall file size to avoid data loss.

How do I verify the health of my Claude Code memory index after compaction?

You can verify memory index health by running dedicated analysis and verification scripts. These scripts check the compacted MEMORY.md file to ensure the index is optimized and operating safely under the 12 KB threshold.