Skip to content

Claude Code

Terminal window
agent-mem setup claude --write

Writes the hooks into ~/.claude/settings.json (merged with yours) and registers the MCP server with claude mcp add --scope user agent-mem -- <path>/agent-mem mcp. If claude is not on PATH, setup prints that line for you to run.

CLAUDE_CONFIG_DIR moves ~/.claude, and setup follows it.

EventMatcherModeTimeoutagent-mem does
SessionStart—sync10 sbriefing, panel, viewer start; after compaction the compact block
SubagentStart—sync10 sthe briefing for each subagent
UserPromptSubmit—sync10 snew turn, rules, confident matches
PreToolUseBash|Edit|Write|MultiEdit|NotebookEditsync10 srule note or deny, file history
PostToolUse*async10 srecord, recipes, dead ends, feedback
PostToolUseFailure*sync10 srecord the failure, fix hint
Stop—async10 sanswer, close the turn, start the observer
SubagentStop—async10 sthe subagent’s answer for the bundle
PreCompact—async10 srecorded
SessionEnd—async10 sclose, summary line

Payloads and outputs are on Hook Lifecycle.

  • Session start and after compaction: the panel, in colour (NO_COLOR turns colour off), via systemMessage.
  • Session end: agent-mem session saved · 2 requests · 1 file · facts are added in the background.
  • Failures you must act on, in red, at most every ten minutes.
  • Nothing for ordinary prompts and tool calls.

The model gets context through hookSpecificOutput.additionalContext on session start, prompts and around tools, and a deny through permissionDecision: "deny".

Claude Code passes at most 10,000 characters per hook string to the model and moves the rest to a file the model is not told to read. agent-mem caps every block for Claude Code at 2,400 tokens, whatever the budget says.

Claude Code requests are turned into facts by claude -p … --model haiku under your login, in an empty temporary folder, with no tools, no MCP servers, no settings and no saved session. observe.claude_model changes the model; a model your plan does not offer is retried with the CLI’s default. A usage limit or a missing login pauses facts for an hour; requests wait.

Claude Code keeps notes in ~/.claude/projects/<folder>/memory/*.md and loads them itself. agent-mem reads them as native_note memories and shows them to Codex, Copilot and OpenCode, never back to Claude Code. A note deleted in Claude Code is retired in agent-mem too. "native_notes": false turns this off.

Claude Code’s transcripts (~/.claude/projects/<folder>/<session>.jsonl and subagent transcripts) give the work behind each request: input, cache writes and output. See Token Accounting.