New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Designing, reviewing, or paying for an agent memory system

Memory Engineering — engineer the forgetting, not just the remembering

by alirezarezvani · MIT license · ★ 26,349 on GitHub · updated Aug 30

Memory Engineering — engineer the forgetting, not just the remembering cover

Use when designing, reviewing, or paying for an agent memory system — adding memory to an agent, choosing between long-context / RAG / graph / agentic memory, auditing what a CLAUDE.md or memory directory actually holds, deciding what…

---
name: memory-engineering
description: Use when designing, reviewing, or paying for an agent memory system — adding memory to an agent, choosing between long-context / RAG / graph / agentic memory, auditing what a CLAUDE.md or memory directory actually holds, deciding what to keep and what to expire, or when a memory store keeps growing and nobody has said what leaves it. Prices the write path, picks which cost to pay, classifies records as facts / skills / logs, and refuses a design that has no forgetting policy.
argument-hint: "[optional: path to a memory dir, design spec JSON, or a question]"
license: MIT
metadata:
  version: 1.0.0
  build_pattern: "Four-lens synthesis (Stanford / Microsoft / Anthropic / Nvidia) + 4 deterministic stdlib scripts, with a blocking forgetting gate"
  distinct_from: "llm-wiki (maintains one specific markdown vault; this audits and prices any memory system); skillopt-sleep (runs a nightly consolidation loop; this decides whether that loop's output is worth keeping); agent-harness (bounds a task loop; this bounds a store)"
---

# Memory Engineering — engineer the forgetting, not just the remembering

> **Portability:** 4 stdlib scripts, no APIs/LLM calls/network. They measure and gate; you decide.

## What this does

Anyone can give an agent memory: vector store, pipe in the history, retrieve

Overview

Anyone can give an agent memory: vector store, pipe in the history, retrieve top-k. That works until the history outgrows the context window, the write path costs more than every query it serves, and the store fills with stale state nobody removes. Memory is not a bucket — it is a system with a metabolism.

Manual install (npx, ZIP)
Claude Codenpx skills add alirezarezvani/claude-skills --skill memory-engineering -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/alirezarezvani/claude-skills/tar.gz/19392f7a0826 \ | tar -xz -C ~/.claude/skills --strip-components=4 claude-skills-19392f7a0826/engineering/memory-engineering/skills/memory-engineering
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/e0f974df80eef2ecd9b7/memory-engineering.zip" -OutFile "$env:TEMP\memory-engineering.zip"; Expand-Archive "$env:TEMP\memory-engineering.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md6.6 KB
  • assets/3 files · 11.8 KB
  • references/4 files · 30.5 KB
  • scripts/4 files · 69.8 KB
Read the files here
alirezarezvani/19392f712 files
SKILL.md
Show the full text101 lines

Memory Engineering — engineer the forgetting, not just the remembering

Portability: 4 stdlib scripts, no APIs/LLM calls/network. They measure and gate; you decide.

What this does

Anyone can give an agent memory: vector store, pipe in the history, retrieve top-k. That works until the history outgrows the context window, the write path costs more than every query it serves, and the store fills with stale state nobody removes. Memory is not a bucket — it is a system with a metabolism.

The shift: a storer optimizes what a system remembers; a memory engineer optimizes what it forgets. The problem was never that an agent forgets — it is that it never forgets on purpose.

The four lenses

Lens Question The finding that hurts
Stanford What does remembering cost? Construction energy exceeds total query energy across 300 queries. The tuned half is the smaller half.
Microsoft What is worth keeping? More raw memory can make an agent worse. Keep facts and skills; drop the events.
Anthropic Who controls what it keeps? A wrong memory does not fail once — it persists into every future session that reads it.
Nvidia Where does it hit hardware? It is all KV cache in HBM. Construction is prefill-heavy and stalls the query a user is waiting on.

Workflow

