memory-engineering

Audit and price agent memory systems with four deterministic Python scripts.

25.3k|3.6k|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/alirezarezvani/claude-skills --skill memory-engineering
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory-engineering
Source: https://github.com/alirezarezvani/claude-skills/tree/main/engineering/memory-engineering/skills/memory-engineering
Command: npx skills add https://github.com/alirezarezvani/claude-skills --skill memory-engineering

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Agent memory stores grow without bound, cost more to build than to query, and fill with stale logs nobody removes. This Skill prices the write path, audits what a memory store actually holds, and blocks any design that lacks an explicit forgetting policy.

Core Features & Use Cases

  • Cost Profiling: Splits a memory workload into construction and query phases, computes cost per correct answer, and flags write-path dominance, under-amortization, and co-located construction.
  • Architecture Selection: Scores the four memory paradigms (long-context, flat RAG, structured RAG, agentic) against stated constraints, names the cost each choice makes you pay, and refuses to pick on a tie.
  • Density Auditing: Classifies records in a memory directory or JSONL file as FACT, SKILL, LOG, or PROSE, finds near-duplicates, and flags stale or volatile records.
  • Forgetting Gate: Lints a design JSON against eight checks where F1 (explicit forgetting rule) and F4 (contradictions surfaced, never auto-merged) are blocking failures.
  • Use Case: Before shipping a support agent with long-term memory, run the cost profiler on your workload spec, audit your existing CLAUDE.md memory directory, and lint your design policy to confirm forgetting is designed in.

Quick Start

Audit my agent memory setup by profiling the workload in workload.json, then lint the forgetting policy in design.json and tell me what to fix first.

Frequently Asked Questions about memory-engineering

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit what my agent memory store actually contains?

Run memory_density_auditor.py with --dir pointing at your memory directory or --jsonl for a records file. It classifies each record as FACT, SKILL, LOG, or PROSE, finds near-duplicates above 75% similarity, and flags records older than a configurable staleness threshold.

How do I choose between long-context, RAG, and agentic memory?

Run memory_architecture_picker.py with a constraints JSON describing latency sensitivity, build budget, recall need, volume growth, and mutability. It scores the four paradigm families, disqualifies any that violate hard constraints, and names the cost the winning choice makes you pay.

Why does agent memory construction cost more than queries?

The Stanford characterization found construction energy exceeds total query energy across 300 queries for LLM-mediated memory systems. memory_cost_profiler.py reports this split and computes cost per correct answer so you can cut construction tokens before tuning retrieval.

Does this skill require external APIs or Python packages?

No. All four scripts are stdlib-only Python with no network access, no LLM calls, and no third-party dependencies. They perform deterministic arithmetic, lexical classification, and policy linting entirely locally.

What makes a memory design fail the forgetting policy linter?

Two blocking checks fail a design: F1 requires an explicit forgetting rule (TTL, capacity bound, or decay), and F4 requires contradictions be surfaced to a human rather than auto-merged. Other gaps like missing audit trails or rollback degrade the verdict to CONDITIONAL.

When should I not automate a memory maintenance pass?

Run each pass by hand against real history first and ask whether it changed a decision. If the output did not change anything, scheduling it only generates noise, and sparse input causes the system to hallucinate connections that are not there.