memory

A command for managing optional, persistent memory shared across devices. It connects agents to a self-hosted memory service that stores and searches remembered information.

In plain words
What is it for?
Use it to enable, disable, or check the status of semantic memory for scaffolding agents.
Why use it?
It gives agents access to relevant past information instead of starting without memory each time. Memory stays off until you explicitly enable it on a device.

Command

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 commands/komluk/scaffolding/memory
Clone the repo
git clone --depth 1 https://github.com/komluk/scaffolding
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,227 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 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.00000 $0.01227
Opus 5 $0.00000 $0.00613
Sonnet 5 $0.00000 $0.00245
Haiku 4.5 $0.00000 $0.00123

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

Security

Grade C, and why

memory scanned grade C with 2 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.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

chmod 700 "$HOME/.claude/hooks/refresh-mcp-token.sh"

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

python3 - "$HOME/.claude/settings.json" <<'PY'
commands/memory.md · 106 lines

How it starts

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

/memory Command

Manage cross-device semantic memory for scaffolding (self-hosted mem0 + pgvector, Ollama on GPU). Opt-in, per-device. Memory is off by default — nothing is wired until you enable it.

Usage

/memory enable     # wire the memory MCP backend into Claude Code (user scope)
/memory disable    # remove it from this device (stored memories on the backend are kept)
/memory status     # show whether it's wired and reachable

The assistant reads the argument (enable / disable / status; default: status) and performs the matching section below.


enable

Connects this device so scaffolding agents gain persistent memory via the semantic_search / semantic_recall / semantic_store tools (see the semantic-memory-mcp and semantic-memory-store skills). The token is personal — memory is yours only; anyone without it gets 401.

  1. Check the token is in the environment:
    test -n "${MEMORY_MCP_TOKEN:-}" || echo "MEMORY_MCP_TOKEN not set — export it (e.g. from Vault: export MEMORY_MCP_TOKEN=$(vault kv get -field=token kv/memory/mcp)) and re-run"
    
  2. Register the MCP server (user scope; default endpoint = homelab backend, override with MEMORY_MCP_URL):
    claude mcp add --scope user --transport http memory \
      "${MEMORY_MCP_URL:-http://memory.bernardynska.waw.pl:8000/mcp}" \
      --header "Authorization: Bearer \${MEMORY_MCP_TOKEN}"
    
    (The literal ${MEMORY_MCP_TOKEN} is stored and expanded at runtime — the token is never written to disk.)
  3. Verify: claude mcp list | grep memory
  4. (Optional) Wire token auto-refresh from Vault. Offer this only if the user wants the token kept fresh per-device without manual re-export. It installs a SessionStart hook (shipped with the plugin) into user settings — opt-in, never an always-on plugin hook:
    mkdir -p "$HOME/.claude/hooks"
    cp "${CLAUDE_PLUGIN_ROOT}/hooks/refresh-mcp-token.sh" "$HOME/.claude/hooks/refresh-mcp-token.sh"
    chmod 700 "$HOME/.claude/hooks/refresh-mcp-token.sh"
    python3 - "$HOME/.claude/settings.json" <<'PY'
    import json, os, sys
    p = sys.argv[1]
    d = json.load(open(p)) if os.path.exists(p) else {}
    cmd = "$HOME/.claude/hooks/refresh-mcp-token.sh"
    ss = d.setdefault("hooks", {}).setdefault("SessionStart", [])
    if not any(h.get("command") == cmd for e in ss for h in e.get("hooks", [])):
        ss.append({"matcher": "", "hooks": [{"type": "command", "command": cmd, "timeout": 30}]})
        json.dump(d, open(p, "w"), indent=2); open(p, "a").write("\n")
        print("auto-refresh hook installed")
    else:
        print("auto-refresh hook already present")
    PY
    
    It re-pulls MEMORY_MCP_TOKEN from Vault (kv/memory/mcp) each session and keeps settings.json topped up. Requires the vault CLI + a valid login; a clean no-op without them. Skip if the token is supplied another way (e.g. the claude() shell wrapper). Takes effect next session.
  5. Tell the user to restart Claude Code so the server + token load and connect. After restart, mcp__memory__* tools are available and skills use them automatically.

Read the full file on GitHub · 106 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 · 106 lines · 0 tokens per session scan C cfa3723ba0bf

Subscribe to this mod's changes

memory is a command published in the GitHub repository komluk/scaffolding (15 stars, last pushed 27d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,227 tokens. A static security scan graded it C with 2 findings (asks for root, reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.