Skip to content

Claude Code

Claude Code connects to Spongram through a plugin that declares the MCP server and adds what MCP alone cannot do: project context at session start, reminders to save, and a capture of the conversation before it is compacted. This page covers the two ways to install the plugin, what it ships, and every setting that controls it.

Two ways to install

Public plugin Per-instance bundle
Source The public marketplace ezeeFlop/claude-plugins A .plugin file downloaded from your server's admin UI
Instance URL and brain key Typed once in Claude Code's configuration form Written in the bundle's files, in clear
Contains a secret No Yes: treat the file as a password
Persona skills Not included Included, generated from your brain's personas
Language of the session-start context From the shell locale (LANG / LC_ALL): French when it starts with fr, English otherwise From the brain's language setting
Typical use Default choice Fallback when the public marketplace cannot be used, or when persona skills are needed

Both install a plugin named spongram, so a Claude Code installation is connected to one brain at a time. To switch brains, uninstall the current plugin and install the other.

The machine that runs Claude Code needs python3, curl and git on its PATH: the hooks are shell scripts that call them. A missing tool never breaks a session; the hook exits and injects nothing.

Public plugin

claude plugin marketplace add ezeeFlop/claude-plugins
claude plugin install spongram@sponge-theory

When the plugin is enabled, Claude Code shows its configuration form with two fields:

Field Value
instance_url The public URL of your Spongram server, without /mcp, for example https://spongram.example.com. The form is pre-filled with a hosted default: replace it with your own URL.
brain_key The spt_brain_xxx key shown once when the brain was created. Marked sensitive.

The MCP server then connects with Authorization: Bearer <brain_key>. After a key regeneration, enter the new key in the plugin configuration.

If your Claude Code build does not show the form, the MCP server alone can be added by hand:

claude mcp add --transport http spongram https://spongram.example.com/mcp \
  --header "Authorization: Bearer spt_brain_xxx"

This gives the tools only: no hooks, no skill, no commands.

Per-instance bundle

The admin UI offers the bundle when a brain is created and again after a key regeneration, because the server does not keep the clear key and needs it to build the file. The same file is served by the admin API at GET /admin/api/spongram/instances/{id}/bundle/claude-code.plugin, with the brain key in the X-Spongram-Brain-Key header. See admin UI and admin API.

A .plugin file is a zip archive that holds a local Claude Code marketplace named spongram with one plugin, spongram. Extract it, then register the folder:

mkdir -p ~/spongram-plugin
unzip -o ~/Downloads/my-brain.plugin -d ~/spongram-plugin

Then, inside Claude Code:

/plugin marketplace add ~/spongram-plugin
/plugin install spongram@spongram

To update, download the bundle again, extract it over the same folder, then run /plugin marketplace update spongram and /plugin install spongram@spongram.

To uninstall, run /plugin uninstall spongram@spongram and /plugin marketplace remove spongram, then delete the folder. If the code-map git hook was installed in some repositories, remove it first in each of them (see code map).

Warning

The bundle contains the brain key in clear, in .mcp.json and in the hook scripts. Send it through a private channel and never commit it. If it leaks, regenerate the key: every bundle built with the old key stops working.

Check the installation

/plugin                  the plugin "spongram" is listed as installed
/spongram:brain-stats    the server answers and lists the latest episodes

Then tell Claude something durable ("remember that I write commit messages in English"), open a new session, and run /spongram:recall commit messages.

What the plugin ships

Component Path in the plugin Role
MCP server declaration .mcp.json HTTP server spongram at <instance_url>/mcp, with the Authorization header and X-Spongram-Client: claude-code.
Skill skills/spongram/SKILL.md Teaches Claude when to save, when to recall, and how to tag.
Commands commands/ /spongram:recall, /spongram:brain-stats, /spongram:brain-graph, /spongram:persona.
Hooks hooks/ Session start, reminders, capture, code-map setup. See below.
Project identity lib/project_context.py Computes the project slug and the tags of the session.
Code-map extractor lib/spongram_codemap/ Builds the structural map pushed to the server.

The X-Spongram-Client: claude-code header makes the server send the voice variant of an active persona and label writes client=claude-code. It grants nothing. See client contract.

Commands

