Local-first MCP memory backend and governance console for coding agents. Auto-organize, quarantine, supersede, and rollback shared memories across multiple agents.
Recursos
16Instal·la
npx skillscat add irisxc4/memoryguard Instal·la des del registre de SkillsCat.
MemoryGuard
Shared memory for coding agents, without shared-memory chaos.
What It Does
MemoryGuard provides a local MCP stdio memory backend that coding agents
(Claude Code, Codex, Cursor) can write to. Every write is auto-organized:
classified, deduplicated, superseded, quarantined, or compressed.
Install
pip install agent-memguardFirst activation — install the host Hook automatically
Installing a plain Skill does not itself execute code. On the first Skill
activation after installation, the host Agent must proactively complete this
idempotent setup without asking the user to edit JSON/TOML:
- Identify the current host as exactly one of
claude,codex,cursor, ortrae. Do not install into every detected Agent. - Call
memoryguard_provider_install(provider=<current host>). Do not pass a
differentagent_instance_id; the trusted MCP binding is authoritative. - Inspect the returned
hookobject:configured=true: setup is complete.status=configured_pending_runtime: restart/reload the host and verify
after the first prompt.- Codex
trust_required=true: tell the user to open/hooksand trust the
exact MemoryGuard hook hash. Never bypass Hook trust automatically. supported=false: keep MCP + always-on rules active and report that this
host has no verified lifecycle Hook seam.
- Re-running the setup is a repair operation. It replaces only
MemoryGuard-owned handlers and must not duplicate or delete other hooks.
If the MCP install tool is not available but a trusted binding already exists,
run:
memoryguard hooks ensure --provider <current-host> \
--workspace <memoryguard-control-workspace> \
--agent-id <trusted-agent-id>Do not claim that Skill installation alone created a permanent Hook. The Hook
is active only after the user-level host configuration is written and a runtime
receipt is observed.
Mandatory rules
- Use
memoryguard_memory_write(injection_policy="always", priority=...)only
when the user explicitly asks for a long-term mandatory rule (for example,
“must”, “always”, or a default rule). Facts, preferences, and ordinary
procedures remainrelevant; never promote every procedure to mandatory. memoryguard_memory_updatecan switchinjection_policy/priority. The
GUI can switch a rule back to on-demand or delete/restore it.- Bootstrap injects mandatory rules in an independent budget before relevant
recall. Sensitive or over-limit mandatory packages fail closed.
Hook runtime contract
- Claude and Codex:
UserPromptSubmitinjects one bounded, relevant,
active-only long-term context packet per turn. - Claude and Codex subagents receive the same policy plus a task-relevant
bounded packet throughSubagentStart; tool guards also apply inside them. - Cursor:
sessionStartinjects session policy/context. BecausebeforeSubmitPromptcannot inject dynamic context, the first non-MemoryGuard
tool call is denied untilmemoryguard_context_bootstrapsucceeds. PreToolUseblocks visible writes to known native-memory paths and other
memory MCP writers. Manual MemoryGuard GUI delete/restore remains available.PostToolUserecords successful bootstrap/write receipts without storing raw
prompts or memory bodies.Stopcontinues at most once when an explicit durable preference/correction
has no MemoryGuard write receipt. Never save the whole conversation.- Hook modes are
enforce(default),observe, andpaused.
History is evidence, not long-term memory
- Rules & habits govern long-term records. Mandatory rules must be scoped
to their intended Agent, project, provider, or runtime role; never treat a
shared group as permission to force every member. - Conversation history is a separate, local raw-evidence archive. It is
isolated per Agent by default and is never injected bymemoryguard_context_bootstrapor added to the neuron graph automatically. - Retrieve history progressively:
memoryguard_history_search(IDs and
summaries only), thenmemoryguard_history_timeline, thenmemoryguard_history_readfor an authorized raw turn/session. memoryguard_history_extract_previewis read-only. It may suggest
evidence-backed candidates but must not write long-term memory; use the
normal governed memory write path only after explicit selection.- Verified Hook seams may archive bounded user prompts and exposed assistant
finals directly into the history database. They honor privacy/disable flags,
never infer missing content, and cannot block the host conversation when
archival fails.
MCP Configuration
Add to your agent's MCP config:
{
"mcpServers": {
"memoryguard": {
"command": "python",
"args": ["-m", "memoryguard.mcp_server"]
}
}
}Tools
memoryguard_memory_read- Read a single memory record by IDmemoryguard_memory_search- Search memories by query, kind, or statusmemoryguard_memory_write- Write a new memory; auto-organizes on writememoryguard_memory_update- Update a memory (body / kind / status)memoryguard_memory_delete- Soft-delete a memorymemoryguard_memory_status- Get shared memory group statusmemoryguard_binding_create- Bind an agent to a share groupmemoryguard_binding_list- List agent bindingsmemoryguard_extract_memories- Extract memory segments from a source filememoryguard_accept_candidates- Accept extracted candidates and write to shared memorymemoryguard_semantic_check- Check text for semantic duplicates / conflictsmemoryguard_provider_install- Install/repair global MCP + rules + verified
Hook (Claude / Codex / Cursor; TRAE gets an explicit MCP+rules fallback)memoryguard_build_and_enrich- Build projection; host Skill is the default enrichermemoryguard_list_pending_enrichments- List pending classify/translate tasksmemoryguard_apply_enrichments- Apply host enrichment results (then rebuild)memoryguard_enrichment_status- Pending/applied queue countsmemoryguard_history_search- Search scoped local history without raw textmemoryguard_history_timeline- Read a bounded preview around a resultmemoryguard_history_read- Read an explicitly selected raw turn/sessionmemoryguard_history_extract_preview- Preview candidates; never writes memorymemoryguard_history_list_sessions/memoryguard_history_export/memoryguard_history_delete- Manage the trusted Agent's archive (deleterequiresconfirmed=trueand preserves evidence tombstones)
Host AI enrichment (Skill interface — automatic)
You (the host agent running this Skill / MCP tools) ARE the LLM for enrichment.
Installing MemoryGuard + enabling MCP connects this path. Do not ask the user to
pick Codex CLI unless they are in the multi-agent GUI and chose a CLI engine.
Required auto loop (no user confirmation for each step)
When the user asks to build / rebuild projection or enrich memories:
- Call
memoryguard_build_and_enrich(defaultenrich_mode=host). - If response has
host_action_requiredorpending_tasks:- Classify + translate each task yourself (
kind/title/body/confidence). - Call
memoryguard_apply_enrichmentswith the results. - Call
memoryguard_build_and_enrichagain to refresh the neuron graph.
- Classify + translate each task yourself (
- Do not stop after step 1 when pending remains. Do not tell the user
“only Codex is available” — the chat model is already connected via Skill/MCP.
Multi-agent GUI popup (separate path)
When building from the MemoryGuard GUI in share-group / multi-agent mode, the
UI must show a picker: host Skill / Cursor Agent CLI / Codex / Claude / ….
That picker is for choosing the sync engine in the GUI process. Skill/MCP calls
still default to host and auto-run the loop above.
Optional enrich_mode=cli + llm_agent / llm_cli is only for an explicit CLI
choice from that popup or headless automation.
Do not require a separate GUI “AI 整理” button. Rebuild projection to re-run enrich.
Privacy
No account. No server. No telemetry. All data stays in local SQLite under .memoryguard/.