# memtwig — Complete Technical Reference (v1.3.2) memtwig is an open-source (Apache 2.0), git-native, multi-org Markdown memory layer for AI coding agents and assistants, distributed as a single static Go binary (`CGO_ENABLED=0`, ~14 MB, Linux/macOS/Windows) with an embedded local Studio Web UI (`memtwig ui`) and interactive TUI (`memtwig tui`). ## Install ```bash curl -fsSL https://memtwig.com/install.sh | sh # Ensure ~/.local/bin is in PATH: export PATH="$HOME/.local/bin:$PATH" memtwig version # memtwig 1.3.2 ``` Or with Go: ```bash go install github.com/vittoriocompagno/memtwig/cmd/memtwig@latest ``` ## Quickstart (One-Command Setup) ```bash # Fastest start (creates or imports ~/notes, indexes it, detects installed AI harnesses): memtwig setup # add --install to connect detected harnesses automatically # Or set up explicit multi-org vaults in one command each: memtwig init ~/notes/personal --name personal --kind personal \ --always-include "persona/**" memtwig init ~/notes/acme --name acme --kind org \ --match-path "$HOME/work/acme-payments/**" \ --match-remote "github.com/acme-corp/*" memtwig init ~/notes/nordic --name nordic --kind org \ --match-path "$HOME/work/nordic-store/**" \ --match-remote "github.com/nordic-retail/*" # 3. Inspect vaults, index, and diagnose memtwig vault list memtwig index --full memtwig doctor # 4. Search (strictly scoped by cwd + git remote; supports prefix matching, e.g. "Postgres" -> "PostgreSQL") cd ~/work/acme-payments && memtwig search "Postgres" cd ~/work/acme-payments && memtwig search "Shopify" # -> no matches (active vaults: acme, personal) # 5. Governance & deterministic proposals memtwig proposal add infra/postgres.md --vault acme --kind append \ --reason "Add pg_stat_statements alert" \ --content "- [2026-11-23 · dev] Alert if p95 > 250ms." memtwig proposal list --vault acme memtwig proposal show --vault acme memtwig proposal ok --vault acme memtwig proposal no "outdated" --vault acme # 6. Lint all vaults, curate, open local Studio Web UI or TUI memtwig check --all memtwig curate # add --llm for semantic contradiction check memtwig ui # embedded local Web UI at http://127.0.0.1:8787 memtwig tui # interactive terminal UI # 7. Connect AI harnesses memtwig install claude --dry-run memtwig install cursor --dry-run memtwig install codex --dry-run memtwig mcp # stdio MCP server memtwig serve --addr 127.0.0.1:8787 # Streamable HTTP MCP + REST API + RBAC + Studio UI ``` ## Complete `config.toml` Schema (`~/.config/memtwig/config.toml`) ```toml version = 1 [identity] soul_file = "~/.config/memtwig/SOUL.md" # optional identity file injected by `hook --event session-start` inject_on_session_start = true [retrieval] default_top_k = 5 max_snippet_chars = 400 rrf_k = 60 [embeddings] # provider: "none" | "ollama" | "openrouter" | "deepinfra" | "openai" | "cloudflare" provider = "none" model = "bge-m3" # e.g. "baai/bge-m3" (openrouter), "BAAI/bge-m3" (deepinfra), "bge-m3" (ollama) endpoint = "http://127.0.0.1:11434/api/embeddings" api_key_env = "" # e.g. "OPENROUTER_API_KEY", "DEEPINFRA_API_KEY", "OPENAI_API_KEY" account_id = "" # Cloudflare Workers AI account ID dimensions = 1024 # default 1024; changing model/dimensions auto-invalidates SQLite index_meta timeout_ms = 3000 cosine_threshold = 0.45 [llm] # Used by `memtwig curate --llm` for semantic contradiction checks # provider: "none" | "openai" | "ollama" | "openrouter" | "groq" provider = "none" model = "" # e.g. "llama-3.3-70b-versatile" (groq), "openai/gpt-4o-mini" (openrouter) endpoint = "" api_key_env = "" # e.g. "GROQ_API_KEY", "OPENROUTER_API_KEY", "OPENAI_API_KEY" timeout_ms = 15000 [vaults.personal] path = "~/notes/personal" kind = "personal" # "personal" | "org" default_write = "direct" # "direct" | "propose" | "readonly" always_include = ["persona/**"] # globs inside personal vault always visible in org scopes max_note_bytes = 8192 [vaults.acme] path = "~/notes/acme" kind = "org" default_write = "propose" match_paths = ["~/work/acme-payments/**"] match_git_remotes = ["github.com/acme-corp/*"] max_note_bytes = 8192 [server] addr = "127.0.0.1:8787" audit_log_path = "~/.cache/memtwig/audit.jsonl" # Optional RBAC tokens for team HTTP mode (if omitted, local-only admin mode is active): # [[server.tokens]] # name = "acme-ci" # token_env = "MEMTWIG_ACME_TOKEN" # role = "proposer" # "reader" | "proposer" | "writer" | "admin" # vaults = ["acme"] # path_globs = ["infra/**"] ``` ## Note Format & Governance Notes use YAML frontmatter or lightweight top-of-file headers: ```markdown --- status: active valid_from: 2026-11-23 updated: 2026-11-23 owner: vittorio --- # Style Preferences - Keep replies concise. ``` - **Soft cap**: 8 KB per live note (`max_note_bytes`). Outdated facts are moved to append-only `/archive/` files (e.g. `infra/archive/postgres.md`) via `memtwig invalidate --match "..." --reason "..."`. - **Owner lock**: Notes with `owner:` (or `proprietario:`) block direct agent writes even inside `direct` vaults; edits are routed to `.curator/proposals.json`. - **Decisions**: `memtwig decide "..." --note ` logs to `decisions/YYYY-MM.md`; in `org` vaults (`default_write = "propose"`) or owner-locked notes, the update to `--note` is queued as a review proposal. - **Deterministic proposals**: SHA1 IDs + append-only `.curator/history.jsonl` ensure rejected proposals never reopen. - **Secret scanner**: `memtwig check --all` detects leaked API keys/tokens/private keys and blocks `memtwig sync`. ## MCP & HTTP API Reference - **Stdio MCP (`memtwig mcp`)**: exposes `memory_search`, `memory_get`, `memory_status`, `memory_propose`, `memory_write`, `memory_proposals_list`. - **HTTP Server (`memtwig serve` / `memtwig ui`)**: - `GET /health` - `POST /mcp` (Streamable HTTP MCP with Bearer RBAC) - `GET /api/v1/status`, `GET /api/v1/notes`, `GET /api/v1/note?vault=...&path=...`, `GET /api/v1/search?q=...` - `GET /api/v1/proposals` (includes unified `diff`), `POST /api/v1/proposals`, `POST /api/v1/proposals///` - `POST /api/v1/reindex`, `POST /api/v1/curate`, `GET /api/v1/audit?n=50` - `GET /` serves the embedded local Studio Web UI. ## Links - Website: https://memtwig.com - GitHub: https://github.com/vittoriocompagno/memtwig - Releases: https://github.com/vittoriocompagno/memtwig/releases - Comparisons: https://memtwig.com/vs/mem0 · https://memtwig.com/vs/claude-md · https://memtwig.com/mcp-memory