项目 / thedotmack/claude-mem
给 AI 助手配的长期记忆库,自动压缩并复用每次对话积累的知识。
本站整理,非 GitHub 官方 description。
官方快照(gh_history.db,2026-11-25):总榜 #45 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。
以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。
安装或使用说明见 https://docs.claude-mem.ai/telemetry。
项目说明文档见 https://docs.claude-mem.ai/architecture/overview。
claude-mem 运行需要 Node.js 20.19+/22.12+、支持插件的 Claude Code 等受支持的代理、Bun 与 uv(缺失时自动安装),并使用内置的 SQLite 3 做持久存储。
来自 GitHub 仓库 README / 主页介绍正文,正文较长,已截断:保留前 20000 字符(原始 25,713 字节),完整内容见 GitHub 仓库。
<h1 align="center">
<br>
<a href="https://github.com/thedotmack/claude-mem">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/public/claude-mem-logo-for-dark-mode.webp">
<source media="(prefers-color-scheme: light)" srcset="docs/public/claude-mem-logo-for-light-mode.webp">
<img src="docs/public/claude-mem-logo-for-light-mode.webp" alt="Claude-Mem" width="400">
</picture>
</a>
</h1>
<p align="center">
<img alt="Vercel OSS Program" src="https://vercel.com/oss/program-badge-2026.svg" height="24" />
<img alt="Greptile" src="docs/public/greptile-wordmark-green.svg" height="24" />
<img alt="SerpApi" src="docs/public/serpapi-logo-with-wordmark-gradient.svg" height="24" />
</p>
<p align="center">
<a href="docs/i18n/README.zh.md">🇨🇳 中文</a> •
<a href="docs/i18n/README.zh-tw.md">🇹🇼 繁體中文</a> •
<a href="docs/i18n/README.ja.md">🇯🇵 日本語</a> •
<a href="docs/i18n/README.pt.md">🇵🇹 Português</a> •
<a href="docs/i18n/README.pt-br.md">🇧🇷 Português</a> •
<a href="docs/i18n/README.ko.md">🇰🇷 한국어</a> •
<a href="docs/i18n/README.es.md">🇪🇸 Español</a> •
<a href="docs/i18n/README.de.md">🇩🇪 Deutsch</a> •
<a href="docs/i18n/README.fr.md">🇫🇷 Français</a> •
<a href="docs/i18n/README.he.md">🇮🇱 עברית</a> •
<a href="docs/i18n/README.ar.md">🇸🇦 العربية</a> •
<a href="docs/i18n/README.ru.md">🇷🇺 Русский</a> •
<a href="docs/i18n/README.pl.md">🇵🇱 Polski</a> •
<a href="docs/i18n/README.cs.md">🇨🇿 Čeština</a> •
<a href="docs/i18n/README.nl.md">🇳🇱 Nederlands</a> •
<a href="docs/i18n/README.tr.md">🇹🇷 Türkçe</a> •
<a href="docs/i18n/README.uk.md">🇺🇦 Українська</a> •
<a href="docs/i18n/README.vi.md">🇻🇳 Tiếng Việt</a> •
<a href="docs/i18n/README.tl.md">🇵🇭 Tagalog</a> •
<a href="docs/i18n/README.id.md">🇮🇩 Indonesia</a> •
<a href="docs/i18n/README.th.md">🇹🇭 ไทย</a> •
<a href="docs/i18n/README.hi.md">🇮🇳 हिन्दी</a> •
<a href="docs/i18n/README.bn.md">🇧🇩 বাংলা</a> •
<a href="docs/i18n/README.ur.md">🇵🇰 اردو</a> •
<a href="docs/i18n/README.ro.md">🇷🇴 Română</a> •
<a href="docs/i18n/README.sv.md">🇸🇪 Svenska</a> •
<a href="docs/i18n/README.it.md">🇮🇹 Italiano</a> •
<a href="docs/i18n/README.el.md">🇬🇷 Ελληνικά</a> •
<a href="docs/i18n/README.hu.md">🇭🇺 Magyar</a> •
<a href="docs/i18n/README.fi.md">🇫🇮 Suomi</a> •
<a href="docs/i18n/README.da.md">🇩🇰 Dansk</a> •
<a href="docs/i18n/README.no.md">🇳🇴 Norsk</a>
</p>
<h4 align="center">Your coding agent forgets everything between sessions. Claude-Mem remembers for it.</h4>
<p align="center">
<a href="LICENSE">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
</a>
<a href="package.json">
<img src="https://img.shields.io/badge/version-16.1.3-green.svg" alt="Version">
</a>
<a href="package.json">
<img src="https://img.shields.io/badge/node-%5E20.19%20%7C%7C%20%3E%3D22.12-brightgreen.svg" alt="Node">
</a>
<a href="https://github.com/thedotmack/awesome-claude-code">
<img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Claude Code">
</a>
</p>
<p align="center">
<a href="https://www.star-history.com/thedotmack/claude-mem">
<picture><source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/badge?repo=thedotmack/claude-mem&type=rank&theme=dark" /><source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/badge?repo=thedotmack/claude-mem&type=rank" /><img alt="Star History Rank" src="https://api.star-history.com/badge?repo=thedotmack/claude-mem&type=rank" /></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/badge?repo=thedotmack/claude-mem&type=trending&theme=dark" /><source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/badge?repo=thedotmack/claude-mem&type=trending" /><img alt="GitHub Trending Repository of the Day" src="https://api.star-history.com/badge?repo=thedotmack/claude-mem&type=trending" /></picture>
</a>
</p>
<br>
<table align="center">
<tr>
<td align="center">
<a href="https://github.com/thedotmack/claude-mem">
<picture>
<img
src="https://raw.githubusercontent.com/thedotmack/claude-mem/main/docs/public/cm-preview.gif"
alt="Claude-Mem Preview"
width="500"
>
</picture>
</a>
</td>
<td align="center">
<a href="https://www.star-history.com/#thedotmack/claude-mem&Date">
<picture>
<source
media="(prefers-color-scheme: dark)"
srcset="https://api.star-history.com/image?repos=thedotmack/claude-mem&type=date&theme=dark&legend=top-left"
/>
<source
media="(prefers-color-scheme: light)"
srcset="https://api.star-history.com/image?repos=thedotmack/claude-mem&type=date&legend=top-left"
/>
<img
alt="Star History Chart"
src="https://api.star-history.com/image?repos=thedotmack/claude-mem&type=date&legend=top-left"
width="500"
/>
</picture>
</a>
</td>
</tr>
</table>
<p align="center">
<a href="#quick-start">Quick Start</a> •
<a href="#how-it-works">How It Works</a> •
<a href="#mcp-search-tools">Search Tools</a> •
<a href="#documentation">Documentation</a> •
<a href="#configuration">Configuration</a> •
<a href="#troubleshooting">Troubleshooting</a> •
<a href="#license">License</a>
</p>
<p align="center">
Every new session, your agent starts from zero. It re-reads the same files, re-asks the same questions, and walks back into mistakes you already fixed together.
</p>
<p align="center">
Claude-Mem runs a second agent beside it that takes notes while it works. The next session starts with a short index of what matters, and pulls in the details only when it needs them. Works with Claude Code, Codex, Cursor, OpenCode and 11 more agents. Copilot CLI, Goose, Roo Code, Warp and Zed can search your memory, but their sessions aren't recorded.
</p>
---
## Quick Start
**Installing for someone as an AI agent?** If the user is available, run `npx claude-mem install --setup browser` on their computer and keep it running. In an interactive terminal, they can enter a work email and an optional message, or press Enter to skip. An unattended terminal skips both prompts. The installer prepares the local runtime, then opens the browser for the user to choose agents, integrations, skills, model, and usage analytics. If the page doesn't open, give them the printed URL. If the user is away, run `npx claude-mem install --setup defer` to prepare the runtime and leave setup waiting for their first visit. Their next session shows them the link. Don't make their choices for them.
```bash
npx claude-mem install
```
The installer finds the agents on your machine and asks which ones to set up. Then just start working: observations stream in from your first prompt, and your second session in a project opens with memory from the first. (Copilot CLI, Goose, Roo Code, Warp and Zed get memory search only, so their sessions don't add to it.)
The installer sets everything up first, then asks you to sign in to claude-mem in your browser (email magic link, no card required to sign in). Choosing the **claude-mem observer** then starts its **30 Day Free Trial** on a checkout page that asks for a payment method; once it completes, the installer saves your memory key. With the observer, memory runs off-plan, so you get up to 100% more usage from your plan. When the free trial ends, memory automatically falls back to your Anthropic plan unless you subscribe. After sign-in you pick your memory provider: the claude-mem observer, your own OpenRouter or Gemini key, or your Anthropic plan.
Prefer to skip the sign-in? Pass an explicit `--provider` flag, set `CLAUDE_MEM_ONLINE_OPTIN=false`, or run in CI/non-interactive shells — the installer completes without any account interaction.
Your memory lives in `~/.claude-mem` on your machine. Cloud sync is opt-in. Anonymous usage analytics are on by default; `npx claude-mem telemetry disable` turns them off ([what's collected](https://docs.claude-mem.ai/telemetry)).
Or install from the plugin marketplace inside Claude Code:
```bash
/plugin marketplace add thedotmack/claude-mem
/plugin install claude-mem
```
Restart Claude Code. Context from previous sessions will automatically appear in new sessions.
> **Note:** Claude-Mem is also published on npm, but `npm install -g claude-mem` installs the **SDK/library only** — it does not register the plugin hooks or set up the worker service. Always install via `npx claude-mem install` or the `/plugin` commands above.
### Other agents
`npx claude-mem install` covers every supported agent. To set up one agent directly, pass `--ide`.
**OpenCode** (1.3.4 or later, including OpenCode 2). Restart OpenCode after installing.
```bash
npx claude-mem install --ide opencode
```
**T3 Code** (Codex and Claude Code providers). The installer discovers T3 Code's enabled providers, registers native Claude-Mem plugins in their configured homes, and supports T3-managed Codex. Restart T3 Code, trust the provider's hooks when prompted, and start a new thread. See the [T3 Code integration guide](https://docs.claude-mem.ai/t3code-integration) for custom server settings, status, and removal.
```bash
npx claude-mem install --ide t3code
```
**Antigravity CLI** ([setup guide](https://docs.claude-mem.ai/antigravity-cli/setup)):
```bash
npx claude-mem install --ide antigravity
```
**OMP (Oh My Pi):**
```bash
npx claude-mem install --ide omp
```
**Pi and DeepSeek Harness** use the worker runtime. See [native harness setup](docs/native-harness-integrations.md) for capture, recall, and troubleshooting.
```bash
npx claude-mem install --ide pi
npx claude-mem install --ide dsh --dsh-profile tui
```
**Grok Bot:** see [Grok Bot](#grok-bot) below.
```bash
npx claude-mem install --ide grok-bot
```
The full list of `--ide` values is in `npx claude-mem --help`.
#### Grok Bot
Grok Bot has no host hooks, so we watch the chat log files. Default is CMEM Pro, the hosted memory. Local observer is opt-in: `--provider host`. Installing this plugin does not install Cursor.
**Opt-in awareness push:** needle observations (`decision`, `bugfix`, `security_alert`, `sensitive`) are appended as dated `- YYYY-MM-DD [awareness] …` lines into that bot's `memory/log/YYYY-MM.md`. Grok Bot already re-reads the log from disk. This does not write `profile.md`, user-memory, or project memory. Enable with `CLAUDE_MEM_GROK_BOT_AWARENESS_ENABLED=true` and set `CLAUDE_MEM_GROK_BOT_AWARENESS_AGENT_IDS` to your agent UUIDs (empty by default).
#### 🦞 OpenClaw Gateway
Install claude-mem as a persistent memory plugin on [OpenClaw](https://openclaw.ai) gateways with a single command:
```bash
curl -fsSL https://install.cmem.ai/openclaw.sh | bash
```
The installer handles dependencies, plugin setup, AI provider configuration, worker startup, and optional real-time observation feeds to Telegram, Discord, Slack, and more. See the [OpenClaw Integration Guide](https://docs.claude-mem.ai/openclaw-integration) for details.
## What You Get
- 🧠 **The next session starts where the last one left off.** Each session opens with a compact index of past observations, layered so the agent opens full details only when it needs them, and the header can show what each layer costs in tokens.
- 🔍 **Find anything you worked on.** The mem-search skill searches your project history in three steps (index, timeline, details), so the agent spends tokens only on what it opens.
- 🖥️ **Watch it work, and keep track of yours.** My Work shows live requests, progress, human handoffs and a saved review queue at the worker URL printed on startup. [Guide](https://docs.claude-mem.ai/usage/my-work). Memory, sessions and settings remain at `/viewer`.
- 👥 **Share with your team, if you want.** TeamBrain is an optional shared workspace beside My Work, with real team work lists, member attribution and linked findings. Each person chooses what to share; personal requests and review notes stay separate. [Set up a team](https://cmem.ai/teambrain/start).
- 💻 **Search from Claude Desktop.** Search your memory from Claude Desktop conversations.
- 🔒 **Keep secrets out.** Wrap anything in `<private>` tags and it never gets stored.
- 🖼️ **Screenshots, kept by default.** Keep converted copies of tool screenshots under `~/.claude-mem/media-v1/` and show them in My Work, upload them to cmem.ai only when Cloud Sync is on, and send them to the observer model only when image inference is separately enabled. Turn it off with the "Keep images" switch in Settings ([details](https://docs.claude-mem.ai/configuration#screenshots-and-images)).
- ⚙️ **Choose what gets injected.** Fine-grained settings for what context a new session starts with.
- 🤖 **Nothing to remember to do.** It runs on its own once installed.
- 🔗 **Point back to past work.** Every observation has an ID you can cite through the worker API or open in the web viewer.
---
## Documentation
📚 **[View Full Documentation](https://docs.claude-mem.ai/)** - Browse on official website
### Getting Started
- **[Installation Guide](https://docs.claude-mem.ai/installation)** - Quick start & advanced installation
- **[Usage Guide](https://docs.claude-mem.ai/usage/getting-started)** - How Claude-Mem works automatically
- **[Search Tools](https://docs.claude-mem.ai/usage/search-tools)** - Query your project history with natural language
- **[Cloud Sync](https://docs.claude-mem.ai/cloud-sync)** - Back up your memory to cmem.ai — no daemon, the worker syncs on write
### Best Practices
- **[Context Engineering](https://docs.claude-mem.ai/context-engineering)** - AI agent context optimization principles
- **[Progressive Disclosure](https://docs.claude-mem.ai/progressive-disclosure)** - Philosophy behind Claude-Mem's context priming strategy
### Architecture
- **[Overview](https://docs.claude-mem.ai/architecture/overview)** - System components & data flow
- **[Architecture Evolution](https://docs.claude-mem.ai/architecture-evolution)** - The journey from v3 to v5
- **[Hooks Architecture](https://docs.claude-mem.ai/hooks-architecture)** - How Claude-Mem uses lifecycle hooks
- **[Hooks Reference](https://docs.claude-mem.ai/architecture/hooks)** - Every hook entry explained
- **[Worker Service](https://docs.claude-mem.ai/architecture/worker-service)** - HTTP API & Bun management
- **[Database](https://docs.claude-mem.ai/architecture/database)** - SQLite schema & FTS5 search
- **[Search Architecture](https://docs.claude-mem.ai/architecture/search-architecture)** - Hybrid search with Chroma vector database
### Configuration & Development
- **[Configuration](https://docs.claude-mem.ai/configuration)** - Environment variables & settings
- **[Development](https://docs.claude-mem.ai/development)** - Building, testing, contributing
- **[Troubleshooting](https://docs.claude-mem.ai/troubleshooting)** - Common issues & solutions
---
## How It Works
1. **Your agent works.** Hooks in your agent hand each tool call (what it reads, edits and runs) to a small local worker.
2. **The observer takes notes.** A second agent turns that activity into short observations, and writes a summary when the session ends.
3. **The next session starts with them.** When a session starts, your agent gets a compact index of the observations that matter for this project, and fetches full details only when it needs them.
Memory injection starts on your second session in a project. To front-load a whole repo instead, run `/learn-codebase` (~5 minutes on a typical repo, optional).
See [Architecture Overview](https://docs.claude-mem.ai/architecture/overview) for details.
### How it fits together
For contributors, the main parts and where they live:
- **The `claude-mem` command** (`src/npx-cli/index.ts`): install, repair, doctor, start, search and the rest. The installer puts a small launcher on PATH so hooks can run `claude-mem` directly.
- **Hooks** (`src/cli/hook-command.ts`, one adapter per agent in `src/cli/adapters/`): each agent event runs one shell-free command, such as `claude-mem hook claude-code <event>`. For Claude Code that's Setup (`claude --init` / `--maintenance`), SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, Stop, SubagentStop and SessionEnd.
- **The worker** (`src/services/worker-service.ts`, routes in `src/services/worker/http/routes/`): a local HTTP service managed by Bun. It takes tool activity from the hooks, runs the observer, and serves the viewer and search.
- **The observer** (prompts in `src/sdk/`, one provider per model source in `src/services/worker/`, such as `ClaudeProvider.ts` and `OpenRouterProvider.ts`): turns tool activity into observations and summaries.
- **Storage** (`src/services/sqlite/`): SQLite at `~/.claude-mem/claude-mem.db` holds sessions, observations and summaries. Chroma adds semantic search on top of SQLite's keyword search (`src/services/worker/search/`).
- **Context** (`src/services/context/`): builds the block a new session starts with.
- **Search** (`src/servers/mcp-server.ts`, `plugin/skills/mem-search/`): the MCP tools and the mem-search skill that drives them.
- **The viewer** (`src/ui/viewer/` at `/viewer`, `src/ui/my-work/` at `/`): memory, sessions and settings, plus My Work.
- **The built plugin** (`plugin/`): written by `npm run build`; edit `src/`, not the generated scripts.
The words we use for each of these, and the story they tell, are in [docs/story.md](docs/story.md).
---
## MCP Search Tools
Search runs through three MCP tools in a token-efficient three-step workflow. The mem-search skill drives it for you:
**The three steps:**
1. **`search`** - Get compact index with IDs (~50-100 tokens/result)
2. **`timeline`** - Get chronological context around interesting results
3. **`get_observations`** - Fetch full details ONLY for filtered IDs (~500-1,000 tokens/result)
**Step by step:**
- Your agent uses MCP tools to search your memory
- Start with `search` to get an index of results
- Use `timeline` to see what was happening around specific observations
- Use `get_observations` to fetch full details for relevant IDs
- **Index rows are about a tenth the size of a full record**: ~50-100 tokens versus ~500-1,000. Filtering decides how many records you pay to fetch, not how large each one is; the workflow's total cost also includes the timeline and the selected details. The ratio is not a measured recall or end-to-end saving ([#4138](https://github.com/thedotmack/claude-mem/issues/4138)).
**Available MCP Tools:**
1. **`search`** - Search memory index with full-text queries, filters by type/date/project
2. **`timeline`** - Get chronological context around a specific observation or query
3. **`get_observations`** - Fetch full observation details by IDs (always batch multiple IDs)
**Example Usage:**
```typescript
// Step 1: Search for index
search(query="authentication bug", type="bugfix", limit=10)
// Step 2: Review index, identify relevant IDs (e.g., #123, #456)
// Step 3: Fetch full details
get_observations(ids=[123, 456])
```
The worker also offers tools for code navigation (`smart_search`, `smart_outline`, `smart_unfold`), saving a note on purpose (`save_memory`) and tracking work in progress. See [Search Tools Guide](https://docs.claude-mem.ai/usage/search-tools) for detailed examples.
---
## System Requirements
- **Node.js**: 20.19 or later in the 20.x line, or 22.12 or later
- **A supported agent**: Claude Code (latest, with plugin support) or any agent in [Other agents](#other-agents)
- **Bun**: JavaScript runtime and process manager (auto-installed if missing)
- **uv**: Python package manager for vector search (auto-installed if missing)
- **SQLite 3**: For persistent storage (bundled)
---
### Windows Setup Notes