Recommended Claude Code config

Drop-in templates for an mneme-aware Claude Code setup. Copy any or all into your own config; tune from there.

The walkthrough in Setting up with Claude Code is the prose explanation of how and why. This page is the copy-paste kit. Both stay in sync — the hook scripts and settings snippet referenced here are the same files that ship in the repo under docs/examples/, included verbatim below.

1. CLAUDE.md template

Drop this into ~/.claude/CLAUDE.md (user-scope, applies everywhere) or <repo>/CLAUDE.md (project-scope, only when Claude Code runs in that repo). Both work; pick the scope that matches how you want mneme to participate.

## Memory (mneme)

You have [mneme](https://github.com/tr0mb1r/mneme) — a local-first MCP
memory server. Mneme has four memory layers:

- **L0 procedural** — pinned rules (`pin` / `unpin`); surfaces on every
  recall context.
- **L1 working session** — turn log, checkpointed; resets per process.
- **L3 episodic** — recent events (tool calls, lifecycle events,
  conversation turns, curated semantic events); time-ordered, not
  embedded (ADR-0007).
- **L4 semantic** — long-term facts / decisions / preferences /
  conversations; embedding-indexed.

The default scope is `global` (v1.1.x+; pre-1.1.x installs defaulted
to `personal`). Use `switch_scope` once per session if you want a
different default for write tools (`remember`, `pin`, `record_event`);
the filter tools (`recall`, `recall_recent`, `forget`,
`summarize_session`, `export`) treat omitted `scope` as no-filter.

### Tools

- `mneme.recall(query, limit?, scope?, type?, tags?, mode?)` — semantic search across
  **L4 only** (ADR-0010). L3 events are not embedded (ADR-0007); to
  search them by similarity, also `remember` the distilled fact to L4.
  Use `recall` before answering questions about past work.
- `mneme.recall_recent(limit?, scope?, kind?)` — last-N L3 events. No
  embedding; fast. Use for "what was the last thing on this branch?"
  Pass `kind` to filter by event kind (e.g. `decision`, `milestone`).
- `mneme.remember(content, type?, tags?, scope?, pinned?, supersedes?)` — write L3 + L4.
  `type` ∈ {`fact` (default), `decision`, `preference`, `conversation`}.
  **Size:** target under 500 chars; 500–2k accepted with a
  `length_advisory`, 2k–10k with a `length_warning`, over 10k
  rejected. Extract the key insight rather than pasting source
  material. See `book/src/mcp-surface.md` §Size guardrails.
- `mneme.pin(content, tags?, scope?)` — write L0 procedural. Use for
  hard rules ("always X", "never Y") that should surface every session.
- `mneme.record_event(kind, payload, tags?, scope?, retrieval_weight?)`
  — agent-driven L3 producer. `kind` is free-form; canonical kinds:
  `user_message`, `assistant_message`, `decision`, `problem`,
  `resolution`, `milestone`, `preference`, `pivot`, `observation`,
  `summary`. For `user_message` / `assistant_message` the server also
  pushes a matching turn into L1 — one tool call, both layers
  populated.
- `mneme.update(id, ...)` — revise an existing memory; auto-re-embeds
  if `content` changes.
- `mneme.forget(id)` — permanent delete. Resolves the ULID across L4
  semantic, L0 procedural, and L3 episodic (hot+warm tiers); first hit
  wins. Cold-archive entries are not reachable. **Always confirm with the
  user before calling.**
- `mneme.summarize_session(events?, scope?)` — returns a prompt template
  populated with recent L3 events. Feed it through your own completion
  path, then land the digest via `record_event(kind="summary",
  payload={"text": …, "covers": [event_ids]})` and `remember` / `pin`
  any durable facts or rules the digest surfaces.
- `mneme.stats` / `mneme.list_scopes` / `mneme.export(scope?, limit_per_layer?)`
  — diagnostics. Cheap to call.
- `mneme.switch_scope(scope)` — sets the current default scope for the
  rest of the process.

### Resources

- `mneme://procedural` — every pinned rule. Read on turn 1; treat pins
  as binding for the rest of the session.
- `mneme://context` — assembled context (pinned + recent + working,
  packed against a token budget). Single-call replacement for reading
  procedural + recent + recall separately.
- `mneme://recent` — last-N L3 events.
- `mneme://session/{id}` — a specific session's full state.
- `mneme://stats` — per-layer counts, schema version, applied LSN,
  current scope.

### Layer separation (binding)

- **L3 stays unembedded.** Similarity search is L4's job exclusively.
  `recall` returns L4 hits only; `recall_recent` returns L3 hits only —
  no cross-pollination. Duplication via `remember` is the feature.
- **Auto-emits are server-emitted; never double-record.** The server
  writes `tool_call`, `tool_call_failed`, `session_start`, and
  `session_end` automatically. Do NOT call `record_event` for these
  kinds — you'll create duplicates. Note: `session_start` and
  `session_end` mark the **MCP server's** lifecycle (the
  `mneme daemon` process under v1.1's default flow, or a single-host
  `mneme run`). They are NOT per-agent-session events — `mneme client`
  connections come and go without emitting any lifecycle event.
- **`tool_call` payloads carry only the value-bearing arg** of each
  tool (`remember.content`, `recall.query`, `forget.id`, etc.). The
  full `arguments` object is never mirrored — that's an explicit
  privacy invariant.
- **Privacy discipline.** `record_event` and `remember` payloads are
  opaque to mneme. Never include credentials, secrets, API tokens, or
  other sensitive material — the L3 cold archive retains content for
  180+ days and round-trips through `mneme backup` / `mneme restore`.

