ai-memory README

The project's README from github.com/akitaonrails/ai-memory. As one markdown file: README.md.

ai-memory

Long-term memory for AI coding agents. Quit Claude Code mid-task, start OpenAI Codex in the same directory, continue without re-explaining the architecture, the failed approaches, or the open questions.

Release Rust License

Why ai-memory

Your coding agent already has a memory feature. Claude Code takes its own notes, Cursor remembers some things, and every platform is adding more. All of them share the same walls: the notes live on one machine, belong to one agent, and vanish from view the moment you switch tools — or teammates.

ai-memory is what's on the other side of those walls.

How it works

capture ──▶ consolidate ──▶ recall ──▶ handoff
 hooks        session-end      search     next agent,
 observe      summaries as     + brief    any harness
 silently     wiki pages       injection

Agents emit sanitized observations through lifecycle hooks as you work. At session end, observations become coherent markdown pages in the project's wiki (optionally LLM-written; useful even without). The next session — any agent, any machine — gets a bounded brief and can search everything: full-text, entities, links, and (optionally) vectors, fused into one ranking. Cross-agent handoffs carry the baton explicitly.

The full design, including the invariants that keep multi-user and multi-session use safe, is in docs/ARCHITECTURE.md.

Support matrix

Every row below is a first-party integration — MCP registration, lifecycle hooks, or both — kept honest by CI. The full matrix with per-agent notes and caveats is in docs/support-matrix.md.

Area Status
Linux Supported
macOS Supported
Windows via WSL2 Supported
Native Windows Experimental
Claude Code Supported
Codex Supported
Command Code Supported
Devin CLI Supported
OpenCode Supported
OpenCode 2 (opencode2 beta) Supported
Cursor Supported
Gemini CLI Supported
Oh My Pi / OMP Supported
Pi Supported
Crush Managed-only
Managed workstreams Opt-in
Claude Desktop MCP-only
OpenClaw Supported
Antigravity CLI Supported
Grok Build CLI Supported
Swival CLI MCP-only
Zero Supported
ZCode Supported
Kimi Code Supported
Kiro CLI Supported
Pool Hooks-only
VS Code Copilot MCP-only
Zed MCP-only
Hermes Agent Community
LLM/auth providers Supported
Embedding providers Supported

Quick start

Arch Linux (AUR)

For native Arch installs, use the AUR packages. They install /usr/bin/ai-memory, packaged hook sources, and both system-level and user-level systemd units.

yay -S ai-memory-bin    # prebuilt Linux x86_64/aarch64 binary
yay -S ai-memory        # builds from source

Single-user workstation:

mkdir -p ~/.config/ai-memory ~/.local/share/ai-memory
ai-memory --data-dir ~/.local/share/ai-memory \
  --config ~/.config/ai-memory/config.toml init
systemctl --user enable --now ai-memory.service
ai-memory install-mcp --client claude-code --apply
ai-memory install-hooks --agent claude-code --apply

System service installs use /var/lib/ai-memory and /etc/ai-memory/ via the packaged unit. Full user-service, system-service, auth, and provider setup is in docs/install.md#arch-linux-native-packages-aur.

Docker

You need: Docker or Podman + an agent CLI from the Support Matrix, or anything else that speaks MCP.

The published Docker image includes linux/amd64 and linux/arm64 variants, so Apple Silicon Macs and ARM64 Linux hosts can pull akitaonrails/ai-memory without --platform linux/amd64 emulation.

The default quick-start has no authentication - the server binds to loopback only, so on a single-user laptop nothing else can reach it. Adding a bearer token is a one-line change once you're ready to expose the server on the LAN; see Security below.

# 1. Install the ai-memory CLI wrapper (a small shell script that
#    runs the binary inside a container with your $HOME mounted). This is
#    the only thing that needs to live on the host filesystem.
mkdir -p ~/.local/bin
wrapper_tmp="$(mktemp -d)"
trap 'rm -rf "$wrapper_tmp"' EXIT
wrapper_base=https://github.com/akitaonrails/ai-memory/releases/latest/download/ai-memory-wrapper
curl -fsSL "$wrapper_base" -o "$wrapper_tmp/ai-memory-wrapper"
curl -fsSL "$wrapper_base.sha256" -o "$wrapper_tmp/ai-memory-wrapper.sha256"
expected="$(awk 'NR == 1 { print $1 }' "$wrapper_tmp/ai-memory-wrapper.sha256")"
if command -v sha256sum >/dev/null 2>&1; then
    actual="$(sha256sum "$wrapper_tmp/ai-memory-wrapper" | awk '{ print $1 }')"
