kiyoraka/project-ai-memorycore/memory-compaction-system
Claude Code and agent skill by kiyoraka/project-ai-memorycore
- community
Checking that the SKILL.md file is still in the repository.
MUST use when user says 'compact memory', 'compact [file]', 'check budgets', 'set budget', 'restore compaction', or before any 'save' whose target memory file exceeds its budget in compaction/compaction-policy.md.
Install
npx vskill@latest install kiyoraka/project-ai-memorycore/memory-compaction-systemSKILL.md
Memory Compaction — Budget-Aware Memory Skill
Keep memory small without making it forget.
Activation
When this skill activates for a compaction pass, output:
Never rewrite a memory file without first writing a snapshot.
Context Guard
| Context | Status | |
|---|---|---|
| User says "compact memory" | ACTIVE — compact all over-budget files | |
| User says "compact [file]" | ACTIVE — compact one file | |
| User says "check budgets" | ACTIVE — report sizes vs budgets | |
| User says "set budget ..." | ACTIVE — update policy | |
| User says "restore compaction ..." | ACTIVE — roll back from snapshot | |
| Generic "save" on a budgeted file over budget | ACTIVE — compact then save | |
| Save on a file under budget | DORMANT — save normally | |
| No save or compaction request | DORMANT — no action |
Budget Check Protocol
Before writing any save to a budgeted file:
- Read
compaction/compaction-policy.mdfor the file's budget and newest-tier size. - Measure the current file (lines or chars per the policy unit).
- If under budget → save normally, no compaction.
- If over budget → run the Compaction Protocol below, then save.
Compaction Protocol
Step 1: Snapshot
- [ ] Run
dateto get the current timestamp. - [ ] Copy the target file to
compaction/snapshots/[basename]-[YYYY-MM-DD].md
(use only the filename without its directory — e.g. main-memory, not main/main-memory — so snapshots never create nested subdirectories inside compaction/snapshots/).
- [ ] If a snapshot for today already exists, append
-HHMMSS(seconds included) to avoid
overwriting. If a same-second collision is still possible, use a sequential suffix (-v2, -v3).
Step 2: Split Into Tiers
- [ ] Newest tier — the last N entries per the policy. Never touched.
- [ ] Mid-age tier — entries between newest and oldest. Light summarization only.
- [ ] Oldest tier — everything older. Target for heavy compaction.
Deterministic boundary: the newest tier is the last N entries named in the policy.The oldest tier is everything below the newest tier, down to **30% of the file's totalline count** (rounded to whole entries). Anything between is the mid-age tier. This keepscompaction results consistent across sessions.
Step 3: Compact the Oldest Tier
- [ ] Read every entry in the oldest tier.
- [ ] Distill into a dense summary that keeps:
- Verified facts, paths, commands, and settings
- Decisions and the reasons behind them
- User preferences and recurring corrections
- [ ] Drop:
- Redundant or duplicated statements
- Resolved chatter and one-off context
- Filler and transitional notes
- [ ] Never include secrets, tokens, passwords, or credentials in the summary.
Step 4: Rewrite
- [ ] Replace the verbose oldest-tier entries with a single block:
- [ ] Keep the mid-age and newest tiers in place.
- [ ] Append the new save below.
Step 5: Verify and Report
- [ ] Confirm the file is now under budget.
- [ ] Confirm no fact, decision, or preference was lost (compare against snapshot if unsure).
- [ ] Report:
Restore Protocol
When the user says restore compaction [snapshot]:
- Confirm the snapshot exists in
compaction/snapshots/. - Show the user the snapshot date and size.
- Ask for confirmation before overwriting the current file.
- Replace the current file with the snapshot contents.
Safety Rules
- Snapshot before every compaction — no exceptions.
- Never compact the newest tier.
- Preserve all facts, decisions, and preferences.
- Never summarize secrets into a shared
Compacted Historyblock. - Confirm before first compaction of a user-customized file.
- Compaction is summarization, not deletion — knowledge moves to a denser form, it does not disappear.
A good compaction is one the user never notices, except that memory stopped overflowing.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingFeature/Memory-Compaction-System/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kiyoraka/project-ai-memorycore/memory-compaction-system)