Project memory for Codex CLI.
codex-mneme turns raw Codex session history into concise, project-scoped startup context so a fresh session can pick up where the last one left off.
It is built around Codex's native session logs in ~/.codex/sessions, not a fragile hook-only transcript pipeline.
Codex is good at the current turn. Long-running project continuity is the harder part.
Important decisions, constraints, and half-finished work end up buried across old sessions. When you come back later, you either re-read history manually or rely on memory and vibes. Both are bad.
codex-mneme solves that by:
- ingesting Codex's real session JSONL history
- keeping memory scoped to the current project
- rendering a compact
session-startbrief for the next session - letting you persist durable project facts as typed memory entries
- working without any external service for the core flow
- Project-scoped memory built from native Codex session history
- Concise startup context with remembered items, rolling summary, and recent turns
- Typed durable memory:
note,decision,constraint,todo - Incremental, bounded ingest for large session histories
- Optional AI summaries through your local Codex CLI auth
- Optional hook integration, while keeping history ingest as the canonical path
- Hook-aware startup context via correlated recent hook turns
- Codex-native setup via
codex-init
Recommended:
npm install -g codex-mnemeOn global install, codex-mneme now attempts to auto-configure Codex for you by:
- installing the global
codex-mnemeskill in~/.codex/skills/ - inserting a managed global
~/.codex/AGENTS.mdworkflow block - inserting a managed
notifyblock in~/.codex/config.tomlwhen there is no conflicting unmanagednotifysetting - inserting/updating managed hook handlers in
~/.codex/hooks.json
If you want to disable install-time setup, use:
CODEX_MNEME_AUTO_SETUP=0 npm install -g codex-mnemeRun without installing globally:
npx --yes npm:codex-mneme@latest statusFrom source:
git clone https://github.com/edimuj/codex-mneme.git
cd codex-mneme
npm install
npm link- Install
codex-mneme. - Global install should auto-configure Codex. If you want to apply or re-apply it manually:
codex-mneme codex-init --global --with-agents --apply-notify --apply-hooks- Generate startup context for the current project:
codex-mneme session-start --limit 8- Save durable project memory when something should survive future sessions:
codex-mneme remember --type decision "Session JSONL is the canonical source of truth"
codex-mneme remember --type constraint "Do not depend on hooks for correctness"- Refresh memory from recent Codex sessions:
codex-mneme ingestResume work on a project:
codex-mneme session-start --limit 8 --max-summary-items 5 --max-remembered-items 10Capture an important decision:
codex-mneme remember --type decision "Use deterministic summaries by default"Check what is currently stored:
codex-mneme remember list
codex-mneme statusUse AI summaries when you want better compression:
codex login
codex-mneme session-start --summary-mode ai --summary-model gpt-5.4-miniRepresentative session-start output:
# Codex-Mneme Context
## Remembered
- [decision] Session JSONL is the canonical source of truth.
- [constraint] Do not depend on hooks for correctness.
## Rolling Summary
- [2026-03-18] Added bounded ingest and deferred backlog draining.
- [2026-03-19] Shipped AI summary caching and deterministic output caps.
## Recent Turns
- 2026-03-19 09:12:21 user: Let's improve the README so people actually want to try this.
2026-03-19 09:12:21 assistant: Plan: rewrite positioning, install, quick start, and command overview.
| Command | What it does |
|---|---|
codex-mneme ingest |
Parse Codex sessions for the current project and update the normalized memory log. |
codex-mneme session-start |
Print startup context: remembered entries, rolling summary, and recent turns. |
codex-mneme remember |
Save a durable project memory entry. |
codex-mneme remember list |
List remembered entries with id prefixes. |
codex-mneme remember edit |
Edit remembered content and/or type. |
codex-mneme remember forget |
Remove a remembered entry. |
codex-mneme hook |
Optional hook entrypoint for Codex hook events. |
codex-mneme codex-init |
Scaffold Codex integration files for project or global setup. |
codex-mneme status |
Show memory paths, tracked files, backlog state, and hook status. |
Most useful session-start flags:
| Flag | Purpose |
|---|---|
--limit N |
Number of recent turns to show. |
--max-summary-items N |
Cap rolling summary bullets. |
--max-remembered-items N |
Cap remembered entries shown (prioritized by type, then recency). |
--max-recent-chars N |
Cap text length per recent turn line. |
--max-output-chars N |
Hard cap final output size. |
| `--summary-mode deterministic | ai |
--summary-model MODEL |
Model used for AI summaries. |
--summary-input-chars N |
Cap prompt size sent to the AI summarizer. |
--summary-timeout-ms N |
Timeout for AI summarization. |
--summary-item-chars N |
Cap length of each AI summary item. |
Global install should handle this automatically. If you want to run it manually or re-apply it:
codex-mneme codex-init --global --with-agents --apply-notify --apply-hooksThat setup:
- creates
~/.codex/skills/codex-mneme/SKILL.md - inserts or updates a managed
~/.codex/AGENTS.mdblock - inserts or updates a managed
notifyblock in~/.codex/config.toml - inserts or updates managed hook handlers in
~/.codex/hooks.json
For a project-local setup instead:
codex-mneme codex-init --with-agents --apply-notify --apply-hooksBy default, session-start uses deterministic summarization. That keeps the core workflow local, cheap, and predictable.
If you have Codex CLI auth and want better compression for long histories, enable AI summaries:
codex login
codex-mneme session-start --summary-mode ai --summary-model gpt-5.4-miniNotes:
- AI mode calls
codex execnon-interactively - output is schema-constrained with
--output-schema - summaries are cached when the effective inputs are unchanged
- if auth, quota, or runtime fails, it falls back to deterministic summary automatically
codex-mneme supports Codex hook events, but hooks are not required for correctness.
History ingest remains the canonical path. Hooks are an opt-in acceleration layer.
Enable them explicitly:
export CODEX_MNEME_ENABLE_HOOKS=1
codex-mneme hook SessionStart
codex-mneme hook PreToolUse --text "About to run a shell command"
codex-mneme hook PostToolUse --text "Shell command completed"
codex-mneme hook UserPromptSubmit --text "Investigate ingest performance"
codex-mneme hook StopOr let Codex pipe hook payload JSON to stdin and infer the event automatically:
echo '{"hook_event_name":"UserPromptSubmit","session_id":"s1","turn_id":"t1","prompt":"Investigate ingest performance"}' | codex-mneme hookFor hooks.json, that means you can use the same command for all events:
{
"hooks": {
"SessionStart": [{ "hooks": [{ "type": "command", "command": "codex-mneme hook" }] }],
"PreToolUse": [{ "hooks": [{ "type": "command", "command": "codex-mneme hook" }] }],
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "codex-mneme hook" }] }],
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "codex-mneme hook" }] }],
"Stop": [{ "hooks": [{ "type": "command", "command": "codex-mneme hook" }] }]
}
}Optional: override per-event hook policy (currently ingest) with CODEX_MNEME_HOOK_POLICIES:
export CODEX_MNEME_HOOK_POLICIES='{"PreToolUse":{"ingest":true},"Stop":{"ingest":false}}'Hook records now include correlation keys when available from hook payloads:
sessionIdturnIdturnKey(<sessionId>:<turnId>)toolUseId/toolName/sourcewhen present
session-start now includes a Recent Hook Turns section when correlated hook data is available.
Rolling summaries (deterministic and AI) also consume older hook turns when hook logs are present.
At a high level:
- Read Codex session
.jsonlfiles from~/.codex/sessions. - Scope entries to the current project using
session_meta.payload.cwd. - Normalize useful user and final assistant turns into a project memory log.
- Store durable remembered items separately.
- Render a short startup brief for the next session.
Project memory is stored under:
~/.codex-mneme/projects/<project-key>/
That directory contains the normalized log, remembered items, ingest state, optional hook events, and optional AI summary cache.
git clone https://github.com/edimuj/codex-mneme.git
cd codex-mneme
npm install
npm test
node src/cli.mjs session-start --limit 8
node src/cli.mjs statusMIT