Skip to main content
The agentmemory CLI is the primary way to manage the memory server, connect agents, and inspect memory state. Every command runs as agentmemory <command> (or npx @agentmemory/agentmemory <command> before a global install).

Global Options

These flags work with any command, including the default start command.
OptionDescription
--help, -hShow help
--verbose, -vShow engine stderr and diagnostic info
--version, -VPrint the installed version
--resetWipe ~/.agentmemory/preferences.json and re-run onboarding
--port <N>Override REST port (default: 3111). The viewer port (N+2) and all other derived ports automatically shift with N
--instance <N>Shortcut to run a secondary instance: --instance 1 maps to port 3211, --instance 2 to 3311, and so on (max N=50)
--tools all|coreTool visibility: all exposes all 53 tools, core exposes the 8 essential tools. Unknown values print a warning and fall back to all
--no-engineSkip auto-starting iii-engine (useful when you manage the engine separately)

Commands

agentmemory (start)

Starts the memory server. On first run, agentmemory auto-installs the pinned iii-engine runtime if it isn’t already present. Once the server is ready, agentmemory prints the REST API and viewer URLs so you can confirm everything is running.
# Start with defaults (REST on :3111)
agentmemory

# Start on a custom port
agentmemory --port 4000

# Start with only the 8 core tools exposed to agents
agentmemory --tools core

# Run a second instance on port 3211 alongside the default
agentmemory --instance 1
Run agentmemory connect <agent> in a separate terminal after the server is up to wire your coding agent into the running instance.

agentmemory init

Creates ~/.agentmemory/.env from the bundled default template. Safe to re-run — if the file already exists it is left untouched and you are shown a diff hint so you can compare against the latest template.
agentmemory init
After running init, open ~/.agentmemory/.env in your editor, uncomment your LLM provider key, and restart agentmemory.

agentmemory connect [agent]

Wires Agent Memory into an installed coding agent by writing the MCP server configuration into the agent’s settings file. Run without an argument for an interactive picker that shows all detected agents on your machine. Supported agents: claude-code, cursor, copilot-cli, codex, gemini-cli, cline, zed, warp, continue, openclaw, hermes, pi, openhuman, droid, kiro, qwen, antigravity
# Wire a specific agent
agentmemory connect claude-code
agentmemory connect cursor
agentmemory connect cline

# Interactive picker (shows all detected agents)
agentmemory connect

# Preview what would change without writing anything
agentmemory connect claude-code --dry-run

# Re-install an existing connection (overwrite)
agentmemory connect claude-code --force

# Wire every detected agent at once
agentmemory connect --all
After connecting, restart your agent application so it picks up the new MCP server configuration.

agentmemory status

Shows a real-time snapshot of your running memory server: session count, observation count, memory count, knowledge graph stats (nodes and edges), active feature flags, estimated token savings, and circuit breaker state.
agentmemory status
Example output:
Health:       ✓ healthy
Sessions:     14
Observations: 1,042
Memories:     87
Graph:        312 nodes, 891 edges
Circuit:      closed
Heap:         142 MB
Uptime:       3847s
Viewer:       http://localhost:3113

Token savings: ~78,120 tokens saved (92% reduction)
  Full context: ~84,920 tokens
  Injected:     ~1,900 tokens

Provider:     ✓ llm
Embeddings:   ✓ embeddings
Flags:
  ✓ CONSOLIDATION_ENABLED       4-tier consolidation pipeline
  ✓ GRAPH_EXTRACTION_ENABLED    Knowledge graph extraction
  ✗ AGENTMEMORY_REFLECT         Auto-synthesize lessons
If the server is not running, status exits with an error and prints the start command.

agentmemory doctor

An interactive diagnostic tool that checks for common issues — missing provider keys, unreachable viewer, engine version mismatches, and more — and offers to fix each one in place. Interactive keys:
KeyAction
FApply the suggested fix
SSkip this check
?Show detailed explanation
QQuit doctor
# Interactive mode (recommended)
agentmemory doctor

# Apply all available fixes automatically (useful in CI)
agentmemory doctor --all

# Show what each fix would do without executing anything
agentmemory doctor --dry-run
--all and --dry-run cannot be combined. Use one or the other.
Doctor first runs a passive server check (health, LLM provider, embeddings, Claude Code hooks, knowledge graph) and prints a summary panel. It then steps through the full diagnostic catalog and prompts you for each failing check.

agentmemory demo [--serve]

Seeds three realistic sample sessions (JWT auth setup, database migration debugging, rate limiting) and runs smart-search queries against them to demonstrate semantic recall. The demo shows how a query like “database performance optimization” surfaces the N+1 query fix — something keyword matching alone cannot do.
# Run demo against an already-running server
agentmemory demo

# Start the server, run the demo, then stop — one command, no second terminal
agentmemory demo --serve
After the demo, the output panel shows the viewer URL and a cleanup curl command to delete the seeded demo data.

agentmemory upgrade

Upgrades local npm dependencies and the pinned iii-engine binary to the latest compatible version. The command detects whether you are using pnpm or npm and runs the appropriate install command, then prompts you to re-run the iii-engine installer.
agentmemory upgrade
Run agentmemory status and your test suite after upgrading to confirm nothing has changed in behaviour.

agentmemory stop [--force]

Gracefully stops the running agentmemory worker (flushing its BM25/vector index to disk first) and then stops the iii-engine process. Use --force to bypass the Docker-heuristic guard and signal whatever lsof reports on the REST port — useful when the engine was started natively but the state file is missing.
# Graceful stop
agentmemory stop

# Force stop (bypasses safety guard)
agentmemory stop --force
Memories are always persisted to disk before the worker exits. You can restart safely at any time with agentmemory.

agentmemory remove

Cleanly uninstalls Agent Memory. Builds a destruction plan (pidfiles, state files, .env, iii-engine binary, connect backups) and shows it before asking for confirmation. Data in ~/.agentmemory/ is included in the plan unless you pass --keep-data.
FlagDescription
--forceSkip all confirmation prompts
--keep-dataRemove the installation but preserve memory data in ~/.agentmemory/
# Interactive remove (shows plan and asks twice to confirm)
agentmemory remove

# Keep your memory data but remove everything else
agentmemory remove --keep-data

# Skip prompts entirely (destructive — use with care)
agentmemory remove --force
agentmemory remove does not uninstall the npm package itself. After removing, run npm uninstall -g @agentmemory/agentmemory to remove the CLI binary.

agentmemory mcp

Starts the standalone MCP shim without launching the full iii-engine. The REST API remains available at :3111. Use this for minimal deployments or MCP-only clients (Cursor, Gemini CLI, etc.) that do not need the full engine stack.
agentmemory mcp
The standalone MCP shim uses a local fallback store at ~/.agentmemory/standalone.json when the main server is unreachable. Set STANDALONE_PERSIST_PATH in your .env to change this location.

agentmemory import-jsonl [path]

Imports Claude Code JSONL session transcripts into Agent Memory so you can search and recall past work. Defaults to scanning ~/.claude/projects/. The server must be running before you import.
FlagDescription
--max-files NLimit the scan to the N most recent files (default: 200, max: 1000)
pathCustom directory to import from instead of ~/.claude/projects/
# Import from the default location
agentmemory import-jsonl

# Import only the 50 most recent transcript files
agentmemory import-jsonl --max-files 50

# Import from a specific directory
agentmemory import-jsonl /path/to/transcripts
For very large transcript trees (>1000 files), batch the import by subdirectory — run import-jsonl once per project folder under ~/.claude/projects/.
After a successful import, the command prints the session count, observation count, and a link to the Replay tab in the viewer.