else
    actual="$(shasum -a 256 "$wrapper_tmp/ai-memory-wrapper" | awk '{ print $1 }')"
fi
[ -n "$expected" ] && [ "$actual" = "$expected" ] || { echo "wrapper checksum mismatch" >&2; exit 1; }
install -m 0755 "$wrapper_tmp/ai-memory-wrapper" ~/.local/bin/ai-memory
rm -rf "$wrapper_tmp"
trap - EXIT
# Most distros put ~/.local/bin on PATH automatically. If `which
# ai-memory` comes up empty, add this to ~/.bashrc / ~/.zshrc:
#     export PATH="$HOME/.local/bin:$PATH"

# 2. Start the server. `--restart unless-stopped` makes it come back
#    on docker daemon restart and on machine boot (provided your
#    docker service is enabled at boot — `sudo systemctl enable
#    docker` on most distros). Loopback-only bind (`127.0.0.1:49374`)
#    so nothing outside this machine can reach it. Omit the LLM /
#    EMBEDDING lines for zero-LLM mode — FTS5 search still works
#    without any keys.
docker run -d --name ai-memory \
    --restart unless-stopped \
    -p 127.0.0.1:49374:49374 \
    -v ai-memory-data:/data \
    -e AI_MEMORY_LLM_PROVIDER=anthropic \
    -e ANTHROPIC_API_KEY=sk-ant-... \
    -e AI_MEMORY_EMBEDDING_PROVIDER=openai \
    -e OPENAI_API_KEY=sk-... \
    docker.io/akitaonrails/ai-memory:latest

# 3. Wire your agent CLI in two commands. The wrapper takes care of
#    mounts and each client's config-path detection. Re-run with
#    `--agent codex`, `--agent command-code`, `--agent devin`, `--agent opencode`, `--agent opencode2`, `--agent gemini-cli`,
#    `--agent grok`, `--agent kimi-code`, `--agent kiro-cli`, `--agent omp`,
#    `--agent oh-my-pi`, `--client cursor`,
#    `--client gemini-cli`, `--client grok`, `--client kiro-cli`, etc.
#    for additional agents; full list in docs/install.md.
ai-memory install-mcp   --client claude-code --apply
ai-memory install-hooks --agent  claude-code --apply

The examples use docker; replace it with podman on a Podman host. The wrapper automatically uses Podman when Docker is not installed. Set AI_MEMORY_DOCKER=podman to force Podman when both engines are available.

On Linux/macOS, that's it. Start a Claude Code session as usual - every prompt and tool call now lands in ai-memory, and the next session you open in this project will see a handoff with where you left off. On macOS, the native release binary is also supported and recommended when you do not need Docker; see docs/macos.md.

Wiring another agent is the same two commands with a different name — --client codex, --agent codex, and so on for every row of the support matrix. The full per-agent guide, including Windows and remote servers, is docs/install.md.

Two agents in the same project at once, or teammates on one server? That works out of the box: the "current project" pointer is isolated per caller by default (v1.39+). See docs/auto-scope.md for the optional session-aware Claude Code bridge and the details.

Managed workstreams are optional and add cross-harness session continuity on top of shared memory:

ai-memory run claude
ai-memory run codex --yolo   # later: same workstream, different harness
ai-memory continue           # resume the newest managed checkout

ai-memory uninstall --apply removes everything ai-memory installed, and only what it installed. Install commands are idempotent and write timestamped backups next to any file they touch.

Everyday use

Day to day, you mostly do not think about ai-memory. Hooks capture prompts, tool calls, and session boundaries; session end turns them into readable wiki pages; the next session starts with a handoff.

The full tour — search modes, entities, feedback, briefings, the web API — is in docs/usage.md and docs/use-cases.md.

Teams and multiple machines

Run the server somewhere reachable — a homelab box, a LAN host — and point every machine and every teammate at it. Knowledge is shared per project; personal handoffs stay personal; every write is attributed and audited. Multi-user auth (passwords, API credentials) is built in.