Command What it does
/spongram:recall <topic> Calls search_nodes with the topic and summarises the top results.
/spongram:brain-stats Calls get_status, then get_episodes with max_episodes=5, and prints a compact status.
/spongram:brain-graph Prints the URL of the graph explorer, <instance_url>/v1/graph. The page asks for the brain key. The per-instance bundle prints the URL with the key in its fragment (#key=): a fragment is not sent to the server, but it stays in the browser history. See Cortex and Wiki.
/spongram:persona Lists the brain's personas. With a slug, /spongram:persona <slug> calls activate_persona and adopts the returned block.

Hooks

Claude Code event Script Purpose
SessionStart (startup, resume, clear, compact) recall-on-start.sh Injects the project context and recent memory.
SessionStart (same four sources) setup-codemap.sh Installs the code-map git hook for the repository and seeds a first map.
Stop memory-nudge.sh Reminds the model to save when nothing has been written for a while.
PostToolUse on Bash memory-nudge.sh Same reminder, right after a git commit.
PreCompact memory-capture.sh Sends the end of the transcript to the server for distillation.
SessionEnd memory-capture.sh Same capture when the session closes.

The split between a reminder and a capture follows what Claude Code hooks can do. Stop and PostToolUse can hand text back to the model, so they can ask it to write. PreCompact and SessionEnd cannot: one can only block a compaction, the other runs after the session is over. Compaction is exactly when context is discarded, so the capture at those two points does not rely on the model at all.

Every hook is written to never block or break a session: any failure, missing tool or slow network makes it exit silently.

Project context injection

At every session start, including after /clear, a resume and a compaction, recall-on-start.sh:

  1. computes the project of the session with lib/project_context.py;
  2. reads, with a 3-second timeout per request, the five most recent episodes of that project, the five most recent project=global episodes, the three most recent episodes of the brain as a fallback when the project has none (the public plugin leaves out those tagged with another project), the code-map summary, and the active persona's voice block;
  3. injects one block of context into the session.

The injected block contains, in order: a note that the client's own instructions and the repository's conventions take precedence over Spongram; the active persona's voice block, if any; the project context (project_slug, repo, branch, working directory); the tagging rule with the exact tag line to copy on every add_memory; the rule to pass scope.project on searches; the global and project episodes (each shortened to a few hundred characters); and the code-map summary (cut to 4000 characters).

The tag line looks like this:

project=my-project repo=acme/my-project branch=main client=claude-code

The context is re-injected at each of the four session-start sources because Claude Code drops it after a compaction or a resume.

If the server is unreachable, the block is still injected without the episodes: the project context is what keeps the tagging correct.

The project slug and .spongram.json

The slug is the first of these that yields a value: the SPONGRAM_PROJECT environment variable; the nearest .spongram.json between the session directory and the git root; the name of the main repository (a linked worktree uses the main repository's name); the name of the directory.

{"project": "my-project"}

Commit a .spongram.json at the root of a repository to give several folders or repositories the same project, for Claude Code and Codex alike. The complete rules, including normalisation, are in tagging and scope.

Labels that already exist in the brain under other names can be grouped without touching any repository: ask Claude to "group web and old-name under my-project", which uses project aliases.

Memory reminder

memory-nudge.sh adds a short advisory note to the model's context. It never forces an extra turn, never blocks, and makes no network call. It fires in two situations:

Trigger Condition Tuning
End of a turn (Stop) The session has at least 20 user or assistant turns, no add_memory or record_skill in the last 30, and no reminder in the last 25. SPONGRAM_NUDGE_MIN_ENTRIES, SPONGRAM_NUDGE_GAP, SPONGRAM_NUDGE_COOLDOWN
A real git commit run through Bash (not --dry-run) No write in the last 8 turns and no reminder in the last 8. SPONGRAM_NUDGE_COMMIT_GAP, SPONGRAM_NUDGE_COMMIT_COOLDOWN

The commit reminder exists because a commit message records what changed, not what was ruled out or why an approach won, and that reasoning is fresh at that moment.

The script runs at the end of every turn, so it reads only a bounded tail of the transcript (SPONGRAM_NUDGE_WINDOW_BYTES, 2 000 000 by default): its cost does not grow with the session. It keeps one small state file per session under ~/.spongram/state/ and deletes those older than 14 days.

Set SPONGRAM_NUDGE_DISABLED=1 to turn the reminder off.

Out-of-band capture

On PreCompact and SessionEnd, memory-capture.sh reads the end of the transcript and posts it to the server, which extracts the durable facts and queues them as episodes.

Client side:

  • reads at most SPONGRAM_CAPTURE_WINDOW_BYTES (1 500 000) from the end of the transcript;
  • keeps the text of user and assistant turns only, each cut to 4000 characters, the last SPONGRAM_CAPTURE_MAX_TURNS (300) of them;
  • does nothing when fewer than SPONGRAM_CAPTURE_MIN_TURNS (6) turns are found;
  • runs detached with a timeout of SPONGRAM_CAPTURE_TIMEOUT seconds (240), so a compaction or an exit never waits for it.

Server side, the route is POST /v1/memory/distill, authenticated with the brain key:

{
  "source": "precompact",
  "project": "my-project",
  "repo": "acme/my-project",
  "branch": "main",
  "turns": [{"role": "user", "text": "..."}, {"role": "assistant", "text": "..."}]
}
  • source is precompact or sessionend; any other value answers HTTP 400.
  • The server keeps at most 400 turns, 4000 characters per turn and 120 000 characters in total, starting from the most recent.
  • It asks the extraction model for at most 8 durable facts and writes each one to the ingestion queue as an episode tagged with the project, repository and branch of the request, then client=claude-code capture=auto. The group_id always comes from the brain key, never from the request.
  • The answer is {"queued": <number of episodes>, "facts": [<names>]}.
  • The route answers HTTP 503 unless SPONGRAM_DISTILL_ENABLED is on (off in the code, on in the container image). The hook treats a 503 as "nothing to do".
  • With the Cloud control plane, the route needs the memory.write permission.

Set SPONGRAM_CAPTURE_DISABLED=1 before starting Claude Code to turn the capture off on a machine.

Warning

The capture sends conversation text to your Spongram server and to its inference backend. It does not guarantee that secrets pasted in the conversation are removed. Disable it on machines where that matters.

Code map

setup-codemap.sh runs at session start in a git repository. It installs a post-commit git hook that refreshes the brain's code map after each commit, and builds a first map if the repository has none. See code map for the feature itself.

  • A git hook runs outside Claude Code and cannot read the plugin's configuration, so it needs its own copy of the connection. The public plugin writes the instance URL and the brain key to ~/.spongram/codemap/connection.env with mode 600, refreshed at the next session start after a key change. The per-instance bundle writes them in the block it appends to .git/hooks/post-commit of each repository. Both are clear copies of the key: keep them private, and reinstall the hook after a key regeneration when you use the bundle.
  • The extractor and a launcher are copied to ~/.spongram/codemap/, so a plugin update does not break the hook installed in your repositories.
  • Nothing is installed in a linked git worktree; the main checkout publishes the map.
  • To opt out, set SPONGRAM_CODEMAP_DISABLE=1 or create the file ~/.spongram/codemap/disabled.
  • Opting out does not remove a hook already installed. Run bash <plugin-root>/hooks/uninstall-codemap-hook.sh in each repository: it removes the Spongram part of .git/hooks/post-commit, keeps anything else in that hook, and deletes the state file.

Persona skills in per-instance bundles

A persona can reference skills in the Agent Skills format (SKILL.md). When SPONGRAM_PERSONAS_ENABLED is on, a per-instance bundle includes each skill referenced by at least one persona of the brain, as:

plugins/spongram/skills/persona-<skill-slug>/SKILL.md

Claude Code then discovers them as ordinary plugin skills. The description of each one is prefixed with a sentence naming the persona it belongs to and saying it is to be used only while that persona is active, so Claude does not pick it up in an unrelated session.

  • The skills are written into the bundle when it is generated. After adding or changing a persona skill, download the bundle again and reinstall it.
  • The public plugin and the Claude Desktop .mcpb never contain persona skills. Without the bundle, an agent still reaches a skill of the active persona with the get_skill tool.
  • Personas and their skills are edited on <instance_url>/v1/personas. Activation is requested from the agent, with /spongram:persona <slug> or in plain words. See personas.

Claude Code only ever inherits a persona's tone and language by default, under the rule that the project's conventions and development instructions take precedence. The plugin installs no output style and changes no permission, tool list or project instruction file.

Settings reference

Environment variables read by the hooks, on the machine that runs Claude Code:

Variable Default Effect
SPONGRAM_PROJECT unset Forces the project slug of the session.
SPONGRAM_NUDGE_DISABLED unset Any value disables the memory reminder.
SPONGRAM_NUDGE_GAP 30 Turns without a write before the end-of-turn reminder.
SPONGRAM_NUDGE_COOLDOWN 25 Turns between two end-of-turn reminders.
SPONGRAM_NUDGE_MIN_ENTRIES 20 Minimum session length for the end-of-turn reminder.
SPONGRAM_NUDGE_COMMIT_GAP 8 Turns without a write before the commit reminder.
SPONGRAM_NUDGE_COMMIT_COOLDOWN 8 Turns between two commit reminders.
SPONGRAM_NUDGE_WINDOW_BYTES 2000000 Size of the transcript tail the reminder reads.
SPONGRAM_CAPTURE_DISABLED unset Any value disables the out-of-band capture.
SPONGRAM_CAPTURE_WINDOW_BYTES 1500000 Size of the transcript tail the capture reads.
SPONGRAM_CAPTURE_MAX_TURNS 300 Maximum number of turns sent.
SPONGRAM_CAPTURE_MIN_TURNS 6 Below this number of turns nothing is sent.
SPONGRAM_CAPTURE_TIMEOUT 240 Timeout of the capture request, in seconds.
SPONGRAM_CODEMAP_DISABLE unset Any value disables the code-map setup at session start.

Server flags that change what the plugin can do are listed in feature flags: SPONGRAM_DISTILL_ENABLED, SPONGRAM_READ_SCOPING_ENABLED, SPONGRAM_PERSONAS_ENABLED, SPONGRAM_PROJECT_ALIASES_ENABLED.

What leaves the machine

  • Memory writes and code-map uploads go to the Spongram server configured in the plugin.
  • The capture sends the end of the transcript to the same server.
  • Memories retrieved by a search are returned to Claude Code and become part of the context sent to its model provider. The memory graph stays on your infrastructure; what an agent reads from it does not.