Plugin · sc-memory · Default
Memory
Your agents remember what each project decided.
Do this for me on this machine: make this workspace remember decisions and bugs across sessions, then save one fact and recall it so I can see it work. This is superclaude's own guide. Read all of it as raw Markdown first, without summarizing it: curl -fsSL "https://superclaude.io/docs/memory.md" Then: 1. Tell me in a few lines what you are going to change. 2. Do every step yourself: run the commands, edit the files, check each result. 3. Stop only for what needs me: a browser sign-in, a choice between options, a secret to paste. 4. Finish by showing it works, and tell me the one command I will use from now on. Other superclaude pages, if you need them: https://superclaude.io/llms.txt
What your web project rememberssaved as you work
- DecisionRedis in front of the API: too slow without it3 Oct
- BugUploads over 50 MB reset: raise the proxy limit9 Oct
- PreferenceLead with the answer, no preamble12 Oct
- OngoingAuth migration: step 3 of 5today
Every new session starts with this list. The files are plain Markdown.
sc-memory is a default plugin: sc expects it in every workspace, and sc doctor flags a manifest that leaves it out. It needs no other plugin.
Claude Code uses it when the task calls for it, so you do not have to call it by name.
What you get in every workspace
- Each session starts with a map of what past sessions concluded.
- When a bug comes back, a subagent finds the memory that records its fix.
- A background fork saves what the session concluded every 30 steps.
sc-memory keeps one Markdown file per conclusion (a decision, a diagnosed bug, a preference, a verified fact), filed by kind.
Using it#
It saves on its own. You never call it; you talk the way you would to a colleague who was there last week:
Remember that the staging database resets every Sunday night.
It files that under the right kind.
Has this “connection reset during upload” error bitten us before?
It searches memory and answers from the few files that match, with their paths.
Where are we on the auth migration?
A long-running thread like this is kept as a quest, and the answer comes from its file.
What does config.rs contain now?
Memory holds conclusions, never the current state of code, files or builds, so the agent reads the file instead.
How it works
Why the plugin owns the trigger#
A session ends and its conclusions go with it, so the next one rediscovers the same bug and re-argues the same decision. Asking the main agent to “remember things” costs main-loop context on every turn, depends on the model complying, and writes untyped notes that nothing can index. In sc-memory a function-hook module counts steps and spawns the fork, and the bookkeeping lives in the plugin. The model judges what is worth keeping.
Where memory lives#
Each memory is a Markdown file under a kind: artifacts/, decisions/, gotchas/, notes/, patterns/, preferences/, quests/ or references/. Two roots hold them.
- The project tier is
$CLAUDE_MEMORY_PROJECT, whichscsets to<vault>/memories/p/<project>. Every agent of a project shares it. A workspace whose path has nop/<project>, such assystem, keeps<workspace>/.claude/memory. - The memory hub is
$CLAUDE_MEMORY_HUB, whichscsets to<vault>/memories. Every workspace in the vault reads it.
artifacts/ holds everything about Claude Artifact pages: style rules, flows, and a log of what was published.
With no vault, sc sets neither root, so sc-memory has nowhere to read or write until a vault exists (or you export CLAUDE_MEMORY_HUB yourself). The session-start hook never derives a root from the working directory.
Each root carries a generated INDEX.md.
Scope follows the kind. When a hub exists, preference, reference, pattern and artifact are written straight to the hub. decision, note and quest stay in the project. A gotcha splits on what it affects: a tool or platform bug goes to the hub, a bug in this repo’s code stays in the project. With no hub, everything is project-scoped. With only a hub (you exported CLAUDE_MEMORY_HUB yourself), everything goes to the hub and names its project in an origin: field.
At session start#
A SessionStart hook runs at startup, resume, /clear and compaction. It creates decisions/, gotchas/, notes/ and quests/ in the project tier when they are missing. With no hub it also creates patterns/, preferences/ and references/. artifacts/ is created on its first write. It checks that $CLAUDE_MEMORY_HUB, when set, points at a real directory; if not, it warns that global memory is unavailable and the session runs project-only. It then injects the map.
Every populated kind shows as kind/ (count). The main agent also sees the five most recent titles of artifacts/, decisions/, patterns/, preferences/ and quests/. Anything collapsed into a count is unsearched, not empty. The hook also injects the current timestamp and session id, which the writer uses for created, updated and sources.
The consolidation fork#
A function-hook module counts model steps in the main loop. When either condition is met, it spawns a fork subagent that runs the memorize pass on the conversation:
- the main loop has taken 30 model steps since the last pass, or
- the context has reached 70% of the auto-compact threshold, so a pass runs before compaction summarizes the work away.
The fork inherits the whole conversation and shows up as a visible task. Nothing is injected into the main agent to ask for it, and a fork spawned by a hook cannot re-trigger that hook, so the pass cannot loop.
Each pass ends with a RECAP: line naming the topics it saved. The module keeps the last three recaps in a ledger, which survives a resume, and hands them to the next pass, so each pass works only on what happened since the previous one. Only one pass runs at a time. A pass that never reports is dropped after 15 minutes so later passes can run.
While a pass is running, a tool.call hook limits it to memory work. Write, Edit and NotebookEdit are allowed only under a memory root. Mutating Bash commands are refused. It may spawn only memory-search by name; any other named subagent is refused. Read-only tools are untouched.
The memorize router#
The memorize pass triages the session and routes each insight to exactly one kind, using that kind’s template. An empty pass is a valid outcome, and it replies Nothing to consolidate: <one-line reason>. A few things always qualify: a diagnosed bug, a choice made with a reason, a verified fact, and anything you explicitly asked to remember. After writing, the router regenerates INDEX.md for every root it touched. The rules it adds to the prompt are on /prompts.
Subagents and recall#
A subagent cannot be forked, and its context is gone when it returns. So it gets two other things instead. At SubagentStart it receives its own memory map, which expands gotchas/, decisions/ and patterns/, plus a short protocol: offload findings to a file, and save anything durable through the memorize pass. During its run, a PostToolBatch hook reminds it every 30 tool batches to write down what it learned.
When the map shows a kind as a bare count, or a title hints at something older, the main agent asks its memory-search subagent. It returns a few ranked file paths with a one-line reason each, not a dump. It refuses a current-state question in one line, Not a memory question: <X> is current state; read <the file / run <the command>> instead, and names the live source if it can see it.
Reading and editing the files#
The files are plain Markdown. You can read them, grep them and commit them like any other file. Have the agent write new ones, though: it owns the frontmatter and the index, and a hand-written file breaks both.
Where it logs and keeps scratch state#
Every decision the module makes is one line in Claude Code’s debug log, as [sc-memory] $.ui.log (to debug): event {json}: a pass spawned, skipped, orphaned or denied, a recap harvested, a compaction, a guard refusal, a drift check. Watch it with claude --debug, or capture it with --debug-file <path>. Read it when you want to know whether a pass fired.
Scratch state lives outside the workspace, in $SC_MEMORY_RUNTIME, which sc sets to <runtime dir>/sc-memory/<workspace>, where the runtime dir is the sc runtime directory: inflight.json (passes in flight), counts.json (each live subagent’s batch count) and a steer-<loop>.txt that is deleted as it is delivered. Under a stock claude launch it falls back to a sc-memory-state directory in the OS temp directory.
What it needs
| Needs | Required | What for |
|---|---|---|
python3 | yes | the SessionStart, SubagentStart and PostToolBatch hooks |
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 | yes, for consolidation | loads the function-hook module that spawns passes and guards the fork |
CLAUDE_CODE_FORK_SUBAGENT=1 | yes, for consolidation | lets the module spawn a fork subagent |
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 | yes | keeps Claude Code’s built-in auto memory off (or set "autoMemoryEnabled": false) |
CLAUDE_MEMORY_PROJECT | no | the project tier; sc sets it to <vault>/memories/p/<project> |
CLAUDE_MEMORY_HUB | no | the cross-project hub; sc sets it to <vault>/memories, only when that directory exists, and unset means project-only when a vault resolves |
python3 for the hooks, and the two feature gates sc sets, are all it needs.
sc sets the two feature gates on every launch except incognito, and a value already in your environment wins. So CLAUDE_CODE_FORK_SUBAGENT=0 is an off switch. Without the function-hook gate, the module does not load: the map and the subagent reminders still work, but no consolidation pass runs. Under a stock claude launch, the prompt sections in plugin.toml do not render either, because only sc reads that file. Incognito launches (-i) disable all hooks, so sc-memory does nothing there.
Configuration
Three switches appear in Claude Code’s /config as sc-memory.<field> rows. Each turns one feature off when false.
| Row | Field | Default | What false turns off |
|---|---|---|---|
SC: Memory recall | recall | true | the memory map at session start and at subagent start |
SC: Memory auto-save | auto_save | true | the consolidation fork, the subagent write-it-down reminders, and the worker protocol’s save rule |
SC: Memory drift check | drift_check | false | the periodic drift check described below |
The cadences are fixed: a pass every 30 main-loop steps or at 70% of the auto-compact threshold, a subagent reminder every 30 tool batches, and a drift check every 360000 ms. Two env vars override the step cadences for one run:
| Env var | Overrides |
|---|---|
SC_MEMORY_MAIN_EVERY | the 30 main-loop steps |
SC_MEMORY_SUB_EVERY | the 30 subagent batches |
SC_MEMORY_MAIN_EVERY=15 sc <project> <agent>The cadences are loose on purpose. A pass is a real fork with its own context, which makes it the plugin’s main cost. Because each pass works only the delta since the last one, a longer window hands it more to do without losing anything, and the 70% threshold makes sure a pass still runs before compaction. That threshold is measured against the auto-compact threshold, not the model’s full context window. On a 1M-token model the window percentage reads low long after compaction is close.
Drift check#
With drift_check on, the module asks the model on a timer, out of band, whether the work still serves the goal you last stated. The question runs as a cache-shared model fork that costs the main context nothing. If the answer is that the work has drifted, it shows a toast and queues a one-time reminder that names the goal. The main loop receives that reminder after its next tool batch.
Name it in the manifest#
A workspace that loads it names it in the manifest (.claude/superclaude.toml):
plugins = ["$SC_PLUGINS/sc-memory"]Every workspace that loads the plugin renders its prompt sections automatically, after the manifest’s own system_prompt. plugin.toml publishes three: memory_protocol (the standing rules), memory_hub (project versus hub routing) and memory_explicit (fork mechanics spelled out for models that follow instructions literally). The first two always render. memory_explicit renders only when the launch model name contains deepseek, qwen, glm or kimi.
To change that gate, name the section in system_prompt with your own. The entry with a different gate wins, and the same gate is redundant:
system_prompt = [
{ ref = "sc-memory:memory_explicit", if = { var = "model", not_contains = "claude" } },
]Check a manifest after editing it with sc validate --spf <file>, or run sc validate from the workspace directory. To see the assembled prompt and which plugin sections arrived, run sc <project> <agent> --prompt. See superclaude.toml for the full system_prompt grammar.
Next: Web research