Start with docs/users.md for accounts and ownership, and docs/deploy.md for the server itself — including capacity numbers measured rather than guessed, and the one rule that matters: one server per data directory, never two.

Security

The quick-start default is loopback-only with no auth — nothing outside your machine can reach it. From there, hardening is incremental: a bearer token for the LAN, per-user accounts, OIDC device auth for hooks, TLS via a reverse proxy. Capture is sanitized at a typed privacy boundary before anything is stored, and per-repository [capture] rules can exclude paths or invert to allowlist mode.

The full model is in docs/security.md, docs/users.md, and docs/https-via-proxy.md.

LLM providers

Optional. Everything works with zero LLM calls; adding a provider upgrades session summaries and enables semantic search. Anthropic, OpenAI (incl. OAuth/Codex), GitHub Copilot, Gemini, OpenCode (Go and Zen), and any OpenAI-compatible endpoint (Ollama, LM Studio, vLLM) are supported for consolidation; OpenAI, Voyage, Gemini, and keyless OpenAI-compatible endpoints for embeddings. Configuration lives in docs/llm-providers.md.

Architecture

One Rust binary runs an MCP/HTTP server and owns one data directory:

<data_dir>/
├── wiki/    # markdown source of truth, git-versioned
├── raw/     # immutable sanitized managed-workstream transcript segments
├── db/      # SQLite indexes, including FTS5, entities, and embeddings
├── models/  # reserved for local embedding models
└── logs/    # rolling tracing output

Hooks POST observations to the server. The server serializes writes through one SQLite writer, compiles session observations into markdown pages, and serves retrieval through FTS5, entity-match and graph-neighbor RRF, optional vector RRF, bounded source-authority adjustment, and bounded raw-observation fallback for non-global searches.

See docs/ARCHITECTURE.md for the data-flow diagram, crate breakdown, schema notes, and invariants.

Docs

File What it is
docs/install.md Installation cookbook. Every agent CLI, every alternative (curl, source build, no-docker, no-auth), and the server-on-a-different-machine (homelab/LAN) walkthrough. Read after the Quick start if your setup doesn't match the happy path.
docs/usage.md Handoffs, proactive memory queries, slim routing snippet + managed Agent Skills, migration from other memory tools, web UI, raw-wiki inspection, and rules-vs-facts workflow.
docs/managed-workstreams.md Optional ai-memory run continuity across Claude Code, Codex, OpenCode, OpenCode 2 beta, Pi, Crush, Kimi Code, Command Code, Kiro CLI v2/v3, OMP, Grok Build CLI, and Antigravity CLI: automatic harness selection, native resume, argument forwarding, ledger search, privacy, and recovery.
docs/managed-harness-contributions.md Protocol and acceptance bar for contributors adding managed resume, read-only transcript import, and startup context delivery to another harness.
docs/marker-file.md .ai-memory.toml workspace/project routing for multi-client trees, mono-repos, worktrees, and work/personal separation.
docs/auto-scope.md [auto_scope] modes for shared servers: default single-slot routing, session-aware isolation, and multi-user per_actor behavior.
docs/macos.md macOS install paths: native release binary (recommended), source build, the Docker wrapper, hook-platform notes, and current macOS limitations.
docs/windows.md Windows install modes: full WSL2, native Windows with Docker Desktop, prebuilt native release zip, native source builds, and current hook/MCP harness caveats.
docs/mcp-install.md Per-client MCP and lifecycle notes, handoff-injection limits, and community bridge guidance.
docs/deploy.md Homelab deploy: bin/deploy, bearer-token auth, pointers to the TLS guide.
docs/users.md Multi-user attribution and human login. Four-rung bearer ladder, password sessions, ai-memory user / api-key walkthrough, brownfield aim_ migration.
docs/https-via-proxy.md HTTPS via a reverse proxy. When you need TLS (multi-user, non-loopback) and when you don't (loopback / stdio). Copy-paste docker compose templates for Caddy + Let's Encrypt, Caddy + internal CA (LAN-only), Cloudflare Tunnel (no open ports), and external cert files; plus native-Caddy + nginx recipes. The "thinking you're secure when you're not" failure modes explicitly called out.
docs/lifecycle-ops.md Read before running purge / rename / backup / restore / reset / reindex / restore-page. Safety matrix for state-touching commands, per-project disk layout (how isolation actually works), checkpoint-based page recovery, and operator workflows for "fresh start", "snapshot before risky op", "drop one project", and rebuilding SQLite from wiki files.
docs/auto-improvement-loop.md Auto-improvement design notes: Hermes-inspired scheduled review, auto-approval default, manual review opt-in, pending proposal storage, and curator work.
docs/companion-crates.md Boundary and implementation plan for optional companion projects, including the standalone importer at companions/ai-memory-importer, without widening core ai-memory.
docs/llm-provider-comparison.md Empirical notes behind the recommended LLM defaults.
docs/llm-provider-fallback.md Proposed opt-in fallback-chain design for transient LLM-provider failures; not yet a supported configuration surface.
docs/ARCHITECTURE.md Operational summary: data flow, crate layout, cross-cutting invariants, schema.
docs/design-decisions.md The full v1 spec.
Research docs under docs/ Karpathy LLM Wiki notes, Hermes Agent, agentmemory / basic-memory / cognee deep-dives, lessons-learned from upstream issues.

