memory-engineering
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.
Estimated installs are a discovery signal based on public repository popularity and source completeness, not recorded Dokki installation events.
Repository
alirezarezvani/claude-skills
Pinned commit
f2bac0a8f29b
License
MIT
Execution
Instructions only
Complete source instructions
SKILL.md
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
- Never quote accuracy without cost per correct answer.
- Never return a "best" memory system — name the cost the choice makes you pay.
- Never auto-merge contradictions. The system surfaces; the human decides.
- Never call a design done without a forgetting rule. No evaluated system provides one by default.
- Never schedule a pass not yet run by hand.
- Report findings as findings. A non-zero exit is a result to surface, not an error to swallow.
- 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
references/memory_cost_canon.md— construction dominance, energy per correct answer, the four families, ten recommendations (7 sources)references/what_to_keep.md— PlugMem and MEMENTO: facts over logs, density over volume (7 sources)references/memory_control_and_governance.md— memory as files, scope/audit/rollback, poisoning, reading vendor numbers (7 sources)references/forgetting_policy_design.md— forgetting mechanisms, contradiction discipline, KV cache, ship order (7 sources)assets/memory_engineer_worksheet.md— seven forcing questions with recommended answers + citations; walk one at a timeassets/memory_design_spec.example.json— one file covering every script's inputassets/forgetting_policy_template.md— fillable policy covering F1–F8
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.
Same repository
Related Skills
agent-launcher-orchestrator
Use when a user wants to build, launch, grade, or schedule a Claude Managed Agent (CMA) in their own Anthropic account — "build me an agent", "launch this as a managed agent", "run this on a schedule", "grade my agent against a rubric", "set up a nightly worker". Reads the per-session goal (./my-agent/goal.json), routes deterministically to one of five phase sub-skills (interview → stage-launch → grade-iterate → run-without-you → wrap-up) via goal_router.py, and compiles the goal+phase into an execution shape (single-pass workflow / bounded grade→iterate loop / recurring cron deployment loop) via loop_compiler.py. Forks context so heavy intake (build sheets, payloads, eval cases) stays out of the parent thread. All launches are emitted as BYOK curl the user runs with their own key; no tool makes API calls. Inspired by anthropics/launch-your-agent (Apache-2.0). Distinct from engineering/agent-harness (generic domain loop) and engineering/write-a-skill (authors Claude Code skills, not CMAs).
View detailsagent-protocol
Inter-agent communication protocol for C-suite agent teams. Defines invocation syntax, loop prevention, isolation rules, and response formats. Use when C-suite agents need to query each other, coordinate cross-functional analysis, or run board meetings with multiple agent roles.
View detailsarquiteto-de-empresa
Company Architect: builds a business from scratch as an OKF (Open Knowledge Format) bundle — a tree of version-controllable .md files with frontmatter type, links forming a graph, and reserved index.md/log.md, readable by humans and agents. Guides the founder through a 12-phase interview (foundation, strategy, market, financial, sales, marketing, product, operations, tech, people, legal, governance), one phase at a time, few questions per block, and generates the concepts as conformant markdown. Trigger when the user wants to create, structure, or document an entire company in folders and .md files; when they mention build my company from scratch, company as code, company knowledge base for AI to read, company wiki for agents, OKF, or knowledge bundle. In English.
View detailsarquiteto-de-empresa
Company Architect: builds a business from scratch as an OKF (Open Knowledge Format) bundle — a tree of version-controllable .md files with frontmatter type, links forming a graph, and reserved index.md/log.md, readable by humans and agents. Guides the founder through a 12-phase interview (foundation, strategy, market, financial, sales, marketing, product, operations, tech, people, legal, governance), one phase at a time, few questions per block, and generates the concepts as conformant markdown. Trigger when the user wants to create, structure, or document an entire company in folders and .md files; when they mention build my company from scratch, company as code, company knowledge base for AI to read, company wiki for agents, OKF, or knowledge bundle. In English.
View detailsboard-deck-builder
Assembles comprehensive board and investor update decks by pulling perspectives from all C-suite roles. Use when preparing board meetings, investor updates, quarterly business reviews, or fundraising narratives. Covers structure, narrative framework, bad news delivery, and common mistakes.
View detailsboard-meeting
Multi-agent board meeting protocol for strategic decisions. Runs a structured 6-phase deliberation: context loading, independent C-suite contributions (isolated, no cross-pollination), critic analysis, synthesis, founder review, and decision extraction. Use when the user invokes /cs:boardroom, calls a board meeting, or wants structured multi-perspective executive deliberation on a strategic question.
View details