memory-protocol

A shared set of rules for using a persistent memory service across coding-agent sessions.

In plain words
What is it for?
Use it at session start, before substantial work, after important actions, when errors occur, and at session end.
Why use it?
It helps the agent recall earlier decisions and conventions, record important changes, and learn from errors instead of starting from scratch.

Skill for Claude CodeCodex

Part of the total-agent-memory plugin — 3 skills, 7 hooks, 1 MCP server shipped together

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/vbcherepanov/total-agent-memory/memory-protocol
Any agent
npx skills add vbcherepanov/total-agent-memory --skill memory-protocol
Clone the repo
git clone --depth 1 https://github.com/vbcherepanov/total-agent-memory

Made for: Claude Code, Codex.

Or install total-agent-memory, the plugin that ships this one along with the rest of its 3 skills, 7 hooks, 1 MCP server.

Per session 120 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,653 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.00120 $0.02653
Opus 5 $0.00060 $0.01326
Sonnet 5 $0.00024 $0.00531
Haiku 4.5 $0.00012 $0.00265

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

Security

Grade A, and why

memory-protocol 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 3d 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.

skills/memory-protocol/SKILL.md · 223 lines

How it starts

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

Memory Protocol — Universal Skill

You have access to a persistent cross-session memory via the total-agent-memory MCP server (60+ tools). Knowledge survives between sessions and is shared across agents working on the same project.

This skill is universal — the same MCP tools, the same triggers, the same templates work in every supported environment (Claude Code, Codex, Cursor, Cline, Continue, Aider, Windsurf, Gemini CLI, OpenCode). Hooks and sub-agents are environment-specific and documented separately (see references/hooks-explained.md and references/ide-setup.md).

The five non-negotiables

  1. Session start → session_init first, then memory_recall. Always. Skip only if you have already called session_init in this session.
  2. Before any non-trivial task → memory_recall(query, project). Use the recipe instead of guessing the convention.
  3. After every significant action → memory_save immediately. Don't batch. A decision, a fix, a new convention — one save per fact, not one save per session.
  4. On error / bash non-zero / stuck → learn_error (or self_error_log) with root cause + fix. Pattern auto-consolidates after 3 occurrences.
  5. End of session → session_end with summary + next_steps + pitfalls.

If you only remember one thing: session_initmemory_recall → work → memory_savesession_end.

Trigger table — when to call what

Event Tool Why
Session opens session_init(project) Returns previous summary + next_steps + pitfalls and marks them consumed. Call first.
Any task starts memory_recall(query, project) Recipe-first; never invent a convention twice.
Before edit/write to a file file_context(path) Returns risk_score + warnings (past errors on this path, hot spots).
Before architecture choice memory_recall + analogize(query, exclude_project) Cross-project analogy.
Bash returns non-zero (and reproducible) learn_error(file, error, root_cause, fix, pattern) Auto-consolidates to a rule after N≥3.
Architectural decision made save_decision(title, options, criteria_matrix, selected, rationale) Structured; auto-tagged structured; goes into recall with decisions_only=True filter.
Tech-stack/dependency/config change kg_add_fact(subject, predicate, object) Temporal; auto-invalidates old facts.
Solution that other projects could reuse memory_save(type='solution', tags=['reusable', '<tech>']) Surfaces in analogize() for sibling projects.
Reusable pattern / idiom memory_save(type='convention')
Lesson learned (regression / postmortem) memory_save(type='lesson') Higher recall weight on similar tasks.
Episode (story of how something was done) memory_episode_save(narrative, outcome) Narrative form — "what was tried, what failed, what worked".
Error worth a one-time note self_error_log(description, category, fix?) Cheaper than learn_error; no auto-rule.
User prompt that should be remembered save_intent(prompt, project) Auto-captured by hook if installed.
Major task starting workflow_predict(task_description) If confidence < 0.3 ask the user about approach.
Major task ending workflow_track(workflow_id, outcome) Trains the predictor.
"What was the stack at date X?" kg_at(timestamp) Time-travel query.
"Find similar in other projects" analogize(text, exclude_project) Jaccard + Dempster-Shafer fusion.
Indexing an external repo ingest_codebase(path, languages) AST tree-sitter, 9 languages.
Show recent saves chronologically memory_timeline(limit) Replays session → session.
Build per-project digest memory_wiki_generate(project) Markdown to <MEMORY_DIR>/wikis/<project>.md.
Session closes ("сохранись" / "save") session_end(session_id, summary, next_steps, pitfalls) + dual-write to Obsidian if available Picked up by next session_init.

Read the full file on GitHub · 223 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. 3d ago First seen · 223 lines · 120 tokens per session scan A 3e1238a16d28

Subscribe to this mod's changes

memory-protocol is a skill published in the GitHub repository vbcherepanov/total-agent-memory (66 stars, last pushed 6d ago), licensed MIT. It adds 120 tokens to every session and 2,653 once invoked, about $0.0006 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.

Related

Other skills, from other repositories

mulch-record-from-evidence

Turn the evidence of a finished work session — git commits, changed files, recently-touched seeds issues — into well-formed ml record invocations. Use at session close, when an agent has made changes worth preserving as mulch expertise but hasn't yet recorded them.

jayminwest/mulch · 61 tokens

implement

End-to-end workflow for taking MCP work items from backlog to merged PR. Handles git branching, schema-driven planning, implementation, independent review, and PR creation. Composes spec-quality, review-quality, and schema-workflow skills into a single pipeline. Use when a user says "implement this", "work on this…

jpicklyk/task-orchestrator · 101 tokens

session-retrospective

Analyzes the current implementation run — evaluates schema effectiveness, delegation alignment, note quality, and plan-to-execution fit. Captures cross-session trends and proposes improvements when patterns repeat. Use after implementation runs, or when user says 'retrospective', 'session review', 'what did we learn'…

jpicklyk/task-orchestrator · 107 tokens

ralph

Launcher for the Ralph-style queue drain script — emits the right node ralph-loop.mjs invocation based on the user's filter and bounds. The actual loop runs as a Node script that spawns one claude -p --worktree per iteration; this skill is the configurator, not the loop. Use when a user says: drain the backlog, ralph…

jpicklyk/task-orchestrator · 99 tokens

prepare-release

End-to-end release automation — reads commits since last tag, infers semver bump, drafts changelog, creates release PR, merges it, waits for CI green, tags, and monitors the Docker build to completion. Use when the user says: prepare release, cut a release, bump version, create release PR, ship a new version, tag a…

jpicklyk/task-orchestrator · 95 tokens

quick-start

Interactive onboarding for the MCP Task Orchestrator. Detects empty or populated workspaces and walks through how plan mode, persistent tracking, and the MCP work together. Use when a user says "get started", "how do I use this", "quick start", "first time setup", "onboard me", "what can this MCP do", or "help me…

jpicklyk/task-orchestrator · 82 tokens