refactor-memory

refactor-memory is a skill for Claude Code, Codex from vinta/hal-9000. It costs 49 tokens per session (778 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 CodeCodex

Written for Claude Code and Codex: allowed-tools in frontmatter, but also agents/openai.yaml present. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions Claude Code.

Part of the hal-skills plugin — 13 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, Codex.

Or install hal-skills, the plugin that ships this one along with the rest of its 13 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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor-memory

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 778 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.00049 $0.00778
Opus 5.5 $0.00020 $0.00311
Sonnet 5.5 $0.00010 $0.00156
Haiku 4.5 $0.00005 $0.00078

Measured 20d ago against content hash 6d792ff5821a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-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 20d 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 memories so each entry carries what no lookup returns: a decision, a correction, a measured gotcha. Audit entries within the requested scope; their storage and update mechanism depend on the environment.

Instructions

  1. Pick the target. Use the scope or directory the user names, otherwise the platform default below. Load the reference for the active environment before reading memories:

    • Claude Code: references/claude-code.md for project memory files, index rules, promotion destinations, and direct edits.
    • Codex: references/codex.md for shared storage, project filtering, promotion destinations, and session-authorized updates.

    State the storage location and audit scope. A shared directory does not make every entry global.

  2. Read the evidence. Follow the reference's reading procedure and fetch its official memory guide. Compare entries against applicable loaded instructions, repository files, and current vendor documentation. Inventory the entries in scope before assigning verdicts.

  3. Audit entries. Give every entry exactly one verdict, with its location and evidence beside it. Done when no entry in scope lacks one.

    • contradiction: conflicts with another memory, or with the current instruction or code it describes. Record both sides.
    • delete: no future action depends on it. Covers completed work, settled questions, and facts recoverable from code, git history, loaded instructions, or vendor docs. Check each claim by looking: search the repo, read the instruction, fetch the docs page. Delete outright, never rewrite into a done or synced record.
    • rewrite: right fact, wrong form: a recall hook disagrees with the body, a reference is broken, a date is relative, or two entries carry one fact and should merge.
    • promote: a memory that is really a standing instruction. Name the destination using the platform reference. Promote only instructions that change future behavior and are not already covered there; use a skill for a multi-step workflow. Tool behavior alone is not a standing instruction.
    • keep: earns its index line and recall cost as written.

Read the full file on GitHub · 41 lines

Files

What ships with it

3 files 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. 20d ago Changed · +8 lines 6d792ff5821a
  2. 22d ago Changed · -1 lines 55c32862a07b
  3. 23d ago Changed · -4 lines f08a3fd9d8d1
  4. 1mo ago Changed · +1 lines 150f9df9c34d
  5. 2mo ago Changed · -1 lines 42c2805acddb
  6. 2mo ago Changed 27f54b4baf81
  7. 2mo ago Changed · -5 lines 98b969c688cf
  8. 2mo ago Changed · +2 lines · -15 tokens per session eb9f71764bf3
  9. 2mo ago Changed 282624b0aa0f
  10. 2mo 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 (144 stars, last pushed today), licensed MIT. It adds 49 tokens to every session and 778 once invoked, about $0.0002 per session on Opus 5.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

refactor-memory compared with skills from other repositories

refactor-memory next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactor-memoryvinta/hal-9000Skill144todayMITA49Claude Code, Codex
rememberlangchain-ai/deepagentsSkill32ktodayMITA71Claude Code, Codex
mem0-climem0ai/mem0Skill70k3d agoApache-2.0A177Claude Code, Codex
mem0-vercel-ai-sdkmem0ai/mem0Skill70k3d agoApache-2.0A146Claude Code, Codex
mempalace-recallMemPalace/mempalaceSkill61ktodayMITA94Claude Code
mempalace-taskMemPalace/mempalaceSkill61ktodayMITA67Claude Code
mem0-tourmem0ai/mem0Skill70k3d agoApache-2.0A47Claude Code, Codex