Codex CLI
How Pathrule CLI connects Codex CLI through hooks, AGENTS.md and MCP, and how Codex can also reach a workspace through Remote MCP.
On this page
Codex CLI connects to your Pathrule workspace through Pathrule CLI or the VS Code extension. The integration has three pieces: Codex's native hooks, a companion AGENTS.md file at the workspace root, and the same MCP tool surface the other clients use. Codex is one of the two clients, with Claude Code, that Pathrule reaches with a prompt-submit hook.
Pathrule writes the Codex hooks and AGENTS.md when the repository already has Codex files: an AGENTS.md, .codex/hooks.json or .codex/config.toml. In a repository with none of them, Codex gets the MCP entry only; add an AGENTS.md and run pathrule sync to have Pathrule write the rest.
This page covers what gets written into your project for the integration, how it differs from the Claude Code and Cursor flows, and how to verify it.
What Pathrule writes
When you install Pathrule into Codex CLI in a repository with Codex files, you get:
- An MCP server entry in
~/.codex/config.toml, so the assistant can callpathrule_*tools. Your other servers in that file stay as they are. .codex/hooks.jsonin the project. The hook registrations, merged so any hooks you added yourself are kept.- A marked block in the project's
.codex/config.tomlthat turns Codex's hooks on. The rest of that file is yours and stays untouched. AGENTS.mdat the workspace root. With the hook installed, Pathrule's part of it is a short note that Pathrule is active and delivered by the hook.
AGENTS.md is the analogue of CLAUDE.md for Codex. When the Codex hook is installed, the protocol rides the SessionStart hook instead of the file, and path knowledge arrives through the prompt and tool hooks, so no protocol copy or knowledge files are written into your tree. Without the hook, AGENTS.md carries the full protocol and workspace overview, and Pathrule adds an AGENTS.md in each directory that has knowledge attached, which Codex loads when work enters that directory.
Hook coverage
Codex's hook contract is close to Claude Code's. Pathrule registers session-start, prompt-submit, pre-tool, post-tool and stop hooks:
- Session start delivers the workspace metadata, the protocol and your team context once per session.
- Prompt submit scopes the turn with the rules and memories that fit the prompt, the strongest memories as full bodies.
- Pre-tool adds the names of what applies to the path the patch or command touches, and checks rules with an approved block pattern before a patch lands.
- Post-tool records the outcome.
- Stop lets an approved required check hold the turn open until its command has passed.
The main differences from Claude Code are in the tool surface: Codex uses its apply_patch format (with *** Update File: markers) instead of separate Edit and Write tools, and there is no Read hook. Pathrule's shared hook script understands apply_patch, resolves the affected paths back to workspace nodes and treats a patch as an edit, so a rule with an approved block pattern stops a matching patch before it is applied. A block pattern an assistant proposed is not enforced until a person has approved it.
The investment lives in the content layer, not in the client, so the same memories, rules and skills serve Codex and every other client.
Per client isolation
Codex coexists with Claude Code and Cursor on the same machine. You can install one, two, or all three. They share the same Pathrule workspace, the same MCP server, and the same content tree. The configs each client reads are independent.
Install
Through Pathrule CLI:
pathrule setup
Run it in the project folder. On a new install it sets the folder up on Pathrule Cloud: it signs you in when needed, attaches the folder to a workspace, writes the MCP entry into ~/.codex/config.toml and every other AI client's configuration, and writes the Codex files when the repository has Codex files. --target codex writes the MCP entry for Codex only. Run pathrule setup --local instead to use Pathrule with no account; knowledge then stays on this machine.
To wire the pieces by hand in a folder that is already attached:
pathrule install codex
pathrule sync
pathrule doctor
pathrule install codex adds the MCP entry to ~/.codex/config.toml. pathrule sync installs the hook script and writes the Codex files, beside Claude Code's, when the repository has Codex files.
Through the VS Code extension, choose Codex in Connect AI Clients. The extension writes the same MCP entry and hook configuration through its bundled CLI.
Remote MCP
Codex can also connect to the hosted endpoint, with no local install:
codex mcp add pathrule --url https://cloud.pathrule.io/mcp
Then complete the OAuth sign-in with your Pathrule account. Remote MCP gives Codex the MCP tools only: it installs no hooks, writes no local files and has no local mode. See Pathrule Remote MCP.
Verify
Open Codex CLI in a directory you attached to a workspace. The Pathrule session metadata should arrive at session start, and the assistant should be able to call pathrule_get_context against your working directory.
Run a simple prompt that touches a path with content. The relevant rules and memories should arrive with the prompt, and the assistant can reach deeper through MCP. If nothing arrives, run:
pathrule doctor
The doctor is read-only. It reports which edition serves this folder, your sign-in and whether this folder is attached in a Cloud folder, whether the Pathrule MCP entry is installed for Codex and each other client, and which Pathrule-managed files are in the folder and who wrote them. Add --json for the full report, which also flags an MCP entry that points at a runtime that no longer exists. pathrule install codex rewrites a stale entry, and pathrule sync keeps the hook script current and, in a repository with Codex files, writes the hook configuration and AGENTS.md again. If you connected Codex with pathrule integrations, pathrule integrations repair applies that integration again.
What stays the same
The content layer is identical across clients.
- The same memory that shows up to Claude Code through the hook shows up to Codex through its own hooks and the MCP tools.
- A rule with an approved block pattern blocks a matching patch on Codex just as it blocks an edit on Claude Code.
- A skill is invokable by name.
If your team writes content for one assistant, every assistant gets it.
What to read next
- Claude Code for the sibling integration with native hooks.
- Cursor for the Cursor integration.
- MCP tools reference for every tool Codex can call.