Migrated from AutoHub issue #528. AutoHub is the private automation-hub tracker; this work belongs in verygoodplugins/automem.
Claude Code hook-based passive memory capture is core AutoMem product/plugin work, not AutoHub runtime work.
Original source: https://github.com/verygoodplugins/autohub/issues/528
AutoMem Claude Code Plugin — Passive Memory Capture via mcp_tool Hooks
Type: fix_plan / Feature Issue
Lane: opportunity
Priority: High
Sources:
Background
Claude Code's hook system now supports "type": "mcp_tool" hooks (officially documented). This allows any registered MCP server to receive lifecycle events from Claude Code deterministically — without relying on the agent to choose to call memory tools.
Current AutoMem integration requires agents to explicitly call store_memory. That is:
- Opt-in and agent-cooperative (the agent can skip it)
- Dependent on CLAUDE.md prompt instructions (subject to context compaction)
- Invisible at the tool-call level
Hooks are different. They fire regardless of model behavior, are deterministic, and cannot be bypassed (a PreToolUse hook returning deny blocks even --dangerously-skip-permissions).
Opportunity: Zero-Friction Passive Memory Capture
AutoMem could ship a Claude Code plugin / hook config that passively captures memory from four high-value lifecycle events:
| Event |
AutoMem Action |
Why it Matters |
PostToolUse |
store_memory for significant tool results |
Captures file edits, bash outputs, search results without any agent cooperation |
Stop |
consolidate_session — link session memories |
Session summary + cross-memory graph edges at turn end |
PostCompact |
preserve_pre_compact_context |
Rescues important context before compaction discards it |
SubagentStop |
Cross-agent memory transfer |
Subagent findings become first-class memories for the orchestrator |
Product gap confirmed: No memory MCP server (Mem0, Zep, engram, Hindsight) currently ships a Claude Code hook integration. The standard setup requires CLAUDE.md instructions which are prompt-cooperative, not deterministic.
Implementation Plan
1. New AutoMem MCP Tools (mcp-server additions)
// tool: capture_tool_use
// Called from PostToolUse hook
{
name: "capture_tool_use",
description: "Passively record a Claude Code tool call and result as a memory",
inputSchema: {
tool_name: string, // e.g. "Bash", "Write", "Read"
tool_input_summary: string,
tool_output_summary: string,
session_id: string,
importance_hint?: number // 0-1, optional override
}
}
// tool: consolidate_session
// Called from Stop hook
{
name: "consolidate_session",
description: "Create a session summary memory and link related tool-use memories",
inputSchema: {
session_id: string,
workflow_name?: string
}
}
// tool: preserve_pre_compact_context
// Called from PostCompact hook
{
name: "preserve_pre_compact_context",
description: "Store key context from a compacted session before it is lost",
inputSchema: {
compact_summary: string, // Claude's own compaction summary
session_id: string
}
}
2. Claude Code Hook Configuration (.claude/settings.json snippet)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash|Write|Edit|MultiEdit|WebSearch|WebFetch",
"hooks": [
{
"type": "mcp_tool",
"server": "automem",
"tool": "capture_tool_use",
"args": {
"tool_name": "{{tool_name}}",
"tool_input_summary": "{{input_summary}}",
"tool_output_summary": "{{output_summary}}",
"session_id": "{{session_id}}"
}
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "mcp_tool",
"server": "automem",
"tool": "consolidate_session",
"args": {
"session_id": "{{session_id}}",
"workflow_name": "{{workflow_name}}"
}
}
]
}
],
"PostCompact": [
{
"hooks": [
{
"type": "mcp_tool",
"server": "automem",
"tool": "preserve_pre_compact_context",
"args": {
"compact_summary": "{{summary}}",
"session_id": "{{session_id}}"
}
}
]
}
]
}
}
3. Claude Code Plugin Manifest
Ship as a distributable plugin so any Claude Code user can claude plugin install automem:
automem-claude-plugin/
├── .claude-plugin/
│ └── plugin.json # plugin manifest
├── skills/
│ └── automem-recall.md # "before starting work, recall relevant memories"
├── hooks/
│ └── settings-fragment.json
└── README.md
4. Files to Create/Modify
| File |
Change |
src/mcp-server/tools/capture-tool-use.ts |
New tool |
src/mcp-server/tools/consolidate-session.ts |
New tool |
src/mcp-server/tools/preserve-compact-context.ts |
New tool |
src/mcp-server/index.ts |
Register 3 new tools |
docs/claude-code-plugin.md |
Installation guide |
.claude-plugin/plugin.json |
Plugin manifest |
skills/automem-recall.md |
Recall skill |
Acceptance Criteria
PostToolUse hook fires on Bash, Write, Edit tool calls → AutoMem stores a memory with tool, input_hash, output_summary, timestamp, session_id
Stop hook fires → AutoMem creates a session summary memory linking all tool-use memories from that session via PART_OF edges
PostCompact hook fires → AutoMem stores the compaction summary as a Context memory with high importance
- Plugin installable via
claude plugin install or manual copy
- Test: 5-turn Claude Code session → verify 5+ memories stored passively with correct graph edges
- No agent instruction changes required — works with empty CLAUDE.md
Why This Matters for AutoMem's Graph Strategy
The key AutoMem graph insight: memories are more valuable as a graph than as isolated facts. The hook integration enables:
LEADS_TO edges: Bash(run tests) → Edit(fix failing test) — causal chain from tool sequence
PART_OF edges: all tool-use memories → session summary
OCCURRED_BEFORE edges: automatic temporal ordering within sessions
- Cross-session
RELATES_TO: same file edited in different sessions → link automatically
This closes the gap between AutoMem's graph model and the "passive recall" capability that Mem0 and Zep currently market as their differentiator. AutoMem's graph wins if the edges are written from real tool-call evidence, not just LLM-summarized text.
Competitive Differentiation
| System |
Claude Code Hook Integration |
| Mem0 |
❌ None (CLAUDE.md only) |
| Zep / Graphiti |
❌ None |
| engram |
❌ None |
| Hindsight |
❌ None |
| AutoMem (proposed) |
✅ Native mcp_tool hooks |
Frontier Candidate
Add to frontier: opportunity:automem-claude-code-hook-integration
- Lane:
opportunity
- Priority: 80 (higher than BEAM because zero external dependency, ships to production users)
- Status:
open
Secondary Lead: LongMemEval-V2 (arXiv:2605.12493, May 12 2026)
Brand new (3 days old). Tests "knowledgeable colleague" memory — interface affordances, state dynamics, workflows, recurring failure modes. AutoMem's Pattern/Context types + LEADS_TO/OCCURRED_BEFORE edges map directly. No MCP memory system evaluated yet.
Action: Add frontier candidate research:longmemeval-v2-evaluation and outreach to Di Wu (UCLA) once code is released.
Migrated from AutoHub issue #528. AutoHub is the private automation-hub tracker; this work belongs in
verygoodplugins/automem.Claude Code hook-based passive memory capture is core AutoMem product/plugin work, not AutoHub runtime work.
Original source: https://github.com/verygoodplugins/autohub/issues/528
AutoMem Claude Code Plugin — Passive Memory Capture via
mcp_toolHooksType:
fix_plan/ Feature IssueLane:
opportunityPriority: High
Sources:
Background
Claude Code's hook system now supports
"type": "mcp_tool"hooks (officially documented). This allows any registered MCP server to receive lifecycle events from Claude Code deterministically — without relying on the agent to choose to call memory tools.Current AutoMem integration requires agents to explicitly call
store_memory. That is:Hooks are different. They fire regardless of model behavior, are deterministic, and cannot be bypassed (a
PreToolUsehook returningdenyblocks even--dangerously-skip-permissions).Opportunity: Zero-Friction Passive Memory Capture
AutoMem could ship a Claude Code plugin / hook config that passively captures memory from four high-value lifecycle events:
PostToolUsestore_memoryfor significant tool resultsStopconsolidate_session— link session memoriesPostCompactpreserve_pre_compact_contextSubagentStopProduct gap confirmed: No memory MCP server (Mem0, Zep, engram, Hindsight) currently ships a Claude Code hook integration. The standard setup requires CLAUDE.md instructions which are prompt-cooperative, not deterministic.
Implementation Plan
1. New AutoMem MCP Tools (mcp-server additions)
2. Claude Code Hook Configuration (
.claude/settings.jsonsnippet){ "hooks": { "PostToolUse": [ { "matcher": "Bash|Write|Edit|MultiEdit|WebSearch|WebFetch", "hooks": [ { "type": "mcp_tool", "server": "automem", "tool": "capture_tool_use", "args": { "tool_name": "{{tool_name}}", "tool_input_summary": "{{input_summary}}", "tool_output_summary": "{{output_summary}}", "session_id": "{{session_id}}" } } ] } ], "Stop": [ { "hooks": [ { "type": "mcp_tool", "server": "automem", "tool": "consolidate_session", "args": { "session_id": "{{session_id}}", "workflow_name": "{{workflow_name}}" } } ] } ], "PostCompact": [ { "hooks": [ { "type": "mcp_tool", "server": "automem", "tool": "preserve_pre_compact_context", "args": { "compact_summary": "{{summary}}", "session_id": "{{session_id}}" } } ] } ] } }3. Claude Code Plugin Manifest
Ship as a distributable plugin so any Claude Code user can
claude plugin install automem:4. Files to Create/Modify
src/mcp-server/tools/capture-tool-use.tssrc/mcp-server/tools/consolidate-session.tssrc/mcp-server/tools/preserve-compact-context.tssrc/mcp-server/index.tsdocs/claude-code-plugin.md.claude-plugin/plugin.jsonskills/automem-recall.mdAcceptance Criteria
PostToolUsehook fires onBash,Write,Edittool calls → AutoMem stores a memory withtool,input_hash,output_summary,timestamp,session_idStophook fires → AutoMem creates a session summary memory linking all tool-use memories from that session viaPART_OFedgesPostCompacthook fires → AutoMem stores the compaction summary as aContextmemory with high importanceclaude plugin installor manual copyWhy This Matters for AutoMem's Graph Strategy
The key AutoMem graph insight: memories are more valuable as a graph than as isolated facts. The hook integration enables:
LEADS_TOedges:Bash(run tests)→Edit(fix failing test)— causal chain from tool sequencePART_OFedges: all tool-use memories → session summaryOCCURRED_BEFOREedges: automatic temporal ordering within sessionsRELATES_TO: same file edited in different sessions → link automaticallyThis closes the gap between AutoMem's graph model and the "passive recall" capability that Mem0 and Zep currently market as their differentiator. AutoMem's graph wins if the edges are written from real tool-call evidence, not just LLM-summarized text.
Competitive Differentiation
mcp_toolhooksFrontier Candidate
Add to frontier:
opportunity:automem-claude-code-hook-integrationopportunityopenSecondary Lead: LongMemEval-V2 (arXiv:2605.12493, May 12 2026)
Brand new (3 days old). Tests "knowledgeable colleague" memory — interface affordances, state dynamics, workflows, recurring failure modes. AutoMem's Pattern/Context types + LEADS_TO/OCCURRED_BEFORE edges map directly. No MCP memory system evaluated yet.
Action: Add frontier candidate
research:longmemeval-v2-evaluationand outreach to Di Wu (UCLA) once code is released.