agentmemory — Components
12 Claude Code Hooks
All hooks are Node.js .mjs scripts in plugin/scripts/, invoked via plugin/hooks/hooks.json:
| Event |
Script |
What it does |
| SessionStart |
session-start.mjs |
Registers session; if AGENTMEMORY_INJECT_CONTEXT=true, fetches and writes context to stdout |
| UserPromptSubmit |
prompt-submit.mjs |
Intercepts user prompt for pre-processing / context injection |
| PreToolUse |
pre-tool-use.mjs |
Matcher: Edit|Write|Read|Glob|Grep — captures intent before file ops |
| PostToolUse |
post-tool-use.mjs |
Captures tool output as observation |
| PostToolUseFailure |
post-tool-failure.mjs |
Records failure events for pattern detection |
| PreCompact |
pre-compact.mjs |
Claude-bridge sync + injects compressed context to survive compaction |
| SubagentStart |
subagent-start.mjs |
Registers sub-agent spawning in session graph |
| SubagentStop |
subagent-stop.mjs |
Captures sub-agent completion |
| Notification |
notification.mjs |
Handles async agent notifications |
| TaskCompleted |
task-completed.mjs |
Records task completion observations |
| Stop |
stop.mjs |
Session close — triggers compression and summarization |
| SessionEnd |
session-end.mjs |
Final cleanup and state flush |
Pre-compaction hook pattern (from pre-compact.mjs): fetches /agentmemory/context from REST API and writes compressed context to stdout so Claude Code injects it as the first message of the new compacted context.
8 Claude Code Skills
All skills are invokable via /skill-name [args] in Claude Code:
| Skill |
Description |
| recall |
Invokes memory_smart_search MCP tool (hybrid BM25+vector+graph search); returns results grouped by session with importance scoring |
| handoff |
Resumes most recent session; directory-boundary cwd matching; surfaces unanswered questions first |
| remember |
Invokes memory_save to persist an explicit insight, decision, or pattern |
| forget |
Deletes a memory by ID or matching query; requires confirmation |
| recap |
Summarizes current session observations to date |
| commit-context |
Recalls memory observations related to files touched in recent git commits |
| commit-history |
Looks up past session context associated with a specific commit SHA or branch |
| session-history |
Lists all sessions for the current project directory with dates and summaries |
Full tool list extracted from src/mcp/tools-registry.ts:
Core recall/search: memory_recall, memory_smart_search, memory_vision_search, memory_timeline, memory_patterns, memory_sessions, memory_file_history, memory_profile
Storage/save: memory_save, memory_compress_file, memory_export, memory_snapshot_create, memory_checkpoint, memory_crystallize
Graph/relations: memory_relations, memory_graph_query, memory_commit_lookup, memory_commits, memory_claude_bridge_sync
Team/sharing: memory_team_share, memory_team_feed
Governance: memory_audit, memory_governance_delete, memory_verify, memory_diagnose, memory_heal
Workflow/automation: memory_action_create, memory_action_update, memory_frontier, memory_next, memory_lease, memory_routine_run
Signals/comms: memory_signal_send, memory_signal_read, memory_mesh_sync
Sentinels/watchers: memory_sentinel_create, memory_sentinel_trigger
Sketches (scratch to crystal pipeline): memory_sketch_create, memory_sketch_promote
Facets (tagging): memory_facet_tag, memory_facet_query
Learning: memory_lesson_save, memory_lesson_recall
Reflection/insights: memory_reflect, memory_insight_list, memory_consolidate
Slots (scoped storage): memory_slot_list, memory_slot_get, memory_slot_create, memory_slot_append, memory_slot_replace, memory_slot_delete
Integrations: memory_obsidian_export
REST API (port 3111)
Key endpoints (from src/triggers/api.ts):
POST /agentmemory/session/start — registers session, optionally returns injected context
POST /agentmemory/context — returns compressed context for pre-compaction injection
GET /agentmemory/sessions — list sessions (used by handoff skill fallback)
POST /agentmemory/recall — search (fallback when MCP unavailable)
GET /agentmemory/health — server health and config flags
Bearer token authentication via AGENTMEMORY_SECRET env var.
State Schema (iii-engine KV keys)
Key namespaces in src/state/schema.ts:
mem:sessions — session registry
mem:obs:{sessionId} — observations per session
mem:memories — long-term memories
mem:graph:nodes / mem:graph:edges — knowledge graph
mem:slots / mem:slots:global — scoped storage slots
mem:audit — governance audit log
mem:lessons / mem:insights — learned lessons
mem:team:{teamId}:shared — team-shared memory
mem:signals — cross-agent signal bus
mem:mesh — agent mesh topology
mem:crystals — crystallized permanent memories
mem:sentinels — trigger watchers
mem-live stream — real-time viewer feed
65+ Function Files
src/functions/ contains 65+ TypeScript modules: observe.ts, search.ts, smart-search.ts, graph.ts, graph-retrieval.ts, temporal-graph.ts, compress.ts, compress-file.ts, consolidate.ts, crystallize.ts, evict.ts, auto-forget.ts, signals.ts, mesh.ts, sentinels.ts, sketches.ts, facets.ts, lessons.ts, reflect.ts, slots.ts, snapshot.ts, checkpoints.ts, leases.ts, routines.ts, team.ts, audit.ts, governance.ts, vision-search.ts, obsidian-export.ts, working-memory.ts, timeline.ts, profile.ts, patterns.ts, relations.ts, export-import.ts, verify.ts, diagnostics.ts, enrich.ts, dedup.ts, retention.ts, access-tracker.ts, and more.