agentleFS
d2a8k3ud2a8k3u/claude-code-memory/skills/memory-maintain/SKILL.md

memory-maintain

Skill8 starsChanged 9 months agoMITArchived repositoryView on GitHub

Maintain memory database — deduplicate accumulative records, consolidate near-duplicate episodics, remove junk procedurals and low-value patterns, and split large multi-topic memories into focused units.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 4 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run memory_health to get current counts, types, and staleness stats.

    line 18
  2. Very specific:

    If multiple records have the tech-stack tag AND content starts with Technology stack used::

    line 26
  3. Very specific:

    Tag collision check: If any record has the tech-stack tag but does NOT start with Technology stack used: (e.g., a detailed dependencies …

    line 30
  4. Very specific:

    If content starts with Task: — extract the task text after the marker, strip markdown bold, and use first ~80 chars as the title

    line 44
  5. Very specific:

    If content starts with Files modified: — derive a title like "Session: N files in dir1, dir2"

    line 45
  6. Very specific:

    If content contains both Task: and Files modified: lines — prefer the task text for the title

    line 46
  7. Distinctive:

    Keep the one with the cleanest, shortest command chain

    line 70
  8. Very specific:

    Read it with memory_get

    line 93
  9. Very specific:

    Create relates_to relations between sibling sections using memory_relate

    line 99
  10. Very specific:

    Delete the original monolithic memory with memory_delete

    line 100
  11. Very specific:

    Mixed content: If a memory contains both facts and procedures, split by type (store as semantic and procedural separately).

    line 104
  12. Distinctive:

    Lists: If a memory is a long list, group related items together.

    line 105
  13. Distinctive:

    Be conservative with deletion: If unsure whether a record is junk, keep it.

    line 122
  14. Distinctive:

    Preserve the best record: when deduplicating — pick the one with the most items, highest importance, or most recent date.

    line 123

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Memory Maintenance

Clean up noise, deduplicate records, and reorganize large memories. Run this after upgrading the plugin, when search quality degrades, or when memories have grown large and unfocused.

Steps

1. Assess

Run memory_health to get current counts, types, and staleness stats.

2. Deduplicate accumulative records

These records should exist at most once each. Search for duplicates and merge them.

Tech-stack:

  1. memory_search("Technology stack used", type="semantic")
  2. If multiple records have the tech-stack tag AND content starts with Technology stack used::
    • Collect all technology items from each record's comma-separated list
    • memory_update the most comprehensive record with the union of all items (sorted alphabetically)
    • memory_delete all other duplicates
  3. Tag collision check: If any record has the tech-stack tag but does NOT start with Technology stack used: (e.g., a detailed dependencies description from memory-init), rename its tag from tech-stack to tech-stack-detail via memory_update to prevent merge conflicts.

Active modules:

  1. memory_search("Active modules directories", type="semantic")
  2. If multiple records have the active-modules tag AND content starts with Active modules/directories::
    • Same approach: union all items, update the best, delete the rest
  3. Tag collision check: Same as above — rename non-accumulative records' tag to active-modules-detail.

3. Fix episodic titles

Episodic memories created before v1.2 often have no title, causing their content (starting with **Task:** or **Files modified:**) to be used as the label. This makes them indistinguishable in graphs and lists.

  1. memory_list(type="episodic", limit=100) — scan all episodic records
  2. For each record that has no title (title is null/empty):
    • If content starts with **Task:** — extract the task text after the marker, strip markdown bold, and use first ~80 chars as the title
    • If content starts with **Files modified:** — derive a title like "Session: N files in dir1, dir2"
    • If content contains both **Task:** and **Files modified:** lines — prefer the task text for the title
    • memory_update(id, { title: derivedTitle })
  3. Skip records that already have a meaningful title

4. Consolidate episodic records

  1. memory_list(type="episodic", limit=50) — scan through all episodic records
  2. Delete meaningless records that match ANY of:
    • Task is [Request interrupted by user for tool use] with no tools AND no files AND no memory ops
    • Content is just a task summary under 15 characters with no tools or files
    • Content is empty or contains only boilerplate markers
  3. Consolidate near-duplicate session-end records: Group episodic records by tag:
    • session-end records: If multiple have the same or near-identical task text (e.g., all say [Request interrupted by user for tool use] with similar tool lists), keep only the one with the highest importance. Delete the rest.
    • session-files records: If multiple have the same or near-identical file list (>80% overlap), keep only the most recent. Delete the rest.
    • session-errors records: Same approach — deduplicate near-identical error records.

5. Clean procedural records

  1. memory_list(type="procedural", limit=50) — scan through all procedural records
  2. Delete junk procedurals that match ANY of:
    • Content is over 500 characters (real workflows are short command chains, not test scripts)
    • Commands contain mktemp, sqlite3, manual test setup, or multi-line heredocs — these are test/debug artifacts, not reusable workflows
    • Commands contain hardcoded temp paths (/var/folders/, /tmp/tmp.)
  3. Deduplicate by category: Group procedural records by their category tag (build, test, lint, install, deploy). If multiple records share the same category:
    • Keep the one with the cleanest, shortest command chain
    • Delete the rest

6. Clean low-value patterns

  1. memory_list(type="pattern", limit=50) — scan through all pattern records
  2. Delete low-value patterns that match ANY of:
    • Content is just a list of tool names with no actionable insight (e.g., **Tools:** TaskCreate, TaskUpdate, Edit, Bash)
    • Content is just a list of file paths with no context about what was done or why
    • Title is a generic auto-generated name like "X Y Z pattern: Tools" and content provides no real pattern
  3. Keep patterns that:
    • Describe a recurring behavioral theme (e.g., "Claude not using memory proactively")
    • Identify frequently co-modified files with context about why
    • Capture genuine recurring workflows or decisions

7. Split large multi-topic memories

For each type (semantic, procedural, pattern), run memory_list with a reasonable limit (20-50). Identify memories that are:

  • Over 500 characters
  • Contain multiple distinct topics (headers, bold sections, or topic shifts)

For each candidate:

  1. Read it with memory_get
  2. Identify natural topic boundaries
  3. For each topic section:
    • Store as a new memory with memory_store using the same type, tags, context, and source
    • Title: "{original title}: {section topic}" (or just the section topic if no original title)
    • Content: just the section's content
  4. Create relates_to relations between sibling sections using memory_relate
  5. Delete the original monolithic memory with memory_delete

Edge cases:

  • Prose paragraphs: Identify where the topic shifts even without headers. Create separate memories for each topic.
  • Mixed content: If a memory contains both facts and procedures, split by type (store as semantic and procedural separately).
  • Lists: If a memory is a long list, group related items together.

8. Report

Summarize what was done:

  • Accumulative records deduplicated (before -> after count)
  • Tag collisions fixed
  • Episodic titles fixed (count)
  • Episodic records consolidated (deleted count)
  • Procedural records cleaned (deleted count)
  • Patterns cleaned (deleted count)
  • Large memories split (count processed, new memories created, relations created)
  • Final memory count from memory_health

Guidelines

  • Default scope is steps 2-7 (full maintenance). Use the argument to narrow scope if needed.
  • Be conservative with deletion. If unsure whether a record is junk, keep it.
  • Preserve the best record when deduplicating — pick the one with the most items, highest importance, or most recent date.
  • Don't split small memories — Only process memories >500 chars with multiple topics.
  • Preserve metadata — Keep the same type, tags, context, and source on split pieces.
  • Maintain relations — Create relates_to between sibling sections.
  • Check before storing — Use memory_search to avoid creating duplicates of existing memories.
  • Respect the argument filter — If the user specified a scope (e.g., 'episodic only'), only run that step.

$ARGUMENTS

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.