Codex CLI
OpenAI’s Codex CLI has no per-tool-call hook (the only documented event hook, notify, fires at the end of a turn, after the model has already seen the tool output), so sqz cannot rewrite its shell commands transparently the way it does for Claude Code or Gemini CLI. Two things Codex does support reliably carry the integration instead:
AGENTS.mdat the project root, read at session start.sqz initwrites a fenced block that tells Codex to pipe long-running commands throughsqz compress, when not to, and how to recover from a§ref:HASH§token.- MCP servers in
~/.codex/config.tomlunder[mcp_servers.<id>].sqz initmerges ansqzentry so Codex getscompress,passthrough,expand,sqz_recall,sqz_read_file,sqz_grepandsqz_list_dir.
Setup
cargo install sqz-cli sqz-mcp # or brew / npm / pipx, see the README
cd your-project
sqz init --only codex
sqz init with no --only does the same as part of setting up every tool it detects.
What it writes:
-
./AGENTS.md: appends (or creates) a block between<!-- BEGIN sqz-guidance -->and<!-- END sqz-guidance -->markers, the same block the Zed integration uses. Anything else in the file is left alone. Re-runningsqz init(orsqz doctor --fix) replaces only that block, and folds the separatesqz-agents-guidanceandsqz-zed-guidanceblocks older versions wrote into it. -
~/.codex/config.toml(or$CODEX_HOME/config.tomlif set): adds[mcp_servers.sqz] command = "sqz-mcp" args = ["--transport", "stdio"]The key is
mcp_servers(snake_case).mcpServersis the JSON convention used by other clients and Codex ignores it. If an[mcp_servers.sqz]entry with acommandalready exists, sqz does not overwrite it. Other servers in the file are untouched.
Verify:
sqz status
Then start Codex in the project and ask it to run a noisy command (npm install, cargo test). You should see [sqz] N/M tokens (X% reduction) in the tool output, and repeated file reads coming back as §ref:…§ references.
What you get
- Shell output compressed when Codex follows the AGENTS.md guidance and pipes through
sqz compress(per-command formatters, dedup references on repeats, safe mode for stack traces and secrets). - Compressed file reads, greps and directory listings through the
sqz_*MCP tools, with 13-token references on repeat reads and line-level deltas after small edits. sqz_recallfor recovering exact tool output after Codex compacts its context.expandfor getting back what a§ref:HASH§stands for, andSQZ_NO_DEDUP=1/SQZ_NO_ABBREV=1as per-command opt-outs, all documented in the block Codex reads.
Limits
Because the shell side depends on guidance rather than a hook, compression is only as consistent as Codex’s adherence to AGENTS.md. In practice it follows the block well for the commands listed in it. If sqz stats --breakdown shows a command you run often with no savings, mention it in your own part of AGENTS.md (sqz rewrites what is between its markers), or use the MCP tools for that operation instead.
Codex’s features.codex_hooks flag is documented as experimental and off by default. sqz will target it once the hooks.json schema is stable.
Uninstall
sqz uninstall
Removes the AGENTS.md block (leaving the rest of the file) and the [mcp_servers.sqz] table (leaving other servers).