Integration · OpenAI

Persistent memory for OpenAI Codex CLI

One command sets cachly up for Codex CLI. Each session starts with a briefing from your project's memory, and lessons that match your prompt are added before Codex starts working.

Set it up

  1. In your project folder, run:

    npx @cachly-dev/mcp-server@latest autopilot
  2. Sign in once in the browser when asked. If autopilot did not find Codex, set it up directly:

    npx @cachly-dev/mcp-server@latest init --editor codex
  3. In Codex, confirm the cachly hook once under /hooks and trust the project folder.

What happens automatically

Session start
A short briefing with up to 5 lessons of this project.
Every prompt
Up to 3 lessons that match the prompt are added before Codex starts.

On top of that, Codex CLI can call the cachly tools itself, for example smart_recall before a task and learn_from_attempts after a fix.

Files cachly writes

.codex/config.toml
Connects the cachly MCP server ([mcp_servers.cachly]).
AGENTS.md
Tells Codex when to use its memory.
.codex/hooks.json, .codex/hooks/
The hooks for the briefing and the lessons per prompt.

Limits

  • Codex allows about 2,500 tokens per hook output. cachly stays below that: 3 lessons per prompt, 5 in the briefing.
  • There is no hook at the end of a turn. Codex stores lessons through the cachly MCP tool.

Frequently asked questions

Does Codex CLI keep context between sessions?

Codex reads AGENTS.md, which you maintain yourself. With cachly, lessons stored after a fix come back in later sessions: in the briefing and before each prompt that matches.

Why do I have to confirm the hook?

Codex asks before it runs a new hook. Confirm the cachly hook once under /hooks; until then Codex has the cachly tools but no automatic briefing.

Where is my memory stored?

On cachly servers in Nuremberg, Germany. Your project files hold no key; the key comes from your environment or from ~/.cachly/credentials.json on your machine.

Can my other coding tools use the same memory?

Yes. A lesson stored from one tool is available in every other tool connected to the same Brain, and to teammates who share it. Claude Code, Cursor, GitHub Copilot, JetBrains, Codex CLI and Gemini CLI all read from one Brain.

More about cachly and Codex CLI