Codex CLI
Your Codex agent remembers past decisions, finds relevant context, and learns from every session, across all your AI tools.
Hybrid Codex setup
Best result on modern Codex: install the plugin, keep the bundled Nowledge Mem MCP server enabled, and run the hook setup once. The plugin starts Codex with the right memory guidance, MCP gives it low-friction retrieval and write tools, and the Stop hook captures the real Codex transcript.
Switch between Codex, Claude Code, Gemini, and Cursor without losing context. The Codex package gives you a reliable Working Memory bootstrap, a bundled local MCP server, search and distill skills, and automatic thread capture. Codex still decides when to use memory, but modern Codex tends to follow MCP tools more proactively than skill-only guidance. That is why the recommended setup is hybrid: plugin + MCP + hook.
How you'll know it's working
Start a session and ask "What was I working on?" You should see your recent focus areas and priorities. Then ask a continuation-style question such as "What did we decide before about this release?" On a healthy setup, Codex should move from Working Memory into retrieval instead of stopping at the briefing. After a short turn, nmem t search "phrase from that turn" --source codex should find the captured Codex thread.
Before You Start
- Nowledge Mem running locally (installation) or a reachable remote Mem server
- Codex CLI installed
nmemCLI in yourPATH
Setup
Install nmem
# Option 1: uvx
curl -LsSf https://astral.sh/uv/install.sh | sh
uvx --from nmem-cli nmem --version
# Option 2: pip
pip install nmem-cliIf Nowledge Mem is already running on the same machine through the desktop app, the cleanest setup is Settings → Preferences → Developer Tools → Install CLI.
Install the plugin
Use marketplace-first setup
If you run into older instructions that copy files into ~/.codex/plugins/cache/local/..., treat that as legacy fallback only. The primary path is: add the marketplace, install the plugin from Codex /plugins, then enable it in config.
codex plugin marketplace add nowledge-co/communityIf your Codex build only supports the legacy top-level subcommand:
codex marketplace add nowledge-co/communityOpen Codex /plugins and install nowledge-mem@nowledge-community.
Enable the plugin
Put this in ~/.codex/config.toml:
[features]
plugins = true
codex_hooks = true
[plugins."nowledge-mem@nowledge-community"]
enabled = trueRestart Codex after installation.
What the plugin includes
The current package includes a local Nowledge Mem MCP server at http://127.0.0.1:14242/mcp/. Codex user config wins if you define your own mcp_servers.nowledge-mem, so remote Mem and custom local ports stay explicit.
Enable automatic thread capture
Current stable Codex loads host-level hooks from ~/.codex/hooks.json. Run the plugin's hook setup once after install or update:
HOOK_SETUP="$(find ~/.codex/plugins/cache -path '*/nowledge-mem/*/scripts/install_hooks.py' -print 2>/dev/null | sort | tail -1)"
test -n "$HOOK_SETUP" && python3 "$HOOK_SETUP"The hook runs after Codex turns and calls nmem t save --from codex. It reads the local Codex transcript, then uploads through your normal nmem client configuration. That means local Mem and remote Mem use the same setup.
Optionally add project-level guidance
Copy or merge the plugin's AGENTS.md into your project root for stronger default memory behavior:
git clone https://github.com/nowledge-co/community.git /tmp/nowledge-community
cp /tmp/nowledge-community/nowledge-mem-codex-plugin/AGENTS.md ./AGENTS.md
rm -rf /tmp/nowledge-communityIf your project already has an AGENTS.md, merge the Nowledge section instead of overwriting. This is the clean way to make Codex do more than the basic Working Memory bootstrap on continuation-heavy repos.
Do not edit installed plugin files
Use your repo's own AGENTS.md as the override layer. Treat the package AGENTS.md as source text to copy or merge, not as a file to patch inside the Codex plugin install directory.
Configure remote Mem when needed
nmem config client set url https://mem.example.com
nmem config client set api-key nmem_your_keynmem resolves connection settings in this order:
--api-url/--api-keyflagsNMEM_API_URL/NMEM_API_KEY~/.nowledge-mem/config.json- defaults
If Mem is remote, override the bundled local MCP server in ~/.codex/config.toml too:
nmem config mcp show --host codexPaste the generated TOML into ~/.codex/config.toml. Direct MCP clients do not read ~/.nowledge-mem/config.json automatically; this keeps Codex MCP and nmem pointed at the same Mem server. MCP gives Codex direct tools; nmem still powers the plugin-side fallback flows and real save-thread.
Repo-level install (alternative)
Instead of a shared marketplace source, you can bundle the plugin in a project repo using a local Codex marketplace file. This makes the plugin available to anyone who clones the repo.
git clone https://github.com/nowledge-co/community.git /tmp/nowledge-community
mkdir -p .agents
cp -r /tmp/nowledge-community/nowledge-mem-codex-plugin ./.agents/nowledge-mem
rm -rf /tmp/nowledge-community
mkdir -p .agents/pluginsCreate .agents/plugins/marketplace.json:
{
"name": "local",
"plugins": [
{
"name": "nowledge-mem",
"source": {
"source": "local",
"path": "./.agents/nowledge-mem"
},
"policy": {
"installation": "INSTALLED_BY_DEFAULT",
"authentication": "ON_INSTALL"
},
"category": "Productivity"
}
]
}The path is relative to the repo root, not to the marketplace file. For this local setup, use:
[plugins."nowledge-mem@local"]
enabled = trueThen run the hook setup from the repo-local plugin:
python3 ./.agents/nowledge-mem/scripts/install_hooks.pyUpdate
If you installed the Codex package before 0.1.10, marketplace update alone refreshes the plugin files but does not reliably refresh the host-level Stop hook. Run the hook setup below after updating; it replaces older async hook entries that current Codex stable skips.
codex plugin marketplace upgrade nowledge-communityThen refresh the hook runtime:
HOOK_SETUP="$(find ~/.codex/plugins/cache -path '*/nowledge-mem/*/scripts/install_hooks.py' -print 2>/dev/null | sort | tail -1)"
test -n "$HOOK_SETUP" && python3 "$HOOK_SETUP"If the marketplace is not registered yet, run:
codex plugin marketplace add nowledge-co/community || codex marketplace add nowledge-co/communityThen restart Codex. If you are using a repo-local @local source, update that local source path instead.
Skills
The plugin skills still matter in the hybrid setup. They teach Codex when to use memory at all, while MCP gives Codex a lower-friction execution path once it decides to act.
| Skill | Trigger | What it does |
|---|---|---|
$nowledge-mem:working-memory | Session start, "what am I working on" | Loads your daily Working Memory briefing and prefers MCP read_working_memory when available |
$nowledge-mem:search-memory | Prior work, past decisions, "why did we..." | Searches memories and threads with progressive inspection, preferring MCP retrieval when available |
$nowledge-mem:save-thread | Manual save request, or hook setup unavailable | Real Codex transcript import via nmem t save --from codex |
$nowledge-mem:distill-memory | Decisions, learnings, procedures emerge | Proactively saves durable insights to memory, preferring MCP writes when available |
$nowledge-mem:status | "Is Mem working?", errors | Checks server connectivity and configuration |
Direct nmem Use
nmem remains the universal fallback and the real Codex thread-import path. The Stop hook uses the same command automatically:
nmem --json wm read
nmem --json m search "auth token rotation" --mode deep
nmem --json t save --from codex -p . -s "Finished the auth refactor."
nmem --json m add "JWT refresh failures came from clock skew." --title "JWT refresh failures traced to clock skew" --importance 0.9 --unit-type learning -l auth -s codexBy default, nmem t save --from codex reads sessions from ~/.codex. If your Codex home lives somewhere else, set CODEX_HOME and the save path follows automatically.
Migrating from Custom Prompts
If you previously used nowledge-mem-codex-prompts, the plugin covers everything the prompts did:
- Install the plugin (see Setup above).
- Remove old prompts:
rm ~/.codex/prompts/{read_working_memory,search_memory,save_session,distill}.md - The plugin skills replace the prompts one-to-one.
| Old prompt | New skill |
|---|---|
/prompts:read_working_memory | $nowledge-mem:working-memory |
/prompts:search_memory | $nowledge-mem:search-memory |
/prompts:save_session | $nowledge-mem:save-thread |
/prompts:distill | $nowledge-mem:distill-memory |
| (none) | $nowledge-mem:status |
Troubleshooting
"Command not found: nmem"
Install with pip install nmem-cli or use uvx --from nmem-cli nmem. See Getting Started.
"Cannot connect to server"
Run nmem status and nmem config client show for remote setups. See Remote Access.
Skills not appearing
Restart Codex after installing the plugin. Verify three things: the marketplace was added, nowledge-mem@nowledge-community was installed from /plugins, and ~/.codex/config.toml has both [features] plugins = true and [plugins."nowledge-mem@nowledge-community"] enabled = true. If you intentionally use a repo-local source, use [plugins."nowledge-mem@local"].
Codex threads are not appearing automatically
Run the hook setup again, then restart Codex:
HOOK_SETUP="$(find ~/.codex/plugins/cache -path '*/nowledge-mem/*/scripts/install_hooks.py' -print 2>/dev/null | sort | tail -1)"
test -n "$HOOK_SETUP" && python3 "$HOOK_SETUP"The setup writes ~/.codex/hooks.json and ensures codex_hooks = true in ~/.codex/config.toml.
"plugin is not installed"
Run codex plugin marketplace add nowledge-co/community (or codex marketplace add nowledge-co/community on legacy Codex), install nowledge-mem@nowledge-community from /plugins, then verify the plugin key in ~/.codex/config.toml.
It only reads Working Memory, but never searches or distills
That usually means Codex is only seeing the plugin bootstrap path. Confirm the bundled nowledge-mem MCP server is visible in Codex, then merge the package AGENTS.md into your project root. If Mem is remote or not on the default local port, add mcp_servers.nowledge-mem in ~/.codex/config.toml to override the bundled endpoint.