Agent Drive
Officialby CreativLogic
README.md
# Agent Drive
**Persistent memory for Claude Code and Codex that follows you to every device.**
Agent Drive captures what your coding agents do, summarizes every session, and stores the result in a cloud folder you already sync: Google Drive, OneDrive, Dropbox, iCloud Drive or Syncthing. Start a session on your laptop and it already knows what you decided on your desktop yesterday, whether you used Claude or Codex.
It's like [claude-mem](https://github.com/thedotmack/claude-mem), but with these differences:
- **Cross-device by default.** Memory lives in your synced folder, not in a local database.
- **Cross-agent.** Claude Code and Codex share one memory. Any other MCP agent (Gemini CLI, Cursor, Windsurf, Claude Desktop, your own) can join.
- **No server, database or account.** It's plain JSONL files, needs Node 18+ and has zero npm dependencies.
- **Persistent.** Every write is fsynced. It works offline and syncs later. A local mirror keeps memory readable when the drive is unmounted, and nothing is ever deleted.
---
## Quick start (Claude Code + Codex)
1. **Put the repo in your synced folder.**
```bash
# Google Drive on Windows (adjust for your drive letter or sync app)
cd "G:\My Drive"
git clone https://github.com/CreativLogic/Agent-Drive.git
```
On macOS the Google Drive folder is usually `~/Library/CloudStorage/GoogleDrive-<you>/My Drive`.
2. **Install on this device.**
```bash
node Agent-Drive/install.mjs
```
This registers the MCP server and the capture hooks for Claude Code and Codex, plus any other supported agent it finds.
3. **Restart Claude Code and Codex.** That's it.
4. **Each additional device:** wait for the folder to sync, then run step 2 there.
Check the setup any time:
```bash
node Agent-Drive/server/memory.mjs doctor
```
### Keep the code in Git, the memory in the cloud
To keep the clone outside your synced folder, point the memory to it:
```bash
node install.mjs --data "G:\My Drive\Agent-Drive-memory"
```
---
## What happens automatically
| When | Claude Code | Codex | What Agent Drive does |
|---|---|---|---|
| Session starts | `SessionStart` | `SessionStart` | Injects a brief: recent sessions for this project, project memories, global preferences, decisions and lessons |
| You send a prompt | `UserPromptSubmit` | `UserPromptSubmit` | Records it, with secrets redacted |
| A tool runs | `PostToolUse` | `PostToolUse` | Records a one-line observation (file edited, command run, failed or not) |
| A turn ends | `Stop` | `Stop` | Every few minutes of activity, summarizes the session in the background |
| Session ends or compacts | `SessionEnd`, `PreCompact` | – | Final summary |
The summary is written by your own agent CLI running headless (Claude Haiku via `claude -p`, or `codex exec`), so no extra API key is needed. It records what was asked, investigated, learned and completed, plus the next steps. It also pulls out up to 3 durable memories (decisions, preferences, lessons). If no CLI is available, it falls back to a simple rule-based summary that uses no model.
Sessions that end before they get summarized are picked up the next time you start a session on that device.
## Tools your agents get (MCP)
| Tool | Use |
|---|---|
| `memory_search` | Keyword search across everything; returns a compact index |
| `memory_get` | Full text for ids from the index |
| `memory_sessions` | Recent session summaries |
| `memory_timeline` | Replay the prompts and tool calls of one session |
| `memory_save` | Save a decision, preference, lesson or fact |
| `memory_update` | Correct a memory instead of duplicating it |
| `memory_archive` | Hide a wrong memory (restore anytime) |
| `memory_context` | The session-start brief, on demand |
| `memory_stats` | Counts and sync status |
Search uses progressive disclosure, like claude-mem: an index first, full text on request, so it costs few tokens.
## Web viewer
```bash
node server/memory.mjs viewer
```
This opens a local, read-only viewer at `http://127.0.0.1:37778`, or the next free port if that one is taken. You can search, filter by type and project, and expand any session into its timeline.
---
## Other agents
`install.mjs` also detects and configures these agents:
| Agent | What gets installed |
|---|---|
| Gemini CLI | MCP server + `GEMINI.md` instructions |
| Cursor | MCP server |
| Windsurf | MCP server |
| Claude Desktop | MCP server |
Choose explicitly with `--agents claude,codex,gemini`. For any other MCP client:
```bash
node install.mjs --print-config
```
Paste the printed block into that client's MCP settings and set `AGENT_MEMORY_CLIENT` to a short name. If the agent supports lifecycle hooks, point them at `server/memory.mjs hook <Event> --client <name>` (hook JSON on stdin) to get automatic capture too.
---
## How storage works
```
Agent-Drive/data/
desktop__claude.jsonl memories written by Claude on "desktop"
laptop__codex.jsonl memories written by Codex on "laptop"
sessions/2026-11/desktop__claude.jsonl captured observations, one file per month
~/.agent-drive/ per device, never synced
mirror/ last known copy of everything (offline reads)
outbox/ writes made while the folder was unavailable
state.json session bookkeeping
config.json optional { "dataDir": "..." }
```
- **No sync conflicts.** Each device and agent appends only to its own files, and every device reads all of them.
- **Durable writes.** Every append is fsynced, and a half-synced last line is ignored on read and repaired on the next write.
- **Offline safe.** If the folder is missing (drive not mounted, laptop offline), writes go to `outbox/` and flush automatically on the next write once the folder is back. Reads come from `mirror/`.
- **Nothing is deleted.** Updates and archives are new events, so the full history is always there.
- **Backups.** `node server/memory.mjs export` writes everything to one JSONL file.
## Privacy and safety
- Memory stays in your files and your cloud account. Agent Drive has no server and no telemetry.
- Text that looks like an API key, token or private key is refused by `memory_save`. In captured prompts and tool calls it's redacted, along with `password=…` style values.
- The viewer binds to `127.0.0.1` only and is read-only.
- The summarizer runs your agent CLI with tools disabled, and its own run is excluded from capture.
## Configuration
| Variable | Default | Meaning |
|---|---|---|
| `AGENT_MEMORY_DIR` | `<repo>/data` or `config.json` | Synced memory folder |
| `AGENT_DRIVE_HOME` | `~/.agent-drive` | Local mirror, outbox and state |
| `AGENT_MEMORY_DEVICE` | hostname | Device name in file names |
| `AGENT_MEMORY_CLIENT` | set by the installer | Agent name in file names |
| `AGENT_DRIVE_SUMMARIZER` | `auto` | `claude`, `codex`, or `none` (rule-based) |
| `AGENT_DRIVE_SUMMARY_MODEL` | `haiku` | Model for `claude -p` |
| `AGENT_DRIVE_CODEX_MODEL` | Codex default | Model for `codex exec` |
| `AGENT_DRIVE_SUMMARY_MIN` | `3` | New observations needed before a mid-session summary |
| `AGENT_DRIVE_SUMMARY_EVERY_MIN` | `5` | Minimum minutes between mid-session summaries |
| `AGENT_DRIVE_DISABLE` | – | `1` turns capture off for that process |
## Command line
```bash
node server/memory.mjs context --project my-app # the session brief
node server/memory.mjs search "auth flow"
node server/memory.mjs add "We use pnpm, not npm" --type preference
node server/memory.mjs sessions
node server/memory.mjs timeline <session-id>
node server/memory.mjs export backup.jsonl
node server/memory.mjs flush # push queued offline writes now
node server/memory.mjs doctor
```
## Uninstall
```bash
node install.mjs --uninstall
```
This removes Agent Drive from every agent config and leaves your memory files alone. Every config file the installer touched has a `.bak-<date>-agent-drive` copy.
## Development
```bash
node --test
```
The tests cover the MCP protocol, capture and redaction, summaries, offline queueing, mirror reads, multi-device sync and torn-line recovery. Pull requests are welcome.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues