/total-agent-memory:memory-protocolfrom total-agent-memory
Implements persistent cross-session memory via the total-agent-memory MCP server. Automates session init, recall, save, error learning, and session end workflows across multiple AI coding agents.
Ships in total-agent-memory. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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).
session_init first, then memory_recall. Always.
Skip only if you have already called session_init in this session.memory_recall(query, project). Use
the recipe instead of guessing the convention.memory_save immediately. Don't
batch. A decision, a fix, a new convention — one save per fact, not
one save per session.learn_error (or self_error_log)
with root cause + fix. Pattern auto-consolidates after 3 occurrences.session_end with summary + next_steps + pitfalls.If you only remember one thing: session_init → memory_recall →
work → memory_save → session_end.
| 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. |
A complete reference for every tool with arguments, return shape,
common mistakes, and short examples is in
references/tool-cheatsheet.md.
memory_save content must be a structured digest, not a terminal dump:
ЧТО: one-line summary
ПРОЕКТ: project name
ФАЙЛЫ: absolute paths to the key files
СТЕК: language/framework/version
ПОДХОД: 3–7 key steps, no filler
НЮАНСЫ: gotchas, edge cases, what didn't work and why
For type=decision add WHY: context, alternatives considered,
trade-offs, when this rule applies and when it does not.
Tags must include ["reusable", "<tech>"] when the recipe applies
to other projects (it surfaces in analogize()).
Length cap: ≤ 30 lines. If your save is longer, you have not distilled — go again.
memory_recall(query, project=<current>) — start with the current project.analogize(text=query) for sibling
projects.WebSearch / context7 / first-principles.If a recalled record names a file/function/flag and you are about to act on it (not just answer a question about history), verify it exists first (Read / grep). Memory is a claim about the past; the source is the truth now.
memory_save(type='lesson', stuck=...)AskUserQuestion if your
environment supports it; otherwise plain text question).memory_save(type='solution', tags=['reusable', ...]) so the next session does not redo the work.MEMORY_REFLECT_EVERY_N):
memory_reflect_now() consolidates duplicates, decays stale, and
finds contradictions.<private>...</private> — they are
redacted before save. Never put real tokens / passwords / personal
data in memory_save content; the redactor is best-effort, not
absolute.project= so cross-project
noise stays out of recall. analogize() is the right way to bring
sibling-project context in deliberately.query and
content. The smart router detects relational queries in both.Sub-agents (e.g. Agent(subagent_type='php-pro')) get the same
MCP tools as the main agent. The protocol is identical:
memory_recall first, memory_save after. Pass any recipes you
already recalled into the sub-agent's prompt so it doesn't duplicate
the search.
For sub-agents that don't have direct MCP access, use the bash bridge:
lookup-memory "<query>"
lookup-memory --project NAME "<query>"
See references/subagent-protocol.md for the full sub-agent header
template.
Hooks let the protocol fire automatically. They are opt-in and
each one is documented in detail in references/hooks-explained.md:
| Hook | Trigger | Default action |
|---|---|---|
session-start.sh | Session opens | Calls session_init and prints summary. |
pre-edit.sh | Before file write | Calls file_context(path) and warns if risk_score > 0.5. |
post-tool-use.sh | After every tool call | Optional: captures observation via memory_observe. |
user-prompt-submit.sh | User prompt sent | Calls save_intent. |
on-stop.sh | Session interrupted (context limit, Ctrl-C) | Writes recovery file; next session_start picks it up. |
A bash version (*.sh) and a PowerShell version (*.ps1) ship for
every hook so the same setup works on macOS, Linux, WSL2, and
native Windows.
Installation, hook wiring, and skill location differ per IDE.
The full matrix and per-IDE commands are in
references/ide-setup.md. Quick path:
~/total-agent-memory/install.sh --ide claude-code # or codex|cursor|cline|continue|aider|windsurf|gemini-cli|opencode
The installer writes the right files to the right place (skill, hooks, MCP server registration) and is idempotent — safe to re-run on upgrade.
These are the failure modes the protocol is designed to prevent:
decision from
10:15 stored at 17:00 already lost its context — store it now.memory_recall(query="auth") returns noise.
memory_recall(query="JWT refresh rotation in php-symfony auth middleware")
returns the recipe. Be specific.memory_recall and got a
result, cite it briefly (id + 1-line gist) before applying it. The
user can correct stale memory only if they see it.This skill targets total-agent-memory v10.5+.
MEMORY_ASYNC_ENRICHMENT=true).install.sh for all
major IDEs, cross-platform hooks, sub-agent protocol, and
documentation.If your server is older, the protocol still applies — calls to unsupported tools will return a "not implemented" error and fall through.
references/hooks-explained.md (opens in a new tab)references/ide-setup.md (opens in a new tab)references/subagent-protocol.md (opens in a new tab)references/tool-cheatsheet.md (opens in a new tab)references/workflow-recipes.md (opens in a new tab)templates/claude-code-settings.json (opens in a new tab)templates/cline-rules.md (opens in a new tab)templates/codex-AGENTS-block.md (opens in a new tab)templates/codex-config.toml (opens in a new tab)templates/cursor-rules.mdc (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub vbcherepanov/total-agent-memory --plugin total-agent-memory4 skills in this plugin
/onboardDepartment onboarding for a new employee on the total-agent-memory team server. Use when the user types /onboard, asks to be onboarded, trained, or introduced to a department/team, wants to continue their training, take the department quiz, or see their onboarding progress. Requires the team server MCP tools onboarding_*.
/onboard-reportDepartment head / company viewer view of employee onboarding on the total-agent-memory team server. Use when the user types /onboard-report, asks how new employees are doing with training, who finished which module, quiz scores, wants to grade open quiz answers, or to build/edit the department curriculum or quizzes.
/reportActivity report from total-agent-memory for a project and period. Use when the user types /report or asks "report for today", "what did we do this week", "weekly / monthly summary", "status report", "retro for project X", "all-time report", "report for last week", or a report for a department or the whole company on the team server. Calls the memory_report MCP tool and presents the result.
Other plugins' skills for the same job