Persistent memory for Codex CLI, Claude Code, and MCP clients.
Codex-mem is a Codex-first port of claude-mem by Alex Newman (@thedotmack). The upstream project got the core memory architecture right. This repo carries that work forward for Codex with official Codex integration surfaces, passive
MEMORY.mdrecall, and one-line setup.
NOTICE explains the upstream credit and license continuity.
npx codex-mem-cli@latest codex setupAfter setup, start Codex normally:
codexThat one command:
- installs Bun,
uv, and runtime dependencies if needed - copies the runtime into a stable local install directory
- updates
~/.codex/config.tomlwithnotifyand[mcp_servers.codex_mem] - preserves and chains an existing
notifycommand when it can do so safely - starts the worker and verifies health before exiting
npm note: the registry package is
codex-mem-clibecausecodex-memis already taken on npm. The GitHub project and installed CLI command are bothcodex-mem.
Codex-mem still carries forward the upstream Claude Code integration model. If you want the original Claude plugin workflow, install upstream claude-mem or adapt the plugin assets in this repo to your Claude plugin environment.
Install the OpenClaw integration with:
curl -fsSL https://install.cmem.ai/openclaw.sh | bash- Codex CLI can read MCP memory today, but write capture needs Codex-native ingestion surfaces.
- claude-mem already proved the worker, search, and progressive-recall model.
- Codex-mem adds
notify,codex exec --json, andcodex app-servercapture so the same memory architecture works well in Codex.
- Persistent cross-session memory with SQLite, FTS5, and optional vector search
- Codex-native ingestion via
notify,exec --json, andapp-server - Token-efficient recall through
bootstrap_memory,search,timeline, andget_observations - Root
MEMORY.mdprojections for passive recall in Codex - Web viewer on
http://localhost:37777 - Privacy controls including
<private>stripping before persistence
📚 View Full Documentation - Browse on official website
- Installation Guide - Quick start & advanced installation
- Usage Guide - How Claude-Mem works automatically
- Search Tools - Query your project history with natural language
- Beta Features - Try experimental features like Endless Mode
- Context Engineering - AI agent context optimization principles
- Progressive Disclosure - Philosophy behind Claude-Mem's context priming strategy
- Overview - System components & data flow
- Architecture Evolution - The journey from v3 to v5
- Hooks Architecture - How Claude-Mem uses lifecycle hooks
- Hooks Reference - 7 hook scripts explained
- Worker Service - HTTP API & Bun management
- Database - SQLite schema & FTS5 search
- Search Architecture - Hybrid search with Chroma vector database
- Configuration - Environment variables & settings
- Development - Building, testing, contributing
- Troubleshooting - Common issues & solutions
Core Components:
- 5 Lifecycle Hooks - SessionStart, UserPromptSubmit, PostToolUse, Stop, SessionEnd (6 hook scripts)
- Smart Install - Cached dependency checker (pre-hook script, not a lifecycle hook)
- Worker Service - HTTP API on port 37777 with web viewer UI and 10 search endpoints, managed by Bun
- SQLite Database - Stores sessions, observations, summaries
- mem-search Skill - Natural language queries with progressive disclosure
- Chroma Vector Database - Hybrid semantic + keyword search for intelligent context retrieval
See Architecture Overview for details.
Codex-mem provides intelligent memory search through 4 MCP tools following a token-efficient 4-step workflow pattern:
The Workflow:
bootstrap_memory- Build a compact memory brief for the current project/tasksearch- Get compact index with IDs (~50-100 tokens/result)timeline- Get chronological context around interesting resultsget_observations- Fetch full details ONLY for filtered IDs (~500-1,000 tokens/result)
How It Works:
- Claude and Codex can use MCP tools to search your memory
- Start with
bootstrap_memorywhen resuming work in a new session - Prefer passing
cwdfor repo-aware recall;projectalone is a legacy fallback - Start with
searchto get an index of results - Use
timelineto see what was happening around specific observations - Use
get_observationsto fetch full details for relevant IDs - ~10x token savings by filtering before fetching details
Available MCP Tools:
bootstrap_memory- Compact project memory brief with follow-up observation IDs and repo-aware scoping viacwd/repoRootsearch- Search memory index with full-text queries, filters by type/date/projecttimeline- Get chronological context around a specific observation or queryget_observations- Fetch full observation details by IDs (always batch multiple IDs)
Example Usage:
// Step 1: Build a brief
bootstrap_memory(goal="resume auth refactor", cwd="/path/to/repo")
// Step 2: Search for index
search(query="authentication bug", type="bugfix", limit=10)
// Step 3: Review index, identify relevant IDs (e.g., #123, #456)
// Step 4: Fetch full details
get_observations(ids=[123, 456])See Search Tools Guide for the upstream workflow background.
Quick install for Codex CLI:
npx codex-mem-cli@latest codex setupThat one command:
- copies the bundled runtime to
~/.claude-mem/codex - installs Bun,
uv, and runtime dependencies if needed - updates
~/.codex/config.tomlwithnotifyplus[mcp_servers.codex_mem] - preserves and chains an existing
notifycommand when it is a standard string-array config - starts the worker and verifies health on
http://127.0.0.1:37777
Health check after install:
npx codex-mem-cli@latest codex doctorAfter setup, keep using codex normally. The viewer stays available at http://localhost:37777.
Manual / advanced setup:
The worker now supports three Codex ingestion lanes:
notifyfor stock Codex CLI turn-complete captureexec --jsonfor CI / automation ingestionapp-serverfor higher-fidelity streamed events
Safe MCP setup today (stdio transport):
[mcp_servers.codex_mem]
command = "/ABS/PATH/TO/node"
args = ["/Users/YOU/.claude-mem/codex/scripts/mcp-server.cjs"]
enabled = true
required = falseCodex notify example:
notify = ["/ABS/PATH/TO/node", "/Users/YOU/.claude-mem/codex/scripts/codex-notify.js"]Automation / CI ingest example:
codex exec --json "implement X" | node ~/.claude-mem/codex/scripts/bun-runner.js ~/.claude-mem/codex/scripts/worker-service.cjs codex exec-jsonPassive recall:
- Enable
CLAUDE_MEM_MEMORY_MD_ENABLED=trueto keep a rootMEMORY.mdprojection updated. - Add
"MEMORY.md"to Codexproject_doc_fallback_filenamesif you want Codex to load that projection automatically.
- Node.js: 18.0.0 or higher
- Claude Code: Latest version with plugin support
- 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)
If you see an error like:
npm : The term 'npm' is not recognized as the name of a cmdletMake sure Node.js and npm are installed and added to your PATH. Download the latest Node.js installer from https://nodejs.org and restart your terminal after installation.
Settings are managed in ~/.claude-mem/settings.json (auto-created with defaults on first run). That path is inherited from the upstream claude-mem architecture for compatibility.
See the Configuration Guide for all available settings and examples.
See the Development Guide for build instructions, testing, and contribution workflow.
The npm package name is codex-mem-cli.
For the first npm release of a new package, add an NPM_TOKEN repository secret and run the publish workflow on a v* tag.
After the package exists on npm, you can switch to npm trusted publishing for KeystoneScience/codex-mem and .github/workflows/npm-publish.yml, then remove NPM_TOKEN.
Manual publish still works:
npm adduser
npm publish --access public --provenanceIf experiencing issues, describe the problem to Claude and the troubleshoot skill will automatically diagnose and provide fixes.
See the Troubleshooting Guide for common issues and solutions.
Create comprehensive bug reports with the automated generator:
cd ~/.claude/plugins/marketplaces/thedotmack
npm run bug-reportContributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Update documentation
- Submit a Pull Request
See Development Guide for contribution workflow.
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
Copyright (C) 2025 Alex Newman (@thedotmack). All rights reserved.
See the LICENSE file for full details.
What This Means:
- You can use, modify, and distribute this software freely
- If you modify and deploy on a network server, you must make your source code available
- Derivative works must also be licensed under AGPL-3.0
- There is NO WARRANTY for this software
Note on Ragtime: The ragtime/ directory is licensed separately under the PolyForm Noncommercial License 1.0.0. See ragtime/LICENSE for details.
- Repository: github.com/KeystoneScience/codex-mem
- Issues: GitHub Issues
- Upstream Project: github.com/thedotmack/claude-mem
- Credit: Alex Newman (@thedotmack) for the original claude-mem architecture
Built with Claude Agent SDK | Powered by Claude Code | Made with TypeScript