Influences and prior art

ai-memory (akitaonrails/ai-memory)

Searching Database…

11.9K ·GitHub
这是什么?一个面向 AI 编程 agent 的长期记忆服务。你在任务中途退出 Claude Code,在同一目录里启动 Codex 或 Cursor,下一个 agent 就能接上交接:你做到哪了、哪里失败了、还有什么没做完。
它和 Claude Code 或 Cursor 自带的记忆有什么区别?内置的 agent 笔记只存在于一台机器上,而且只属于一个 agent,所以你换工具或和同事协作时它们就没了。ai-memory 是一个共享存储,20 多种工具都会往里写入,跨 agent、跨机器、跨人员通用。
怎么把它跑起来?先运行服务器(Docker/Podman 镜像 akitaonrails/ai-memory,或在 Arch 上安装 AUR 软件包),然后用两条命令把你的 agent 接上(--client codex、--agent codex)。之后钩子会自动记录所有内容。
它能接入哪些编程 agent?二十多个官方集成,全部由 CI 持续验证:Claude Code、Codex、Cursor、Gemini CLI、OpenCode、Devin、Kimi Code、Kiro、Grok Build CLI、OpenClaw,还有仅通过 MCP 接入的客户端,比如 Claude Desktop、Zed 和 VS Code Copilot。
在 Windows 上能用吗?Linux 和 macOS 完全支持,通过 WSL2 也能在 Windows 上用,但原生 Windows 仍处于实验阶段。Docker 镜像同时提供 amd64 和 arm64 两种架构,Apple Silicon 无需模拟。
需要 API key 或 LLM 订阅才能用吗?不需要。默认路径完全不调用 LLM:记录、搜索和交接都不用任何 API key 就能工作。配置一个服务商(Anthropic、OpenAI、Gemini,或 Ollama 这类 OpenAI 兼容服务)可以升级摘要并启用语义搜索。
它会记录我编程会话中的哪些内容?生命周期钩子会记录提示词、工具调用和会话边界,在存储前先经过一个带类型检查的隐私边界做脱敏。每个仓库的 [capture] 规则可以排除指定路径,或反转为白名单模式。
记忆到底存在哪里?存在纯 markdown 文件里:一个用 git 管理的 wiki,由普通的 .md 文件组成,你可以用 grep 搜索、手动编辑,或用 Obsidian 打开。SQLite 数据库只是一个派生索引,随时可以从这些文件重建。
整个团队可以共用一个记忆服务器吗?可以。让所有人都指向同一个服务器:知识按项目共享,个人交接保持私密,而且多用户认证、按人归属和审计日志都是内置的——不是付费功能。
日常使用是什么体验?大多数时候你根本不用管它:钩子默默记录工作,每次会话结束都会生成一份交接。你可以问“我们做到哪了?”、“在记忆里搜一下 Y”或“给我讲讲最近的进展”,再运行一次 ai-memory bootstrap 来索引已有项目的历史。
有网页界面吗?有,是只读的:用 --enable-web 启动服务器就能在浏览器里浏览这个 wiki,另外还有一个位于 /api/v1 的 JSON API。
Size
36 MB
Stars
11.9K
Age
5mo
Commits · 90 Days