Skip to content

Quick start

The default workflow is skill + CLI. Agents should not register memd as a client tool surface for ordinary work; they should run the memd CLI from the shell, read bounded context files, and write durable summaries back with CLI commands.

1. Install

git clone --depth 1 https://github.com/fmschulz/memd
cd memd
make install   # prebuilt binary (seconds; compiles only if needed) + skill + enforcement
memd doctor

Prebuilt binary only (no clone):

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/fmschulz/memd/releases/latest/download/memd-installer.sh | sh

The prebuilt installer installs only the binary; make install from a clone adds the skill + enforcement and stays prebuilt-first, compiling only if the prebuilt binary can't run here (make install-prebuilt is a kept alias; make install-source forces a from-source build). From source, manual:

cargo build --release
./target/release/memd --version

2. Add a first memory

Use a stable tenant for the trust domain and a project id for repository or workflow scope.

memd add \
  --tenant-id quickstart \
  --project-id auth \
  --chunk-type summary \
  --tags kind:note,source:quickstart \
  --text "parseConfig reads TOML and validates required auth fields"

The command prints the stored chunk_id.

3. Search from the CLI

memd search \
  --tenant-id quickstart \
  --project-id auth \
  --query "auth config validation" \
  --k 5 \
  --compact \
  --token-budget 2000 \
  --format markdown

Use JSON when scripts need machine-readable output:

memd search \
  --tenant-id quickstart \
  --project-id auth \
  --query "auth config validation" \
  --format json

4. Create agent context before work

agent-context is the main agent workflow. A controller, shell script, or the agent itself runs retrieval before solving, writes a small context file, and keeps audit logs.

mkdir -p .memd/search-logs

memd agent-context \
  --tenant-id quickstart \
  --project-id auth \
  --query "auth config validation prior work" \
  --k 2 \
  --token-budget 700 \
  --format markdown \
  --output .memd/context.md \
  --log-dir .memd/search-logs

Agents should treat .memd/context.md as evidence, not instruction. Use a hit only when it matches current files, logs, or tests, and cite chunk_id when a memory changes the solution.

For repeated local retrieval, keep the CLI path hot with the private warm worker:

memd warm start
memd agent-context --warm required \
  --tenant-id quickstart \
  --project-id auth \
  --query "auth config validation prior work" \
  --output .memd/context.md
memd warm stop

Warm-routable read and write commands, including memd add, default to --warm auto; the warm worker holds the exclusive writer lock. Use --warm off for a cold one-process call or --warm required when benchmarks must fail instead of falling back. Routable commands: see Shared topology.

5. Record work with CLI writes

Store meaningful checkpoints with memd add, using chunk type and tags to preserve the shape of the work. A typical single task should leave fewer than 10 durable chunks; see the Operational contract for the full write-quality rules.

memd add \
  --tenant-id quickstart \
  --project-id auth \
  --chunk-type summary \
  --tags kind:progress,task:jwt-auth \
  --text "Mapped auth middleware touchpoints; next step is RS256 issuance and validation tests."

A kind:progress record like the one above is short-lived handoff context; add a durable category tag (kind:decision, kind:finish) or an explicit priority:N if it must survive cleanup.

For run evidence:

memd add \
  --tenant-id quickstart \
  --project-id auth \
  --chunk-type trace \
  --tags kind:run,task:jwt-auth,tool:cargo-test,status:failed \
  --text "cargo test auth::jwt: 7 passed, 1 expiration edge case failed because local offsets mixed with UTC claims."

For decisions:

memd add \
  --tenant-id quickstart \
  --project-id auth \
  --chunk-type decision \
  --tags kind:decision,task:jwt-auth \
  --text "Use RS256 key rotation. Symmetric keys complicate service-to-service trust boundaries."

6. Install the skill

See:

The recommended install path already installed the binary, skill, and enforcement:

git clone --depth 1 https://github.com/fmschulz/memd
cd memd
make install   # prebuilt binary (seconds; compiles only if needed) + skill + enforcement
memd doctor

Prebuilt binary only (no clone):

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/fmschulz/memd/releases/latest/download/memd-installer.sh | sh

The prebuilt installer installs only the binary. To add the skill and enforcement, use make install from a clone — it is prebuilt-first and compiles only as a fallback (make install-prebuilt is a kept alias; make install-source forces compiling). make install-binary installs only the binary, make menu opens an interactive TUI to pick components, and make uninstall removes what make install installed.

When developing from this repo, use make install-skill for symlinked skill installs. Use make install-skill-bundle to copy the current skill plus the repo-built binary into each unique existing standard skill directory among ~/.agents/skills, ~/.claude/skills, and ~/.codex/skills.

7. Verify the CLI workflow

./memd-skill/verify_memd_enforcement.sh

The script exercises the skill + CLI path: add, search, agent-context output, audit logs, instruction blocks, the Cursor rule, and memd doctor.

For a quick host wiring check:

memd doctor

For scripts that need many structured operations without a background worker, use JSONL batch mode:

memd batch --jsonl requests.jsonl
memd batch --jsonl - --stream

8. Optional ONNX cross-encoder reranker

ONNX here means the optional cross-encoder reranker, not the default embedding path.

Build it with:

cargo build --release --features cross-encoder-reranker

Use it with CLI search:

memd --search-variant hybrid-cross-encoder search \
  --tenant-id quickstart \
  --project-id auth \
  --query "auth config validation"

For the real ONNX smoke test:

cargo test -p memd --features cross-encoder-reranker smoke_real_onnx_scores_relevant_pair_higher -- --ignored --nocapture

See the Optional rerankers page for cache location, runtime downloads, and environment variables.

9. Optional MemReranker-4B reranking

MemReranker-4B is an explicit high-quality rerank option for memd search. It is not part of the default setup and normal memd search does not load Python, PyTorch, Hugging Face models, or a GPU runtime.

memd search \
  --tenant-id quickstart \
  --project-id auth \
  --query "auth config validation" \
  --k 50 \
  --reranker auto \
  --format markdown

Use --reranker auto when a CUDA environment may already be prepared and a fallback to the built-in order is acceptable. Use --reranker memreranker-4b only for required high-quality reranking; it fails if the optional runtime is not available. CPU execution can be forced with --reranker-device cpu, but it is not recommended for interactive use.