# 1 - Price it first. Never quote a quality number without a cost number.
python scripts/memory_cost_profiler.py --print-sample-spec > workload.json
python scripts/memory_cost_profiler.py --spec workload.json
# 2 - Pick which cost to pay. No "best" verdict; on a tie it asks, exit 2.
python scripts/memory_architecture_picker.py --constraints workload.json
# 3 - Audit what the store actually holds (skip if greenfield).
python scripts/memory_density_auditor.py --dir ~/.claude/memory
# 4 - Gate on forgetting. Exit 4 is a stop, not a suggestion.
python scripts/forgetting_policy_linter.py --policy design.json
# 5 - No command. Prove each pass by hand before scheduling it.

Step 1 reports the construction/query split, cost per correct answer, and amortization — if construction dominates, cut construction tokens before touching retrieval. Step 2 names the cost the winning family makes you pay. Step 3 classifies records FACT / SKILL / LOG / PROSE (LOG-HEAVY = archiving events; PROSE-HEAVY = docs, not memory).

Step 4 is the gate: F1 (explicit forgetting rule) and F4 (contradictions surfaced, never auto-merged) are blocking. Retrofitting forgetting onto two years of records is a migration nobody does; auto-merging disagreeing memories destroys the evidence the conflict existed.

Step 5 has no script — prove each pass by hand, then automate. Run it once against real history and ask whether it changed a decision. If not, scheduling it only makes noise. Ship order: forgetting_policy_design.md §7.

Hard rules

  1. Never quote accuracy without cost per correct answer.
  2. Never return a "best" memory system — name the cost the choice makes you pay.
  3. Never auto-merge contradictions. The system surfaces; the human decides.
  4. Never call a design done without a forgetting rule. No evaluated system provides one by default.
  5. Never schedule a pass not yet run by hand.
  6. Report findings as findings. A non-zero exit is a result to surface, not an error to swallow.
  7. Attribute every number with its confidence level. Vendor customer figures are testimonials, not benchmarks.

Scripts

Script Role Exit codes
scripts/memory_cost_profiler.py Construction vs query split, cost per correct answer, amortization, co-location warning 0 · 2 finding · 3 bad input
scripts/memory_architecture_picker.py Scores 4 families, disqualifies, names the cost, refuses to pick on a tie 0 · 2 ambiguous · 3 bad input · 4 none viable
scripts/memory_density_auditor.py FACT/SKILL/LOG/PROSE, duplicates, staleness, density (--dir or --jsonl) 0 dense · 2 finding · 3 bad input
scripts/forgetting_policy_linter.py The gate: 8 checks, F1 and F4 blocking 0 PASS · 2 CONDITIONAL · 4 FAIL

All support --output json and --sample (no input file needed).

References and assets

Provenance

Framing from "How to be a Memory Engineer" by @N01ennn; every number is cited to a primary source instead, and two paraphrases are corrected — memory_cost_canon.md §2, memory_control_and_governance.md §4.