### Protocol

- **On session start**: read `mneme://procedural` and `mneme://context`.
  The SessionStart hook nudges this; do it even if the nudge didn't
  fire.
- **Before answering about past work, decisions, or rules**: call
  `mneme.recall` first. If it returns nothing, say so — never
  hallucinate past context.
- **When the user shares a fact, decision, or preference** that should
  outlive the session: call `mneme.remember` with the matching `type`.
- **When the user states a hard rule** ("always use uv", "never push to
  main"): call `mneme.pin` instead.
- **Per substantive turn**: capture the exchange via
  `record_event(kind="user_message", payload={"content": <prompt>})`
  and
  `record_event(kind="assistant_message", payload={"content": <reply
  or honest precis>})`. Skip pure-ack turns and meta-only exchanges
  (the auto-emitted `tool_call` already covers tool dispatches).
  Truncate long content at ~4000 chars with a trailing `…` marker.
- **When a turn produces curated semantic content**, also call
  `record_event` with the matching kind: `decision` (with
  `reasoning`), `milestone`, `problem` / `resolution` (link via
  `references` in the resolution payload), `pivot`, `preference`, or
  `observation`.
- **Before context compaction** (PreCompact hook fires) **and at the
  end of significant sessions**: call `mneme.summarize_session`, fill
  the returned prompt template through your completion path, then
  `record_event(kind="summary", payload={"text": …, "covers":
  [event_ids]})` to land the digest in L3. `remember` / `pin` the
  durable facts and rules the digest surfaces.
- **Never invoke `forget` without explicit user confirmation.** Deletion
  is permanent.

What it does:

  • Describes the four memory layers so the agent picks the right tool for the right kind of write.
  • Documents the read-on-session-start protocol so the agent doesn't forget to consult mneme before answering.
  • Locks down forget behind explicit user confirmation — deletion is permanent.

2. settings.json template

Drop this into ~/.claude/settings.json (user-scope) or <repo>/.claude/settings.json (project-scope). If you already have a settings.json, merge each top-level key (mcpServers, hooks, permissions) rather than overwriting the file.

{
  "mcpServers": {
    "mneme": {
      "command": "mneme",
      "args": ["run"]
    }
  },
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/mneme/session-start.sh" }
        ]
      }
    ],
    "PreCompact": [
      {
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/mneme/precompact.sh" }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/mneme/stop.sh" }
        ]
      }
    ]
  },
  "permissions": {
    "allow": [
      "mcp__mneme__*",
      "Bash(mneme:*)"
    ]
  }
}

Three blocks, each independent:

mcpServers

Registers mneme as an MCP server. Equivalent to running claude mcp add --scope user mneme mneme run — pick whichever feels more natural. The CLI form is what the setup guide walks you through; this JSON form is what claude mcp add writes under the hood.

hooks

Wires the three lifecycle scripts (SessionStart, PreCompact, Stop) into Claude Code so the load-and-save loop is deterministic rather than depending on the agent to remember to consult mneme.

The script files themselves ship under docs/examples/claude-code-hooks/ in the upstream repo. Copy them to ~/.claude/hooks/mneme/ and chmod +x:

mkdir -p ~/.claude/hooks/mneme
cp docs/examples/claude-code-hooks/session-start.sh \
   docs/examples/claude-code-hooks/precompact.sh \
   docs/examples/claude-code-hooks/stop.sh \
   ~/.claude/hooks/mneme/
chmod +x ~/.claude/hooks/mneme/*.sh

The hooks emit nudges on stdout; Claude Code surfaces them as additional context, and the agent makes the actual mneme.* tool calls. Each hook is independent — drop any of the three from the hooks block to disable that beat. See the setup guide §7.3 for the per-hook opt-out patterns.

permissions

Mneme-specific entries only. The template allows two patterns so the agent doesn't get prompted on every routine mneme call:

  • mcp__mneme__* — every mneme MCP tool (recall, remember, pin, recall_recent, summarize_session, …). The forget confirmation rule lives in CLAUDE.md (see template above), not here.
  • Bash(mneme:*) — the mneme CLI subcommands (mneme run, mneme stats, mneme inspect, mneme backup, etc.).

Anything not listed falls back to Claude Code's default behaviour (prompt the user). The template intentionally does not prescribe what other tools (cargo, git, gh, shell utilities, …) should be pre-allowed — those are personal choices that depend on the projects you work in. See the next section for how to grow the list from your real usage.

3. Refining over time

The mneme-only allow list above is the floor. To grow it without guessing, run the /fewer-permission-prompts skill after a few sessions — it scans your recent transcripts for read-only Bash and MCP tool calls that prompted, and proposes additions to your allow list. Iterate from your real usage rather than guessing patterns up front.

If you want a deny list too, scope it to operations that should always require explicit confirmation (git push, rm -rf, cargo publish, etc.) and merge it into the same permissions block. Anything denied prompts even if a wider allow pattern gets added later.

4. Verifying the setup

After dropping in the files and restarting Claude Code:

  1. MCP listing — type /mcp. You should see mneme with 13 tools and 5 resources.
  2. Tool smoke — ask the agent to call mneme.stats. The call should run without a permission prompt (the mcp__mneme__* allow pattern covers it) and return the per-layer counts.
  3. Hook smoke — pin a sentinel rule and confirm the agent reads it on session start. Walkthrough in the setup guide §7.4.

If /mcp doesn't list mneme, see the setup guide's troubleshooting section.