refactor-memory

refactor-memory is a skill for Claude Code from vinta/hal-9000. It costs 64 tokens per session (1,116 once invoked), scanned A, original, MIT.

A procedure for cleaning up Claude Code's automatic project memory, including its MEMORY.md index and topic files. It reviews stored notes against project rules and current code to decide what remains useful.

In plain words
What is it for?
Use it to audit memory files, identify notes to delete or revise, fix inconsistencies, and move lasting decisions to project instructions when appropriate.
Why use it?
It removes stale, duplicated, contradictory, or easily looked-up notes so future sessions spend less attention on information that no longer helps.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions CLAUDE.md; names the AskUserQuestion tool.

Part of the hal-skills plugin — 12 skills shipped together

Good fit Use it to audit memory files, identify notes to delete or revise, fix inconsistencies, and move lasting decisions to project instructions when appropriate.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/vinta/hal-9000/refactor-memory
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.

Any agent
npx skills add vinta/hal-9000 --skill refactor-memory
Clone the repo
git clone --depth 1 https://github.com/vinta/hal-9000

Made for: Claude Code.

Or install hal-skills, the plugin that ships this one along with the rest of its 12 skills.

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 refactor-memory

README.md
[![agentmods](https://agentmods.dev/badge/skills/vinta/hal-9000/refactor-memory.svg)](https://agentmods.dev/skills/vinta/hal-9000/refactor-memory)
Your own site
<a href="https://agentmods.dev/skills/vinta/hal-9000/refactor-memory"><img src="https://agentmods.dev/badge/skills/vinta/hal-9000/refactor-memory.svg" alt="Measured on agentmods" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,116 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 3 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 16
    Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
    Fix: Validate all tool parameters against an allowlist. Reject dangerous parameter values (shell=True, --force, -rf /) and use safe defaults.
  • medium Rogue Agent · line 31
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
  • medium Excessive Agency · line 40
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.1 $0.00064 $0.01116
Opus 5 $0.00032 $0.00558
Sonnet 5 $0.00013 $0.00223
Haiku 4.5 $0.00006 $0.00112

Measured 2d ago against content hash 0ede79482efa, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

refactor-memory 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 2d 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/refactor-memory/SKILL.md · 41 lines

How it starts

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

Overview

Refactor a project's auto memory. MEMORY.md is loaded into every session and each topic file is read on recall, so a memory earns its place only by carrying what no lookup returns: a decision, a correction, a measured gotcha. Everything else spends index lines and recall attention on facts that change no future action.

Instructions

  1. Pick the target. If the invocation names a directory, use it. Otherwise use the memory directory named in this session's system prompt, the one holding MEMORY.md. Read MEMORY.md, every topic file, and what the audit compares against: the loaded CLAUDE.md files, .claude/rules/, and ~/.claude/rules/.

  2. Fetch the yardstick. Fetch https://code.claude.com/docs/en/memory#auto-memory for the current index load limits, the memory types, and what auto memory is meant to skip.

  3. Audit topic files. Give every topic file exactly one verdict, with the evidence beside it. Done when no file lacks one.

    • contradiction: conflicts with another memory, or with the current state of the rule, CLAUDE.md line, or code it describes. Record both sides.
    • delete: no future action depends on it. Covers a memory whose tracked work is done or whose question is settled, and a memory the agent could look up when it matters: in the code, git history, a loaded CLAUDE.md or rules file, or the vendor docs. Check each such claim by looking, not from memory: grep the repo, read the rule, fetch the docs page, since a gotcha measured months ago may be documented now. Delete outright, never rewrite into a done or synced record.
    • rewrite: right fact, wrong form: the index hook or description disagrees with the body; a [[link]] names a filename or a slug no memory carries, since links target the name: field; a relative date; two files carrying one fact, which merge into one.
    • promote: a feedback or project memory that is really a standing instruction. Destination by scope: the project CLAUDE.md when it applies to every task in this project, ~/.claude/CLAUDE.md when it applies in every project, and in both cases only if it passes that file's keep bar in the refactor-claude-md skill, since the line is loaded into every session; a paths:-scoped file in .claude/rules/ or ~/.claude/rules/ when it applies to some paths; a skill when it is a multi-step workflow. A reference memory about how a tool behaves stays a memory, since rules record decisions, not tool behavior. Name the destination.
    • keep: earns its index line and recall cost as written.

Read the full file on GitHub · 41 lines

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. 2d ago First seen · 41 lines · 64 tokens per session scan A 0ede79482efa

Subscribe to this mod's changes

refactor-memory is a skill published in the GitHub repository vinta/hal-9000 (128 stars, last pushed today), licensed MIT. It adds 64 tokens to every session and 1,116 once invoked, about $0.0003 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-09-05.

Related

Other skills, from other repositories

memory

Split memory system with USER.md for durable personal profile and MEMORY.md for token-budgeted operational context.

RikyZ90/ShibaClaw · 22 tokens

knowledge-audit

Review and clean up stored memories — find duplicates, contradictions, stale entries, and consolidate.

n24q02m/mnemo-mcp · 21 tokens

temporal-query

Answer time-travel questions over stored memory — what was believed at a past point in time, when a belief changed, and what replaced it. Use when the user says "as of", "back in", "at the time", "history of", "timeline", "what did I think then", or asks why a current memory contradicts an older one.

n24q02m/mnemo-mcp · 77 tokens

memory-commit

Use when the user explicitly says "remember this", "save this", "ghi nho", "luu lai", "save for next time", or otherwise asks to persist the immediately preceding context. Captures with the appropriate contexttype (decision, preference, fact, skill, task, conversation) so future sessions can retrieve it accurately.

n24q02m/mnemo-mcp · 72 tokens

recall-context

Use at session start, before significant decisions, or when a new task references a known project to recall mnemo memories matching the current working directory, recently edited files, or topic keywords. Helps maintain continuity across sessions and avoid redoing past research.

n24q02m/mnemo-mcp · 53 tokens

passport-bootstrap

Use when the user installs mnemo-mcp on a fresh machine and wants to restore prior memory state from S3 or Google Drive (Phase 2 passport sync). Triggers on phrases like "set up mnemo on this machine", "restore my memory passport", "import passport", "bootstrap mnemo", or when the user says they got a new laptop / VM…

n24q02m/mnemo-mcp · 83 tokens