Adding memory to TRAE CLI

the MCP server in traecli.toml, Codex's hooks in cli/hooks.json, and trusting them once at start-up

TRAE CLI 2.0 ships as traex (reporting itself as traecli 0.200.x), a closed-source fork of codex-rs. It writes every session to disk as it runs and opens the next one empty. What you worked out in an earlier session is still on disk, along with the work you did the same week in whichever other agent was open.

What TRAE CLI already has

Rollouts live under ${TRAE_HOME:-~/.trae}/cli/sessions/YYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl (and .jsonl.zst once compressed), with sessions moved by traex archive <id> in archived_sessions/ and the prompts you typed in history.jsonl beside them. TRAECLI_HOME moves the cli directory, TRAE_HOME moves TRAE's whole home above it, and DEJA_TRAE_ROOT overrides the directory deja reads; deja follows all three. (TRAE CLI 1.x, internally CoCo, wrote events.jsonl under ~/Library/Caches/coco/sessions/ on macOS and ~/.cache/coco/sessions/ on Linux, a different format that is not read.)

Because traex is a codex-rs fork, the files are Codex rollouts — session_meta, turn_context, response_item, event_msg — plus TRAE's own history_mutation records for tool calls. deja reads them with the Codex reader and files the sessions under trae, not codex, so deja resume <id> reopens one with traex resume <id> and deja handoff --to trae --exec opens the TUI with the packet as the first prompt. How TRAE CLI's store is read documents the rollout format and the three places where TRAE's records differ from Codex's.

On its own, TRAE CLI carries nothing between sessions except AGENTS.md — the repository's, and ~/.trae/AGENTS.md ($TRAE_HOME/AGENTS.md), which deja rules sync keeps in step.

Adding recall

deja install trae-auto

That writes three things, and deja uninstall trae-auto takes out only what deja added:

  • [mcp_servers.deja] (with command and args, and no type key) and [tui.statusline] in ${TRAE_HOME:-~/.trae}/traecli.toml. TRAECLI_HOME does not move this file: even with it set, traex mcp add writes to $TRAE_HOME/traecli.toml.
  • Codex's hooks in ${TRAECLI_HOME:-${TRAE_HOME:-~/.trae}/cli}/hooks.json, the destination traex migrate hooks --user copies a legacy 1.x file to. (~/.trae/hooks.json belongs to TRAE IDE and 1.x; TRAE CLI 2.0 no longer reads it.)
  • The deja-history and deja-search skills in ~/.agents/skills.

For the MCP server and skill alone, without hooks or the status line, run deja install trae.

One catch worth knowing before you go looking for a bug: TRAE CLI keeps Codex's per-hook trust store (hooks.state tables with a trusted_hash in traecli.toml), and a hook that is never trusted never fires. After running deja install trae-auto, open traex once and trust the hooks it shows at start-up (/hooks lists them). Until you do, every file on disk looks right and no hook ever runs.

Either path needs the deja binary on PATH:

brew install deja-vu
# or
curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh

What the hooks add

  • The project digest at SessionStart: what this project's past sessions settled, before the first prompt.
  • Recall on UserPromptSubmit for each prompt, silent when the history has no answer.
  • File history on PreToolUse before Bash, apply_patch, Edit or Write: traecli 0.208 edits through Claude Code's Edit and Write tools rather than Codex's apply_patch, so the matcher covers both shapes.
  • The repair on PostToolUseFailure (and PostToolUse) after Bash: when a command exits non-zero with an error solved on this machine before, the fix pair arrives in the next request as a developer message right after the call.
  • Compaction recovery on PreCompact: when you run /compact, deja stores the working packet and the next turn's SessionStart hands back the task, the files and the commands with whether they passed (after compaction).
  • SessionEnd on /quit, so the session you just closed is indexed for the next one.
  • /deja-history <query> from ~/.agents/skills/deja-history/SKILL.md, which sends the skill body and your query together, and deja · … in the TUI status line.

Measured on traecli 0.208.1-alpha.5 by reading the requests it sent: in an interactive traex session, a code-mode exec call to deja's MCP tool asks for approval and returns recall; in non-interactive traecli exec, the same MCP call fails with MCP tool call requires approval, but approval policy is never, so recall there comes from the hooks once they have been trusted in traex.

TRAE IDE is a separate install

The desktop apps — TRAE, TRAE CN and TRAE SOLO — keep chat in a SQLCipher-encrypted ModularData/ai-agent/database.db, which deja does not read. deja install trae-ide and deja install trae-ide-auto wire the IDE against the same local index: the server in <user data>/User/mcp.json, the skill in ~/.trae/skills (~/.trae-cn/skills for CN), and Claude-shaped hooks in ~/.trae/hooks.json. The IDE ships with hooks off in its own settings store, so turn them on under Settings > Hooks (enable global hooks and run them locally); until then only the MCP tool works there.

The part that is not about this harness

The index covers every agent's transcripts on the machine — forty-three of them today, each in its own format — so a fix found in one tool answers a question asked in another, including sessions from before any of this was installed. That is the reason to index rather than to capture.

Nothing here writes memories, so there is nothing to hallucinate into your history; indexing and search are local, and credentials are stripped as the index is built (privacy). An injection is capped at 1,536 bytes per prompt and about 4 KB per tool call — what memory costs has the measured comparison.

Getting started · How TRAE CLI's store is read · Deleting TRAE CLI sessions · Memory for Codex CLI

Found this useful? Star deja-vu on GitHub.