Skip to content

CLI Commands

All commands accept --palace <path> to override the default palace location. The top-level command also accepts --backend <name> to select a storage backend such as sqlite_exact, milvus, qdrant, or pgvector.

mempalace init

Scan a project directory for people, projects, and rooms, and set up the palace.

bash
mempalace init <dir>                 # <dir> is required
mempalace init <dir> --yes           # non-interactive mode
mempalace init ~/projects/myapp      # example
mempalace init .                     # initialize from the current directory
OptionDescription
<dir>Required. Project directory to scan. Pass . for the current directory.
--yesAuto-accept all detected entities

What it does:

  1. Scans <dir> for people and projects in file content
  2. Detects rooms from <dir>'s folder structure
  3. Saves detected entities to <dir>/entities.json
  4. Ensures the global ~/.mempalace/ config directory exists

Running mempalace init with no argument will exit with error: the following arguments are required: dir.

mempalace mine

Mine files into the palace.

bash
mempalace mine <dir>
mempalace mine <dir> --mode convos
mempalace mine <dir> --mode convos --extract general
mempalace mine <dir> --wing myapp
OptionDefaultDescription
<dir>Directory to mine
--modeprojectsprojects for code/docs, convos for chat exports
--wingdirectory nameWing name override
--agentmempalaceAgent name tag
--limit0 (all)Max files to process
--dry-runPreview without filing
--extractexchangeexchange or general (for convos mode)
--no-gitignoreDon't respect .gitignore
--include-ignoredAlways scan these paths even if ignored

Find anything by semantic search.

bash
mempalace search "query"
mempalace search "query" --wing myapp
mempalace search "query" --wing myapp --room auth
mempalace search "query" --results 10
OptionDefaultDescription
"query"What to search for
--wingallFilter by wing
--roomallFilter by room
--results5Number of results

mempalace list

Browse drawers by wing/room metadata — no ranking, no embedding. A fast, direct-to-daemon read: it hits palace-daemon directly and skips the MCP/AI round-trip, so it returns immediately.

bash
mempalace list
mempalace list --wing myapp
mempalace list --wing myapp --room auth
mempalace list --limit 50 --offset 50
mempalace list --format json
OptionDefaultDescription
--wingallLimit to one wing
--roomallLimit to one room
--limit20Max drawers to return (max: 1000)
--offset0Pagination offset
--formattabletable, compact (one line per drawer), full (no truncation), or json
--jsonShorthand for --format json

mempalace graph

Structural snapshot of the knowledge graph and palace — wings, rooms, tunnels, and KG entity/triple counts. Direct-to-daemon.

bash
mempalace graph
mempalace graph --limit 1000
mempalace graph --format full
mempalace graph --json
OptionDefaultDescription
--limit500Cap on KG entity count (max: 50000)
--formattabletable (summary + top wings), full (every wing + sampled triples), or json
--jsonShorthand for --format json

mempalace cypher

Run a read-only Cypher query against the Apache AGE knowledge graph. Write verbs are rejected server-side. Direct-to-daemon.

bash
mempalace cypher "MATCH (n) RETURN count(n)"
mempalace cypher "MATCH (n:Entity) RETURN n.name LIMIT 10"
mempalace cypher "MATCH (n) RETURN n.name" --format csv
mempalace cypher "MATCH (n) RETURN n" --json
OptionDefaultDescription
"query"Cypher query (MATCH / RETURN; write verbs are rejected)
--graphpalace graphAGE graph name
--limitAdvisory cap (use LIMIT in the query for a hard cutoff)
--formattabletable (aligned columns), json, or csv
--jsonShorthand for --format json

mempalace move

Relocate a single drawer to a different wing and/or room — metadata only, the verbatim content is never touched. Direct-to-daemon. Omitting both --wing and --room is a no-op (nothing to change).

bash
mempalace move <drawer_id> --wing myapp
mempalace move <drawer_id> --wing myapp --room auth
mempalace move <drawer_id> --room archive --format json
OptionDefaultDescription
drawer_idID of the drawer to move (positional, required)
--wingunchangedNew wing (omit to leave unchanged)
--roomunchangedNew room (omit to leave unchanged)
--formattabletable (old→new confirmation) or json (daemon pass-through)

mempalace bulk-move

Relocate every drawer matching a source wing/room filter to a target wing/room — metadata only, content untouched. Dry-run by default: without --apply it previews the matched drawers and the destination, changing nothing. Each drawer is moved by an independent PATCH, so a single failure doesn't abort the batch. At least one source filter (--wing/--room) and one target (--to-wing/--to-room) are required.

bash
# preview only (dry run)
mempalace bulk-move --wing scratch --to-wing archive
# execute, with interactive confirmation
mempalace bulk-move --wing scratch --room old --to-wing archive --apply
# execute non-interactively (CI / scripts)
mempalace bulk-move --wing scratch --to-wing archive --apply --yes
OptionDefaultDescription
--wingSource: select drawers in this wing (at least one of --wing/--room)
--roomSource: select drawers in this room (at least one of --wing/--room)
--to-wingTarget wing (at least one of --to-wing/--to-room)
--to-roomTarget room (at least one of --to-wing/--to-room)
--applyActually move the drawers (without it, preview only)
--yes, -ySkip the confirmation prompt (required to --apply non-interactively)
--formattabletable (preview/summary) or json (machine-readable)

mempalace split

Split concatenated transcript mega-files into per-session files.

bash
mempalace split <dir>
mempalace split <dir> --dry-run
mempalace split <dir> --min-sessions 3
mempalace split <dir> --output-dir ~/split-output/
OptionDefaultDescription
<dir>Directory with transcript files
--output-dirsame dirWrite split files here
--dry-runPreview without writing
--min-sessions2Only split files with N+ sessions

