memory-md-cleanup

memory-md-cleanup is a skill for Claude Code, Codex from humanerd-drew/opencode-drewgent. It costs 47 tokens per session (3,844 once invoked), scanned A, original, MIT.

A skill for cleaning up an agent’s persistent MEMORY.md file when it approaches its 8,000-character limit. It removes resolved or one-time notes while preserving active operational facts.

In plain words
What is it for?
Use it to measure memory usage, classify entries as removable or active, clean the file, and verify the result.
Why use it?
It prevents accumulated memory from reaching its size limit and losing useful information, while checking for concurrent edits before making changes.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/humanerd-drew/opencode-drewgent/memory-md-cleanup
Any agent
npx skills add humanerd-drew/opencode-drewgent --skill memory-md-cleanup
Clone the repo
git clone --depth 1 https://github.com/humanerd-drew/opencode-drewgent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for memory-md-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/memory-md-cleanup.svg)](https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/memory-md-cleanup)
Your own site
<a href="https://agentmods.dev/skills/humanerd-drew/opencode-drewgent/memory-md-cleanup"><img src="https://agentmods.dev/badge/skills/humanerd-drew/opencode-drewgent/memory-md-cleanup.svg" alt="Measured on agentmods" height="20"></a>
Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,844 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00047 $0.03844
Opus 5 $0.00023 $0.01922
Sonnet 5 $0.00009 $0.00769
Haiku 4.5 $0.00005 $0.00384

Measured 3d ago against content hash 93a4ee87ba59, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-md-cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/brain/memory-md-cleanup/SKILL.md · 209 lines

How it starts

The opening of the file, as written. The whole thing — 209 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MEMORY.md Cleanup

~/.{{AGENT_NAME_LOWER}}/P2-hippocampus/memories/MEMORY.md hits 8K char cap when auto-accumulated + user entries pile up. Manual cleanup needed — auto-cleanup is NOT implemented (growth-2026.md "분기별 메모리 정리 자동화" is TODO).

Trigger

  • System prompt shows [98% — 7,901/8,000 chars] or similar near-cap status
  • User says "메모리 정리" / "MEMORY.md 정리"

Steps

1. Read current state

content = open('~/.{{AGENT_NAME_LOWER}}/P2-hippocampus/memories/MEMORY.md').read()
print(f'chars: {len(content)}, cap usage: {len(content)/8000*100:.1f}%, entries (§): {content.count(chr(167))}')

2. Check for concurrent writes

MEMORY.md.lock mtime 5분+ stale이 아니면 wait. 그 외 진행.

3. Classify entries

Cut (resolved/one-time):

  • "follow-up" / "patched" / "fixed" / "완료" / "✅" 단어 등장
  • 다른 entry가 미참조하는 historical event
  • system prompt active docs (SELF 모델, KANBAN_INDEX, architecture-dataflow)에서 미참조

Keep (operational/active):

  • system prompt active docs에서 참조되는 facts
  • port / path / plist label / version / token / CF account 같은 operasional numbers
  • 다음 session에 적용될 trigger pattern (self-critique framing, cron infra, mock patterns)
  • ongoing incident 핵심 findings (resolve되기 전)

4. Present options via mcp_clarify

H1: aggressive — cut all candidates (0 risk, max headroom) H2: conservative — cut 1~2 largest만 H3: increase cap (8000→12000, config edit, 매 session inject 비용 증가)

User timeout → best judgement = H1. 0 risk, 가장 많은 buffer, follow-up으로 추가 trim 가능.

5. Write new file with mcp_write_file

  • Line 1: [YYYY-MM-DD cleanup: H{N}, removed {N} entries (~{chars} saved). Active entries preserved.]
  • Following: original format — entry line + § on its own line as separator

6. Fix stale cross-references

제거된 entry를 참조하는 warning이 다른 entry에 남아있으면 patch로 정리. 예: "⚠️ bot.py의 M2.7 호출은 6/1 follow-up patch로 M3 통일됨" — 제거된 follow-up entry를 가리키던 warning을 resolved 상태로 update.

7. Verify

content = open('~/.{{AGENT_NAME_LOWER}}/P2-hippocampus/memories/MEMORY.md').read()
assert len(content) < 8000, f'still over cap: {len(content)}'
print(f'OK: {len(content)} chars ({len(content)/8000*100:.1f}% of 8K cap)')

Read the full file on GitHub · 209 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 209 lines · 47 tokens per session scan A 93a4ee87ba59

Subscribe to this mod's changes

memory-md-cleanup is a skill published in the GitHub repository humanerd-drew/opencode-drewgent (2 stars, last pushed 1mo ago), licensed MIT. It adds 47 tokens to every session and 3,844 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

llm-wiki

The foundational knowledge distillation pattern for building and maintaining an AI-powered Obsidian wiki. Based on Andrej Karpathy's LLM Wiki architecture. Use this skill whenever the user wants to understand the wiki pattern, set up a new knowledge base, or needs guidance on the three-layer architecture (raw sources…

Ar9av/obsidian-wiki · 113 tokens

wiki-lint

Audit and maintain the health of the Obsidian wiki. Use this skill when the user wants to check their wiki for issues, find orphaned pages, detect contradictions, identify stale content, fix broken wikilinks, or perform general maintenance on their knowledge base. Also triggers on "clean up the wiki", "what needs…

Ar9av/obsidian-wiki · 152 tokens

wiki-query

Answer questions by searching the compiled Obsidian wiki. Use this skill when the user asks a question about their knowledge base, wants to find information across their wiki, asks "what do I know about X", "find everything related to Y", or wants synthesized answers with citations from their wiki pages. Also use when…

Ar9av/obsidian-wiki · 200 tokens

wiki-update

Sync the current project's knowledge into the Obsidian wiki. Use this skill from any project when the user says "update wiki", "sync to wiki", "save this to my wiki", "update obsidian", or wants to distill what they've been working on into their knowledge base. This is the cross-project skill that lets you push…

Ar9av/obsidian-wiki · 100 tokens

hermes-history-ingest

Ingest Hermes agent history into the Obsidian wiki. Use this skill when the user wants to mine their past Hermes sessions for knowledge, import their /.hermes folder, extract insights from previous Hermes conversations, or says things like "process my Hermes history", "add my Hermes memories to the wiki", "ingest…

Ar9av/obsidian-wiki · 108 tokens

memory-bridge

Browse and compare wiki knowledge by which AI tool originally produced it. Use this skill when the user says "/memory-bridge", "browse codex memory", "what did codex know about X", "show me claude knowledge", "cross-tool memory", "what does hermes know that claude doesn't", "show me knowledge from ", "compare my AI…

Ar9av/obsidian-wiki · 134 tokens