agent-memory exposes these command surfaces:
initupdaterecallqueryaddsyncautomateintegratemcpvalidatestatus
Install the package first:
npm install -D @agent-connect/memoryor:
pnpm add -D @agent-connect/memoryThen run the local CLI with npx agent-memory ....
Commands that synthesize or normalize memory accept:
--provider=auto|codex|claudeThis applies to:
initupdaterecallquerysync
Recall-oriented commands also read defaults from /.agent-memory/config.json.
npx agent-memory initUse init to rebuild a repository into the current schema.
What it does:
- clears and rebuilds
/.agent-memory/ - writes a fresh canonical bundle
- writes the first history event
- writes the first checkpoint
- rewrites projections and entry wiring
Optional validation:
npx agent-memory init --yes --validatenpx agent-memory updateUse update to refresh the active canonical bundle from current repository evidence.
What it does:
- reads the current canonical state
- re-synthesizes the active bundle
- writes a new tool-run event
- writes a new checkpoint
- rewrites projections and entry wiring
This command only supports the current schema. Old states must be replaced with init.
npx agent-memory recallUse recall to consolidate unrecalled history into the active canonical bundle.
What it does:
- reads unrecalled history events
- proposes a consolidated bundle
- previews grouped unrecalled history summary before apply
- prints summary changes and file diffs
- applies only after confirmation, unless
--yesis passed
If there are no unrecalled events, or if consolidation produces no durable changes, recall exits without writing state, checkpoints, or tool-run events.
Optional source filter:
npx agent-memory recall --source=imports
npx agent-memory recall --section=gotchas
npx agent-memory recall --policy=project-map-protected
npx agent-memory recall --show-diff
npx agent-memory recall --checkpoint chk-000001npx agent-memory query "how does caching work?"Use query to retrieve an answer from the memory system.
What it does:
- builds a shortlist from bundle, history, and checkpoints
- detects natural-language retrieval modes such as changes, next actions, and traps
- synthesizes a short answer
- returns citations for each claim, with bundle citations cross-linked to projection docs when applicable
Optional scope:
npx agent-memory query "what changed recently?" --scope=historyOptional output:
npx agent-memory query "what should I do next?" --output=jsonProjects can also override mode-specific retrieval instructions through .agent-memory/config.json.
npx agent-memory add claude-local ~/.claude --name claudeUse add to register an external session source.
npx agent-memory sync claude
npx agent-memory sync --allCurrent built-in source types:
claude-localcodex-local
sync normalizes external sessions into standard history events. It does not directly rewrite the active bundle; use recall for that.
sync is resilient to partial failures:
- valid sessions are imported
- duplicates are skipped
- malformed sessions are reported as failed items
- the source keeps a sync status that
validatecan later inspect
npx agent-memory automate startnpx agent-memory automate stopnpx agent-memory automate statusnpx agent-memory automate run-oncenpx agent-memory automate ensure-runningFirst milestone behavior:
- the daemon is local and built in, not cron-backed
- each cycle can run
sync --all - each cycle can auto-apply
recall - each cycle also evaluates retention and can archive aged history/checkpoints
- dirty worktrees do not block the cycle
- runtime metadata lives in
.agent-memory/automation/ - the latest machine-readable run result lives in
.agent-memory/automation/latest-run.json - archive batches live in
.agent-memory/archive/ - retention is enabled by default, but archived data no longer participates in active query/recall/status baselines
npx agent-memory integratenpx agent-memory integrate --dry-runnpx agent-memory integrate --status
npx agent-memory integrate --status --output=jsonnpx agent-memory integrate --repair
npx agent-memory integrate claude --repair --dry-runnpx agent-memory integrate claudenpx agent-memory integrate codexFirst milestone behavior:
initdoes not touch any chat-client config- Claude Code integration is project-scoped
- Codex MCP registration is global but merged safely
- Claude Code uses project MCP + project skills +
SessionStart/Stophooks - Codex uses MCP +
AGENTS.md+ the local daemon - Claude and Codex guidance now prefer
memory_assess,memory_compact_handoff, andmemory_maintainbefore lower-level MCP tools --dry-runis read-only and does not write project or user files--statusis read-only and reports current integration health--status --output=jsonreturns machine-readable integration status--repaironly rewrites managed mismatches and does not create missing components- normal
integratemay modify user-scope Codex config
Generated or updated files:
.mcp.json.claude/settings.json.claude/skills/agent-memory/SKILL.mdAGENTS.md~/.codex/config.toml
npx agent-memory mcp
npx agent-memory mcp --transport=http --port=8765Starts the local MCP server for chat-client integrations.
- stdio is the default transport
- HTTP transport is available with
--transport=http --port=<port> - HTTP mode also supports
--hostand--allowed-hosts
Primary workflow tools:
memory_assessAssess memory, automation, validation, and integration health in one responsememory_compact_handoffProduce a compact-ready handoff summary before session endmemory_maintainEnsure the daemon is running and perform one maintenance pass
Lower-level tools remain available for finer control:
memory_querymemory_statusmemory_validateautomation_statusautomation_ensure_runningautomation_run_once
Tool calls return human-readable text content plus versioned structuredContent envelopes.
Long-running tools such as memory_maintain, memory_query, and memory_validate also emit progress notifications when the client supplies a progress token.
npx agent-memory statusUse status before recall when you want a maintenance-oriented readout.
It shows:
- current state and latest checkpoint id
- unrecalled backlog counts plus a grouped summary of unrecalled history
- source sync health
- checkpoint drift summary
- retention prune candidates and archive summary
- the next suggested action
Optional flags:
npx agent-memory status --checkpoint chk-000001 --show-diffnpx agent-memory validateThis is a read-only audit.
It checks:
- current
state.jsonschema and bundle hash - history event readability and continuity
- checkpoint presence and latest checkpoint consistency
- source registry validity
- projection marker alignment
- entry block alignment
- referenced path existence
- validation baseline freshness
- recall backlog health
- recall configuration validity
- retention configuration validity
- archive manifest and batch integrity
Important interpretation:
failmeans the canonical system is structurally unhealthywarnmeans the system is still usable, but maintenance is recommended
init= bootstrapupdate= refresh active memoryrecall= consolidate historyquery= retrieve memoryautomate= run local automation for import-sync and recallintegrate= connect Claude Code and Codex to agent-memorymcp= expose agent-memory as a local MCP serveradd= add external session sourcessync= sync external session sources into history eventsvalidate= audit the systemstatus= inspect maintenance state before acting