1---
2name: memory-engineering
3description: Use when designing, reviewing, or paying for an agent memory system — adding memory to an agent, choosing between long-context / RAG / graph / agentic memory, auditing what a CLAUDE.md or memory directory actually holds, deciding what to keep and what to expire, or when a memory store keeps growing and nobody has said what leaves it. Prices the write path, picks which cost to pay, classifies records as facts / skills / logs, and refuses a design that has no forgetting policy.
4argument-hint: "[optional: path to a memory dir, design spec JSON, or a question]"
5license: MIT
6metadata:
7 version: 1.0.0
8 build_pattern: "Four-lens synthesis (Stanford / Microsoft / Anthropic / Nvidia) + 4 deterministic stdlib scripts, with a blocking forgetting gate"
9 distinct_from: "llm-wiki (maintains one specific markdown vault; this audits and prices any memory system); skillopt-sleep (runs a nightly consolidation loop; this decides whether that loop's output is worth keeping); agent-harness (bounds a task loop; this bounds a store)"
10---
11 
12# Memory Engineering — engineer the forgetting, not just the remembering
13 
14> **Portability:** 4 stdlib scripts, no APIs/LLM calls/network. They measure and gate; you decide.
15 
16## What this does
17 
18Anyone can give an agent memory: vector store, pipe in the history, retrieve
19top-k. That works until the history outgrows the context window, the write path
20costs more than every query it serves, and the store fills with stale state
21nobody removes. Memory is not a bucket — it is a system with a metabolism.
22 
23**The shift:** a storer optimizes what a system remembers; a memory engineer
24optimizes what it forgets. The problem was never that an agent forgets — it is
25that it never forgets *on purpose*.
26 
27## The four lenses
28 
29| Lens | Question | The finding that hurts |
30|---|---|---|
31| **Stanford** | What does remembering cost? | Construction energy exceeds total query energy across 300 queries. The tuned half is the smaller half. |
32| **Microsoft** | What is worth keeping? | More raw memory can make an agent *worse*. Keep facts and skills; drop the events. |
33| **Anthropic** | Who controls what it keeps? | A wrong memory does not fail once — it persists into every future session that reads it. |
34| **Nvidia** | Where does it hit hardware? | It is all KV cache in HBM. Construction is prefill-heavy and stalls the query a user is waiting on. |
35 
36## Workflow
37 
38```bash
39# 1 - Price it first. Never quote a quality number without a cost number.
40python scripts/memory_cost_profiler.py --print-sample-spec > workload.json
41python scripts/memory_cost_profiler.py --spec workload.json
42# 2 - Pick which cost to pay. No "best" verdict; on a tie it asks, exit 2.
43python scripts/memory_architecture_picker.py --constraints workload.json
44# 3 - Audit what the store actually holds (skip if greenfield).
45python scripts/memory_density_auditor.py --dir ~/.claude/memory
46# 4 - Gate on forgetting. Exit 4 is a stop, not a suggestion.
47python scripts/forgetting_policy_linter.py --policy design.json
48# 5 - No command. Prove each pass by hand before scheduling it.
49```
50 
51Step 1 reports the construction/query split, **cost per correct answer**, and
52amortization — if construction dominates, cut construction tokens *before*
53touching retrieval. Step 2 names the cost the winning family makes you pay.
54Step 3 classifies records FACT / SKILL / LOG / PROSE (`LOG-HEAVY` = archiving
55events; `PROSE-HEAVY` = docs, not memory).
56 
57Step 4 is the gate: **F1** (explicit forgetting rule) and **F4** (contradictions
58surfaced, never auto-merged) are blocking. Retrofitting forgetting onto two
59years of records is a migration nobody does; auto-merging disagreeing memories
60destroys the evidence the conflict existed.
61 
62Step 5 has no script — prove each pass by hand, then automate. Run it once
63against real history and ask whether it changed a decision. If not, scheduling
64it only makes noise. Ship order: `forgetting_policy_design.md` §7.
65 
66## Hard rules
67 
681. **Never quote accuracy without cost per correct answer.**
692. **Never return a "best" memory system** — name the cost the choice makes you pay.
703. **Never auto-merge contradictions.** The system surfaces; the human decides.
714. **Never call a design done without a forgetting rule.** No evaluated system provides one by default.
725. **Never schedule a pass not yet run by hand.**
736. **Report findings as findings.** A non-zero exit is a result to surface, not an error to swallow.
747. **Attribute every number** with its confidence level. Vendor customer figures are testimonials, not benchmarks.
75 
76## Scripts
77 
78| Script | Role | Exit codes |
79|---|---|---|
80| `scripts/memory_cost_profiler.py` | Construction vs query split, cost per correct answer, amortization, co-location warning | 0 · 2 finding · 3 bad input |
81| `scripts/memory_architecture_picker.py` | Scores 4 families, disqualifies, names the cost, refuses to pick on a tie | 0 · 2 ambiguous · 3 bad input · 4 none viable |
82| `scripts/memory_density_auditor.py` | FACT/SKILL/LOG/PROSE, duplicates, staleness, density (`--dir` or `--jsonl`) | 0 dense · 2 finding · 3 bad input |
83| `scripts/forgetting_policy_linter.py` | The gate: 8 checks, F1 and F4 blocking | 0 PASS · 2 CONDITIONAL · 4 FAIL |
84 
85All support `--output json` and `--sample` (no input file needed).
86 
87## References and assets
88 
89- [`references/memory_cost_canon.md`](references/memory_cost_canon.md) — construction dominance, energy per correct answer, the four families, ten recommendations (7 sources)
90- [`references/what_to_keep.md`](references/what_to_keep.md) — PlugMem and MEMENTO: facts over logs, density over volume (7 sources)
91- [`references/memory_control_and_governance.md`](references/memory_control_and_governance.md) — memory as files, scope/audit/rollback, poisoning, reading vendor numbers (7 sources)
92- [`references/forgetting_policy_design.md`](references/forgetting_policy_design.md) — forgetting mechanisms, contradiction discipline, KV cache, ship order (7 sources)
93- [`assets/memory_engineer_worksheet.md`](assets/memory_engineer_worksheet.md) — seven forcing questions with recommended answers + citations; walk one at a time
94- [`assets/memory_design_spec.example.json`](assets/memory_design_spec.example.json) — one file covering every script's input
95- [`assets/forgetting_policy_template.md`](assets/forgetting_policy_template.md) — fillable policy covering F1–F8
96 
97## Provenance
98 
99Framing from *"How to be a Memory Engineer"* by [@N01ennn](https://x.com/N01ennn/status/2083971749079581120); every
100number is cited to a primary source instead, and two paraphrases are corrected — `memory_cost_canon.md` §2, `memory_control_and_governance.md` §4.
101 
View all files on GitHub →

Details

Updated
Aug 30, 2026
License
MIT
Stars on the repo
★ 26,349
Checked
Source
alirezarezvani/claude-skills ↗
Creator
alirezarezvani · 363 listings
View creator

Similar skills

See all →
SkillExport the Obsidian wiki's knowledge graph to structuredWiki Export — Knowledge Graph ExportAr9av/obsidian-wiki · by Ar9avExport the Obsidian wiki's knowledge graph to structured formats for use in external tools. Use this skill when the user says "export wiki", "export graph", "export to JSON", "export to Gephi", export to Neo4j", "export to Postgres", "export to SQL", "graphml", "visualize wiki", knowledge graph export", "export to OKF", "OKF bundle", "open knowledge format", export as markdown bundle", or wants to use their wiki data in another tool. Outputs graph.json, graph.graphml, cypher.txt (Neo4j), postgres.sql (Postgres), and graph.html (interactive browser visualization) into a wiki-export/ directory at the vault root, plus an optional OKF (Open Knowledge Format) markdown bundle under wiki-export/okf/.★ 3.5k GitHub starsSkillImport a wiki knowledge graph into the current vaultWiki Import — Reconstruct Pages from an ExportAr9av/obsidian-wiki · by Ar9avImport a wiki knowledge graph into the current vault — either from a graph.json export file (stubs) or from an OKF (Open Knowledge Format) markdown bundle (full page bodies). Use this skill when the user says "import wiki", "import from export", "load graph.json", import vault", "import OKF bundle", "import OKF", "load OKF", "import markdown bundle", /wiki-import", or wants to transfer pages from one vault to another using the output of wiki-export.★ 3.5k GitHub starsSkillYour team's shared, AI-ready knowledge base/company-brain — Team-shared AI-ready knowledge basecoreyhaines31/makerskills · by coreyhaines31Your team's shared, AI-ready knowledge base — people, companies, meetings, SOPs, and decisions structured so an agent can answer on your team's behalf. Team-scope sibling to second-brain. Modes — capture, compile (wiki pages + INDEX.md), query (trust-weighted, saved to outputs/), review (verify / deprecate / supersede stale captures), lint, connect, search. Structured raw dirs (people/, companies/, meetings/, sops/, decisions/, customer-language/, sales-objections/). Every capture stamps author, timestamp, and trust status. Optional sync from call transcripts, Slack/email exports, CRM. Vault at ${COMPANY_BRAIN_VAULT:-$HOME/Documents/CompanyBrain}/. Triggers on "/company-brain," "/cb," "capture this into the team brain," "log this meeting," "save this SOP," "compile the company wiki," "query the team brain," "what does the team know about X," "review the company brain," "lint the company brain," "who's the internal expert on X.★ 855 GitHub starsSkillGive Claude a permanent, searchable long-term memoryAI Brain — persistent memory for Claude via ObsidianOotto-AI/claude-content-skills · by Ootto-AIGive Claude a permanent, searchable long-term memory using an Obsidian vault as the store. At the end of a session, summarize what mattered and save it as a Markdown note in your "AI Brain" vault; at the start of a session (or on demand), read back only the relevant past notes. Local markdown you own — connected via the Filesystem MCP. Trigger with "wrap up", "save this session", or "remember this".★ 139 GitHub starsSkillFind prior Claude Code and Codex sessions with an indexed/recall: session memory engineParcha-ai/parcha-skills · by Parcha-aiFind prior Claude Code and Codex sessions with an indexed local search engine, then continue the work, repeat it with fresh inputs, or distill it into a skill. Runs from Claude Code, Codex, or pi; the current index covers Claude Code and Codex transcripts. Use when the user names Recall, says "find that conversation where…", "what did we do last time about…", "continue what we did yesterday on X", "what did codex do on this branch", "turn what we did about Y into a skill", or "remember when you…". Not for searching code (use grep on the repo) or for facts already in MEMORY.md.★ 62 GitHub starsMCPA basic implementation of persistent memory using a localKnowledge Graph Memory Servermodelcontextprotocol/servers · by modelcontextprotocolA basic implementation of persistent memory using a local knowledge graph. This lets Claude remember information about the user across…★ 90.5k GitHub stars

More from alirezarezvani

SkillResume a paused experiment/ar:ar-resume — Resume Experimentalirezarezvani/claude-skills · by alirezarezvaniResume a paused experiment. Checkout the experiment branch, read results history, continue iterating. Use when the user runs /ar:ar-resume or asks to pick up a previously started autoresearch experiment.★ 26.3k GitHub starsSkillShow experiment dashboard with results, active loops/ar:ar-status — Experiment Dashboardalirezarezvani/claude-skills · by alirezarezvaniShow experiment dashboard with results, active loops, and progress. Use when the user runs /ar:ar-status or asks how an autoresearch experiment is going.★ 26.3k GitHub starsSkillStart an autonomous experiment loop with user-selected/ar:loop — Autonomous Experiment Loopalirezarezvani/claude-skills · by alirezarezvaniStart an autonomous experiment loop with user-selected interval (10min, 1h, daily, weekly, monthly). Uses CronCreate for scheduling. Use when the user runs /ar:loop or asks to run an autoresearch experiment continuously on a schedule.★ 26.3k GitHub starsSkillRun a single experiment iteration/ar:run — Single Experiment Iterationalirezarezvani/claude-skills · by alirezarezvaniRun a single experiment iteration. Edit the target file, evaluate, keep or discard. Use when the user runs /ar:run or asks for one manual autoresearch iteration.★ 26.3k GitHub starsSkillSet up a new autoresearch experiment interactively/ar:setup — Create New Experimentalirezarezvani/claude-skills · by alirezarezvaniSet up a new autoresearch experiment interactively. Collects domain, target file, eval command, metric, direction, and evaluator. Use when the user runs /ar:setup or asks to start optimizing a file with the autoresearch loop.★ 26.3k GitHub starsSkill/cs:boardroom <brief/cs:boardroom — Multi-Role Boardroom Deliberationalirezarezvani/claude-skills · by alirezarezvani/cs:boardroom <brief> — 6-phase multi-role deliberation across the C-suite with Phase 2 isolation, critic pre-screen, and synthesis. Outputs a board memo. Use when a decision spans multiple executive domains — e.g. a pricing change touching finance, positioning, and product, or a raise-vs-cut runway call.★ 26.3k GitHub stars