agent-memory
What it does
This skill sets up a memory system for an AI agent, so a lesson is kept only after it keeps coming up. It is for people whose project instruction file has grown messy or whose agent keeps relearning the same correction.
When to use it
- βWhen your agent keeps relearning the same correction every session.
- βWhen your project instruction file has grown too long and mixes important and minor facts.
- βWhen you need to trace where a remembered rule came from.
Skill link
https://github.com/alirezarezvani/claude-skills/blob/main/engineering/agent-memory/skills/agent-memory/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βMy agent keeps forgetting that we use pnpm. Set up a memory system that only keeps lessons that come up repeatedly.β
5 new skills a week. 1 minute to read.
How it works
Facts move through four tiers, from raw session notes up to always-loaded project context. A fact moves up only when it recurs across sessions and days, and a person confirms the final step.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Agent Memory β promotion is earned, not asserted
Portability: stdlib only. No database, no embeddings, no network, no LLM calls.
The problem
A project's CLAUDE.md is a memory system with one tier and no eviction: every
durable fact and every passing preference land in the same always-loaded file,
until the important lines are diluted by the incidental ones. Facts learned
mid-session vanish at teardown unless someone writes them down.
The fix is not more storage β it is a promotion ladder. A claim earns its way toward always-loaded context by recurring; a human confirms the last step.
The four tiers
Tiers are distinguished by injection policy, not storage format.
| Tier | Holds | Injected | Committed |
|---|---|---|---|
| L0 | raw session transcripts | never | no (already on disk) |
| L1 | candidate atoms | on relevance, at prompt time | no (gitignored) |
| L2 | this project's context | every session start | yes, after adopt |
| L3 | stable cross-project persona | always | yes, after adopt |
The gates
Nothing moves up because it sounded important. It moves up because it recurred.
- L0 β L1 β an explicit marker fires (a directive, a correction, a stated preference, a named lesson, a reproducible failure). Rule-based, high precision, deliberately low recall.
- L1 β L2 β β₯ 3 distinct sessions spanning β₯ 2 distinct calendar days. A claim stated outright needs 2 sessions; the distinct-day rule still applies. A verified claim promotes on one observation and is the only day-exempt path.
- L2 β L3 β held in β₯ 2 distinct projects, aged β₯ 30 days, uncontested.
Two gates refuse rather than guess. A claim whose text was altered by redaction never promotes on evidence alone β the flag firing is evidence the source was sensitive, and a lexical filter finding one secret is not proof it found all of them. A claim with an open contradiction is frozen at L1 until a human resolves it; the incumbent is never silently overwritten.
Use it
# what is remembered, and what is blocking the next promotion
python3 scripts/memory_inspect.py --tier L1
# where did this line come from β sessions, days, transcript, quoted source
python3 scripts/memory_inspect.py --why "PR base branch is dev"
# every claim with an open contradiction, both directions of the join
python3 scripts/memory_inspect.py --contested
# dry-run the promotion pass; writes nothing
python3 scripts/memory_promote.py
Three hooks run the loop unattended: SessionStart injects L2 + L3,
UserPromptSubmit recalls relevant L1 atoms, SessionEnd captures and stages.
Each is disabled independently with AGENT_MEMORY_SESSIONSTART=0,
AGENT_MEMORY_USERPROMPTSUBMIT=0, AGENT_MEMORY_SESSIONEND=0. Every hook fails
open: a broken memory system costs you memory, never a session.
Hard rules
- Redact before writing. Every atom passes the filter before it reaches disk. Anything altered is quarantined from promotion.
- Propose, never apply. Promotions land in
.memory/staged/. Only an explicit/cs-memory adopttouches aCLAUDE.md, and it backs both up first. - Cite, don't invent. Every atom carries a back-pointer to the transcript
line that produced it.
--whyresolving to ambiguous prints nothing rather than guess: a wrong citation is worse than a missing one. - Never surface a contested claim as fact. It is still injected β hiding the conflict is worse β but always tagged.
- The committed tiers carry no paths. Promotion strips the back-pointer prefix, which embeds an OS username.
Forcing questions
Walk these one at a time before trusting the store.
- Which line in your
CLAUDE.mddid you last actually read before acting? - Would you rather the agent forget a true thing, or remember a false one?
- When two remembered rules disagree, who decides β and when?
- What would make you delete
.memory/entirely?
Rationale, open decisions, field schema: ../../DESIGN.md.
More in this skill
Load these only when the task needs them.
- references/hook_capture_discipline.md β Hook discipline β running on someone else's critical path
- references/promotion_gate_design.md β Designing the gates β why these thresholds, and what they cost
- references/tiered_memory_canon.md β Tiered agent memory β the canon,
FAQ
Does it use a database or AI calls?
No. The skill uses standard scripts only, with no database, embeddings, network calls or AI calls.
Who approves a fact before it goes into the project file?
A person confirms the last step with an adopt action.
Why does a fact need to recur?
Recurrence shows a lesson matters, so incidental notes do not clutter the always-loaded context.
Details
Original description by the author
Use when an agent keeps relearning the same correction, CLAUDE.md has grown unreadable, or you need to trace where a remembered rule came from. Promotes facts through four tiers only on recurrence across sessions and days, with memory_promote.py and a human adopt step.
Popularity
- GitHub stars
- 29k
- Ranking position
- #9525
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
agent-launcher-orchestrator
29kHelps your agent plan, build, test and schedule a Claude managed agent in your own account, step by step, starting from one clear goal.
grade-iterate
29kLets your agent grade a managed AI agent's work against a rubric and improve it in a fixed number of rounds, so it never loops forever.
interview
29kLets your agent interview you about an AI agent idea and turn your answers into a simple build plan before anything is launched.
run-without-you
29kHelps your agent set up a managed AI agent to run on a schedule or when an event happens, with the cron timing checked before launch.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.