memory-layer

A three-level memory system for coding agents: temporary notes, project lookups, and long-term records of decisions and their reasons.

In plain words
What is it for?
Use it to save session notes, find where things are in a project, and record why technical decisions were made.
Why use it?
It keeps short-lived findings separate from information that should remain available across the project. Moving a decision into long-term memory requires a human approval step.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/othmanadi/mddesign/memory-layer
Any agent
npx skills add OthmanAdi/MDDesign --skill memory-layer
Clone the repo
git clone --depth 1 https://github.com/OthmanAdi/MDDesign

Made for: Claude Code, Codex.

Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,231 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00056 $0.01231
Opus 5 $0.00028 $0.00616
Sonnet 5 $0.00011 $0.00246
Haiku 4.5 $0.00006 $0.00123

Measured 2d ago against content hash d55de2146ba2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-layer 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 2d 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.

.clinerules/memory-layer/SKILL.md · 90 lines

How it starts

The opening of the file, as written. The whole thing — 90 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory Layer

Three-tier wrapper on top of code-memory-router plus a local file-tier scratchpad.

Tiers

Tier Purpose Backend Lifetime
scratch Volatile session notes, in-flight findings .agents/memory/scratch/<topic>.md (file-tier) Session, until promoted or /mddesign:handoff promote
WHERE Locational queries (where is X, which file, which directory) QMD via /memory-router Project lifetime
WHY Decisions, rationale, post-mortems, "we picked X because" MemPalace drawers via /memory-router Forever

Operations

/mddesign:memory save <text> (default tier: scratch)

  1. Determine the active topic. The active phase id from task_plan.md is the default topic. If no plan exists, use general.
  2. Append <text> plus an ISO timestamp to .agents/memory/scratch/<topic>.md. Create parent directories if needed.
  3. Print confirmation: "Saved to scratch / topic=".

/mddesign:memory save --tier why <text>

  1. Print the text to the user with a clear "About to promote to MemPalace WHY tier. Approve? [y/N]" line.
  2. The PreToolUse hook intercepts the next Bash or /memory-router invocation (named checkpoint: before_mempalace_write).
  3. On approval, invoke /memory-router with the canonical "save to MemPalace" pattern documented in code-memory-router's SKILL.md. Pass the text plus a project tag derived from CWD basename.
  4. On the same approval, append a marker to .agents/memory/scratch/<topic>.md: "PROMOTED to MemPalace at ." The original scratch entry stays in place for the rest of the session for context continuity.

/mddesign:memory recall <query>

Routing rule:

  • If the query starts with "where", "which file", "find", "locate", route to WHERE.
  • If the query starts with "why", "decision", "history", "what did we decide", route to WHY.
  • Otherwise, peek at scratch first; if nothing matches, fall back to WHERE.

Routing target:

  • WHERE → invoke /memory-router and let the router dispatch to QMD.
  • WHY → invoke /memory-router and let the router dispatch to MemPalace.
  • scratch → grep .agents/memory/scratch/**/*.md for the query.

Read the full file on GitHub · 90 lines

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. 2d ago First seen · 90 lines · 56 tokens per session scan A d55de2146ba2

Subscribe to this mod's changes

memory-layer is a skill published in the GitHub repository OthmanAdi/MDDesign (13 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 56 tokens to every session and 1,231 once invoked, about $0.0003 per session on Opus 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-08-30.