Memory Commands
CLI commands for reading, recording, searching, and consolidating project memory.
The memory command family provides tools for initializing workspaces, recording facts, building prompt context, auditing repository integrity, creating snapshots, and maintaining the memory knowledge graph.
memofs init
Initializes a new canonical .memofs/ workspace directory layout, bootstrapping all required seed files and writing a default .memofs/config.json.
memofs init
memofs init -p my-project --no-input
memofs init --force
memofs init --no-embeddingsOptions
| Flag | Description | Default |
|---|---|---|
-f, --force | Overwrite existing seed files if .memofs/ already exists | false |
-p, --project-id <id> | Explicit project identifier to seed in manifest.json | Prompted or auto-generated |
--no-input | Skip interactive TTY prompt for project ID (uses random UUID if omitted) | false |
--no-embeddings | Skip predownloading the local embedding model (also skipped when MEMOFS_SKIP_MODEL_DOWNLOAD=1 or MEMOFS_LOCAL_EMBEDDINGS=0 is set) | false |
Behavior
- Creates the canonical directory structure under
.memofs/. - Seeds canonical memory files via
memo.bootstrap(). - Writes
.memofs/config.jsonconfigured forlocalruntime withrecall: { engine: "auto", localEmbeddings: true }, so hybrid recall is enabled before the MCP server connects. - Predownloads the local embedding model into the shared user-level cache, so an agent's first connection does not pay the weight download. The model is resolved from the project's own
node_modules(where@memofs/mcp-serverinstalls it); this step is non-fatal — offline installs still succeed and the download is retried on first recall. With--json, the outcome is reported as a structuredembeddingsfield instead of progress output. - If
.memofs/manifest.jsonalready exists and--forceis not set, skips bootstrapping and informs the user.
memofs remember
Stores a durable note block in memory/notes.md and appends a memory.created event to events/memory-events.jsonl.
memofs remember "Use PostgreSQL for metadata store" --kind decision --title "Metadata Engine"
memofs remember --file ./notes/architecture.md --kind reference --tag architecture --tag database
echo "Max request body size is 10MB" | memofs remember --stdin --kind constraintOptions
| Flag | Description | Default |
|---|---|---|
[content] | Inline text content to store | — |
--stdin | Read memory content from standard input | false |
--file <path> | Read memory content from a file inside the workspace root | — |
-k, --kind <kind> | Note category: decision, constraint, goal, preference, reference, summary, or note | note |
--title <title> | Optional header title for the note | — |
-t, --tag <tag> | Tag to attach (repeatable) | [] |
--confidence <n> | Confidence score from 0 to 1 (numeric or float string) | 1 |
--source <source> | Source identifier or URI | — |
--actor <actor> | Actor performing the write: user, agent, system, api, or type:id (e.g. agent:claude) | user |
--metadata-json <json> | Additional structured metadata as a JSON object string | — |
--allow-secrets | Allow content that triggers secret detection heuristics | false |
Content Resolution & Secret Guardrails
- Precedence: Inline argument
[content]->--file <path>->--stdin. - Secret Scanning: Scans content against automated detection patterns. If a secret is detected, write fails immediately with
CLI_USAGE_ERROR(exit code1) unless--allow-secretsis provided.
memofs context
Packs project memory (core memory, notes, graph entities, and relevant recall) into a condensed, token-budgeted prompt briefing for AI agents. Calls the same intelligence pipeline (memo.context()) used by the MCP server.
memofs context --query "how to deploy workers"
memofs context --query "fix auth bug" --task-type debug
memofs context --max-chars 8000 --json
memofs context --mark-session-startOptions
| Flag | Description | Default |
|---|---|---|
-q, --query <query> | Prioritize memories matching a specific task or question | "" |
--task-type <type> | Biases strategist query expansion: coding, debug, refactor, docs, general | general |
--max-chars <n> | Maximum character limit for output briefing (maps to maxBytes) | 12000 |
--mark-session-start | Writes a memory.indexed event with metadata: { hook: "session-start" } | false |
Use --task-type to refine memory retrieval:
debug: Prioritizes recent errors, constraints, and known workarounds.refactor: Prioritizes architecture decisions, component boundaries, and invariants.docs: Prioritizes interfaces, public APIs, and user guides.
memofs read
Reads and outputs the raw text content of a canonical memory file.
memofs read core
memofs read notes
memofs read manifestArguments
| Argument | Description | Allowed Values |
|---|---|---|
<target> | The canonical memory document to read | core, notes, manifest |
memofs inspect
Displays an inspection dashboard of the current memory workspace, reporting physical file existence, byte sizes, line counts, JSONL record counts, and aggregate metrics.
memofs inspect
memofs inspect --jsonInspected Metrics
- Files:
manifest.json,memory/core.md,memory/notes.md,events/memory-events.jsonl,events/conversations.jsonl,indexes/chunks.jsonl,graph/nodes.jsonl,graph/edges.jsonl,snapshots/snapshots.jsonl. - Summary Counts:
eventCount,conversationCount,chunkCount,graphNodeCount,graphEdgeCount,snapshotCount.
memofs search
Searches memory text files (core.md, notes.md, conversations.jsonl) for substring occurrences or regular expression patterns.
memofs search "authentication"
memofs search "jwt.*expiration" --regexOptions
| Flag | Description | Default |
|---|---|---|
<query> | Text substring or regex pattern to match | (Required) |
-e, --regex | Treat query as a case-insensitive regular expression | false |
memofs events
Reads chronological records from the memory event log (events/memory-events.jsonl).
memofs events
memofs events --limit 25
memofs events --strict --jsonOptions
| Flag | Description | Default |
|---|---|---|
-l, --limit <n> | Limit output to the last N events (0 = all) | 0 |
-s, --strict | Throws CLI_JSONL_ERROR on malformed lines instead of skipping | false |
memofs chunks
Reads chunk index records from indexes/chunks.jsonl.
memofs chunks --limit 50Options
| Flag | Description | Default |
|---|---|---|
-l, --limit <n> | Limit output to the last N chunks (0 = all) | 0 |
-s, --strict | Throws CLI_JSONL_ERROR on malformed lines instead of skipping | false |
memofs snapshot
Creates an immutable snapshot bundle containing all tracked canonical memory files under .memofs/snapshots/<id>.json.
memofs snapshot --label "before-migration"Options
| Flag | Description | Default |
|---|---|---|
-l, --label <name> | Snapshot label (1–80 chars; letters, numbers, dots, hyphens, underscores) | manual |
Snapshot Integrity
- Gathers all canonical memory files into a bundle object with a protocol version header.
- Computes a SHA-256 checksum over the serialized bundle.
- Writes
.memofs/snapshots/<label>-<timestamp>.json. - Appends index entry to
snapshots/snapshots.jsonland emitssnapshot.createdevent inevents/memory-events.jsonl.
memofs diff
Compares two memory snapshots by ID or label, identifying added, removed, or modified files and calculating byte and record deltas.
memofs diff before-migration after-migrationArguments
| Argument | Description |
|---|---|
<labelA> | ID or label of the first snapshot (baseline) |
<labelB> | ID or label of the second snapshot (target) |
Diff Output Indicators
+(Added file): File exists only in snapshot B.-(Removed file): File exists only in snapshot A.~(Modified file): File content differs; reports byte changes and JSONL record deltas.
memofs doctor
Audits workspace integrity, schema validity, referential links, and core memory size limits.
memofs doctor
memofs doctor --strict
memofs doctor --fixOptions
| Flag | Description | Default |
|---|---|---|
-s, --strict | Enforces strict schema checking during JSONL record validation | false |
--fix | Automatically runs graph consolidation and archives deprecated memories | false |
Diagnostic Checks
- Directory Structure: Verifies presence of
.memofs/and sub-memory paths. - Required Files: Verifies all 11 canonical seed files exist.
- Manifest Schema: Validates
manifest.json. - Core Memory Soft Limit: Emits warning if
memory/core.mdexceeds 200 lines, keeping always-loaded prompt context compact. - JSONL Integrity: Audits record schemas for events, conversations, chunks, and snapshots.
- Referential Integrity: Checks that events referencing conversation/document IDs resolve to valid entries.
- Deprecated Memories: Warns if deprecated graph nodes exist; with
--fix, runsmemo.consolidate({ apply: true })andmemo.archiveDeprecated().
memofs validate
Runs strict protocol and schema validation for CI/CD pipelines. Exits with code 0 on success or code 1 if any file or line fails validation.
memofs validate
memofs validate --jsonmemofs status
Displays compliance observability for the most recent agent session, checking if the agent followed memory protocol rules.
memofs status
memofs status --hookOptions
| Flag | Description | Default |
|---|---|---|
--hook | Emits Stop-hook JSON for Claude Code and Codex hooks | false |
Evaluated Compliance Rules
- Context loaded at session start: Checks for a
memory.indexedevent withmetadata: { hook: "session-start" }. - Memory consulted during session: Checks for non-sync memory read/recall events after session start.
- Facts persisted: Checks for
memory.createdevents after session start.
memofs migrate anchors
Backfills AnchorRef code-location metadata onto existing structured notes in memory/notes.md by detecting file-path and TypeScript symbol references in note text.
memofs migrate anchors
memofs migrate anchors --jsonBehavior
- Scans notes for file-path references matching existing workspace files.
- Computes SHA-256 content hashes of the referenced files.
- Attaches structured
anchorfrontmatter metadata to the note block. - Idempotent: Skips notes that already carry an anchor.
memofs consolidate
Executes the knowledge graph consolidation pass, merging duplicate entities and retiring superseded facts.
memofs consolidate
memofs consolidate --archive-deprecatedOptions
| Flag | Description | Default |
|---|---|---|
--archive-deprecated | Physically moves deprecated note blocks to .memofs/archive/<id>.json cold storage files and transitions graph nodes to archived | false |
memofs restore
Restores an archived memory from .memofs/archive/<id>.json back into active memory.
memofs restore 2026-08-10T11:21:09.163ZBehavior
- Reads and validates
.memofs/archive/<id>.jsonagainstArchivedMemoryRecordSchema. - Writes the note block back into
memory/notes.md. - Re-indexes the memory content into the local lexical index.
- Transitions bound graph nodes from
archivedtoactivestatus (clearsvalidUntil). - Deletes
.memofs/archive/<id>.jsonand logs amemory.restoredevent.