mempalace wake-up

Show L0 + L1 wake-up context (~600–900 tokens).

bash
mempalace wake-up
mempalace wake-up --wing driftwood
OptionDescription
--wingProject-specific wake-up

mempalace compress

Compress drawers using AAAK Dialect.

bash
mempalace compress --wing myapp
mempalace compress --wing myapp --dry-run
mempalace compress --config entities.json
OptionDescription
--wingWing to compress (default: all)
--dry-runPreview without storing
--configEntity config JSON file

mempalace status

Show what's been filed — drawer count, wing/room breakdown.

bash
mempalace status

mempalace stats

Palace analytics dashboard — wings, rooms, knowledge graph, tunnels, and optionally tags. Direct-to-daemon (one GET /stats REST call), so it's faster than the equivalent MCP tool fan-out.

bash
mempalace stats
mempalace stats --section kg
mempalace stats --section graph
mempalace stats --tags
mempalace stats --json
OptionDefaultDescription
--top10Max rows per section (0 shows all)
--tagsInclude the tag-count breakdown (extra daemon call)
--sectionallkg, graph, status, or all
--no-relationship-typesSuppress the (potentially long) relationship-types list
--formattabletable or json
--jsonShorthand for --format json

mempalace repair

Rebuild palace vector index from stored data. Fixes segfaults after database corruption.

bash
mempalace repair

Creates a backup at <palace_path>.backup before rebuilding, replacing any backup already there.

FlagDescription
rebuild-indexPositional alias for --mode from-sqlite --archive-existing
--modelegacy (default), max-seq-id, or from-sqlite
--dry-runPrint what the repair would do and exit without modifying the palace
--yesSkip confirmation for destructive changes
--backupBack up SQLite before mutation (default: on)
--sourceSource palace for --mode from-sqlite (defaults to --palace)
--archive-existingRename the existing palace to <palace>.pre-rebuild-<timestamp> first
--segmentSegment UUID filter for --mode max-seq-id
--from-sidecarPre-corruption chroma.sqlite3 to copy clean max_seq_id values from
--confirm-truncation-okOverride the truncation safety guard. Disables the abort that protects you when the collection layer returns fewer drawers than SQLite holds

mempalace prune

Delete drawers older than --stale-days N. Dry-run by default — reports a count without deleting unless you pass --confirm.

bash
mempalace prune --stale-days 90              # dry-run: report only
mempalace prune --stale-days 90 --confirm    # actually delete
mempalace prune --stale-days 90 --wing scratch --confirm
OptionDefaultDescription
--stale-daysrequiredPrune drawers whose filed_at is older than this many days
--wingallLimit prune to this wing
--roomallLimit prune to this room
--confirmActually delete (without it, prune only reports a dry-run count)

mempalace mcp

Helper command that outputs setup syntax (like claude mcp add...) to connect MemPalace to your AI client, automatically handling paths.

bash
mempalace mcp
mempalace mcp --palace ~/.custom-palace

mempalace hook

Run hook logic for Claude Code / Codex integration.

bash
mempalace hook run --hook stop --harness claude-code
mempalace hook run --hook precompact --harness claude-code
mempalace hook run --hook session-start --harness codex
OptionValuesDescription
--hooksession-start, stop, precompactHook name
--harnessclaude-code, codexHarness type

mempalace instructions

Output skill instructions to stdout.

bash
mempalace instructions init
mempalace instructions search
mempalace instructions mine
mempalace instructions help
mempalace instructions status

mempalace logstream

Agent coordination events — delegate work, wait for replies, acknowledge outcomes (RFC 003). Operates on logstream.sqlite3 in the palace directory; safe to run alongside a live hub. See Agent Logstream.

bash
mempalace logstream append --type task.request --stream project/myapp \
  --room delegation --from-agent mac --to-agent windows \
  --correlation-id task_123 --body "Please fix the flaky test."

mempalace logstream list --stream project/myapp --room delegation --json
mempalace logstream wait --correlation-id task_123 --type patch.ready \
  --timeout-ms 300000 --json
mempalace logstream ack evt_... --from-agent mac --status applied

# Background watcher: blocks, wakes on what needs you, exits 0 on a match
mempalace logstream watch --agent mac --type task.request --type patch.ready \
  --state-file ~/.mempalace/watch/mac.json --json
SubcommandDescription
appendAppend an immutable event (--type, --stream, --room, --from-agent required; --body/--body-file, --artifact-id repeatable)
listList events, oldest first (all routing fields as filters, --since-event-id, --limit)
waitLong-poll until a match or timeout (--timeout-ms, max 300000; exits 2 on timeout)
watchBackground watcher: re-arms past the wait cap, carries the cursor, and exits 0 on a match / 2 on --idle-exit-ms. --agent ID is shorthand for --to-agent ID --exclude-from-agent ID so your own * broadcasts never wake you. Filters repeat to mean "or"; --state-file resumes exactly; --follow stays alive past the first match; a cursorless first run starts at the tip (--from-start to replay); exits 130 if interrupted; --follow --json emits NDJSON
ackAppend an event.ack for an event (--from-agent required, --status, --body)
syncPull missing events/artifacts from peer replicas (--peer URL --token T, or all peers in peers.json)

All subcommands accept --json for scriptable output.

mempalace artifact

Exact artifact exchange for agent handoffs — unified diffs, files, logs. Content is stored verbatim with a SHA-256.

bash
git diff | mempalace artifact put --kind patch --created-by windows --json
mempalace artifact get art_... | git apply --3way
mempalace artifact get art_... --out /tmp/handoff.patch
SubcommandDescription
putStore content (--kind patch|file|log|json|note, --created-by required; --content, --file, or stdin)
getPrint exact content to stdout, or --out FILE; --json for metadata

Released under the MIT License.