Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
---
title: Muse Code Integration
description: Memory for Muse Code, Meta's terminal coding agent — hook-based observation recording, session-start context, session summaries, MCP memory search, read context and subagent context
icon: terminal
---
## Overview
The Muse Code integration gives your Muse agent the same memory as Claude Code. The next Muse session starts where the last one left off. It does five things:
1. **Observation recording**: Muse's lifecycle hooks send each tool call to the Claude-Mem worker, and the observer writes observations about it
2. **Context**: the `SessionStart` hook returns your memory as `hookSpecificOutput.additionalContext`, the same envelope Claude Code uses. This also runs after a compaction (`SessionStart` with `source` set to `compact`)
3. **Session summaries**: the `Stop` hook writes a summary from the last assistant message Muse sends
4. **MCP search tools**: the Claude-Mem MCP server gives Muse the `mcp__claude_mem__*` memory search tools (Muse writes the server name with an underscore)
5. **Read and subagent context**: before a `read_file` in the main session, the `PreToolUse` hook adds the file's memory timeline as context and never blocks the read. A new subagent starts with your memory timeline
<Info>
Muse Code reads user hooks from the `hooks` key and MCP servers from the `mcpServers` key in `~/.config/muse/settings.json`. The installer adds Claude-Mem's hooks and the `claude-mem` MCP server to that file. It keeps your other Muse settings, hooks and MCP servers.
</Info>
## Requirements
- Muse Code (the `muse` command), version 1.4.25 (the version tested). The integration was verified on macOS. Windows and Linux are untested.
- Any Muse model. The hooks do not depend on the model Muse uses.
- Claude-Mem runs on your computer. You do not need CMEM Pro.
## Installation
```bash
npx claude-mem install --ide muse-code
```
Or manage the integration directly:
```bash
npx claude-mem muse-code install
npx claude-mem muse-code status
npx claude-mem muse-code uninstall
```
The installer reads `~/.config/muse/settings.json`, saves a backup next to it (`settings.json.bak-YYYYMMDD`, once per day, readable only by you), and writes the new file in one step. If the file does not exist, the installer creates it with `schema_version` set to `1`. If the file is not valid JSON, or `hooks` or `mcpServers` is not an object, or one of the events Claude-Mem uses is not a list, the installer stops and changes nothing.
Start a new Muse session so Muse reads the new settings.
## Verify
1. Run `npx claude-mem muse-code status`. It prints `Muse Code hooks: installed`. It prints `incomplete` when a hook or the `claude-mem` MCP server is missing, `not installed` when neither is there, and `unreadable settings` when the file cannot be read. See [Troubleshooting](#troubleshooting).
2. Start a new Muse session in a project and ask the agent to read a file.
3. Watch the observation arrive in the viewer.
4. In a new session in a trusted folder, ask Muse to search your memory. It uses the `mcp__claude_mem__*` tools.
## What is captured and sent
- **Captured**: your prompts, each tool call (name, input and result, including failed calls), and the last assistant message of each turn.
- **Where it goes**: the hooks send this to the Claude-Mem worker on your computer. The worker sends it to the observer you chose with `CLAUDE_MEM_PROVIDER` (by default Claude, through your Claude account) to write observations and summaries. Memory is stored in `~/.claude-mem/`.
- **Opt out**: wrap text in [`<private>` tags](/usage/private-tags) to keep it out of memory, list tools in `CLAUDE_MEM_SKIP_TOOLS` to skip them (the Muse name, such as `search`, works), or run `npx claude-mem muse-code uninstall`.
## Event mapping
| Muse hook event | Claude-Mem event | Notes |
| --- | --- | --- |
| `SessionStart` | worker start, then `context` | memory is returned as `hookSpecificOutput.additionalContext`; also runs after a compaction |
| `UserPromptSubmit` | `session-init` | |
| `PreToolUse` | `file-context` | only for `read_file` (matcher `^read_file$`); adds the file's [memory timeline](/file-read-gate) as context and never blocks the read. Main session only: a subagent's `read_file` gets no file context |
| `PostToolUse` | `observation` | Muse tool names are mapped, see below |
| `PostToolUseFailure` | `observation` | recorded as a failed tool call with Muse's `error` text |
| `Stop` | `summarize` | uses `last_assistant_message` |
| `SubagentStart` | `subagent-context` | a subagent starts with your memory timeline, as the main session does |
| `SubagentStop` | `subagent-stop` | |
| `SessionEnd` | `session-end` | |
Each hook is a shell command (the Bun runtime plus the worker script, both quoted), uses the matcher `*` (except `PreToolUse`, which uses `^read_file$`), and has its own `timeout` in seconds: 60 for the worker start and context, 15 for `session-init` and `file-context`, 120 for `observation` and `summarize`, 20 for `subagent-context`, and 30 for `subagent-stop` and `session-end`.
### Tool names
Muse names its tools in snake_case. Claude-Mem maps the ones that have a direct Claude Code counterpart:
| Muse tool | Recorded as |
| --- | --- |
| `bash` | `Bash` |
| `read_file` | `Read` |
| `write_file` | `Write` |
| `edit_file` | `Edit` |
| `search` | `Grep` |
| `web_fetch` | `WebFetch` |
Every other tool keeps its Muse name. This includes the MCP tools (`mcp__<server>__<tool>`) and `subagent_spawn` and `subagent_wait`. For `Read`, `Write` and `Edit`, Claude-Mem adds a `file_path` to the tool input. It is the `path` Muse sends, resolved from the folder Muse works in. The original `path` stays.
### Subagents
Work done inside a Muse subagent is recorded under the parent session, so one task stays in one session. Muse runs subagents only in a trusted folder. When a subagent starts, Claude-Mem adds your memory timeline to it. Muse does not give a subagent its parent's context, so the timeline is not sent twice. Muse's own goal-reminder run, which happens after each turn, is not your work. Claude-Mem ignores it and sends it no timeline.
## Limits
- **Muse app**: the Muse app (cloud) has no official setting for a custom MCP server, so this integration does not cover it. It works with the Muse Code CLI.
- **User level only**: the hooks go into `~/.config/muse/settings.json` so they run in every folder, trusted or not. Claude-Mem does not write a project `.muse/hooks.json` or a Muse plugin. Either one next to the user hooks would run every hook twice.
- **Memory search needs a trusted folder**: Muse loads MCP servers, including the user-level `claude-mem` server, only in a trusted workspace. In an untrusted folder the hooks still record your work and load memory at session start, but the `mcp__claude_mem__*` tools are not there. Trust the folder in Muse, or start `muse` with `--trust-workspace`.
- **Read context only, never blocks**: before a `read_file` in the main session, the `PreToolUse` hook adds the file's memory timeline as context. A subagent's `read_file` gets no file context. The hook never blocks or rewrites the read. The [File Read Gate](/file-read-gate) block text names Claude Code's MCP tools, and Muse loads MCP only in a trusted folder, so a block could send the model to tools it does not have.
- **No `PermissionRequest`**: Claude-Mem has no handler for it.
- **No transcript**: Muse sends no transcript file, so the summary comes from the last assistant message.
- **No `~` expansion**: Muse does not expand `~` in a file path. It reads `<folder>/~/x`, and Claude-Mem records the same path.
- **Some tools pass through**: Muse tools `apply_patch` and `bash_input` are not mapped. When asked to use `apply_patch`, Muse used `edit_file` instead, so the tool was not seen in testing. An edit made with `apply_patch` may not be recorded as a modified file.
- **Settings written at the same moment**: if Muse writes `settings.json` while the installer does, the last writer wins.
- **macOS only**: only macOS was verified.
## Troubleshooting
- **Hooks do not run**: run `npx claude-mem muse-code status`, then start a new Muse session. Muse reads the settings when a session starts.
- **Muse has no `mcp__claude_mem__*` tools**: the folder is not trusted. Trust it in Muse, or start `muse` with `--trust-workspace`.
- **Status says incomplete**: a hook or the `claude-mem` MCP server was removed from `~/.config/muse/settings.json`. The status line names what is missing. Run `npx claude-mem muse-code install` again.
- **Status says unreadable settings**: `~/.config/muse/settings.json` is not valid JSON, or `hooks` or `mcpServers` is not an object. Fix the file, then run `npx claude-mem muse-code install`.
- **Bun not found**: the hooks run Bun by its absolute path. If you moved or reinstalled Bun, run `npx claude-mem muse-code install` again.
- **More detail**: Claude-Mem writes its logs to `~/.claude-mem/logs/`.
## Uninstall
```bash
npx claude-mem muse-code uninstall
```
This removes only Claude-Mem's hooks and the `claude-mem` MCP server from `~/.config/muse/settings.json`. Your other settings, hooks and MCP servers stay. `npx claude-mem uninstall` does the same as part of a full uninstall. Your memory in `~/.claude-mem/` is not deleted.