The agent's hooks for Codex CLI
The agent's hooks for Codex stand in the project's .codex/hooks.json, where sheriff init --agent codex writes them (§s-7unxytshhc4md54): one when a session starts, one before an edit made with apply_patch, and one after such an edit or a shell command. Each holds only the lookup of the plugin for Codex CLI in Codex's cache (§s-4mej6ccn7xu3d3p) and a call to the plugin's script for that hook, hooks/session-start.sh, hooks/guard.sh or hooks/after-edit.sh; where it finds no plugin, it does nothing.
The scripts do what the agent's hooks do (§s-477gtdrkw34dzxw), and nothing in a repository holding no sheriff.config.json.
Before an edit, sheriff guard reads from the patch each file it adds, updates, deletes or moves, applies the patch to them in memory, a moved file taken as deleted at its old path and added at its new one, and judges each as an edit made with the file tools (§s-4kd2pave7vm4hmd). It refuses the whole patch where it refuses one of its files or cannot read or apply the patch.
Codex admits no plugin carrying hooks into its public directory, so the hooks are the project's. Codex runs a project's hooks once its user trusts the project and each hook as it stands; a hook holding only the lookup and the call changes only where its lookup does, and is trusted again then, while what the scripts do follows the release. A hook that finds no plugin does nothing, so removing the plugin leaves no hook failing in the project.
Codex hands an edit as one patch, which may touch several files and is applied whole, so the guard judges each file and refuses the patch whole.
The links it makes
- implements → Where an agent writes, the checks run at each of its edits
- implements → What is checked, when, and what a failure costs
- cites → Setting a repository up and taking SpecSheriff out of it
- cites → A git hook runs the SpecSheriff tools a plugin keeps on the machine
- cites → The hooks
- cites → How each check is made
The links made to it
The tests bound to it
- skills/tools/test/e2e/codex.test.ts · s-n76wt2bkqdmh78x after an edit, the hook runs the checks over the working tree and reports to the agent what they refuse
- skills/tools/test/e2e/codex.test.ts · s-n76wt2bkqdmh78x before an edit made with apply_patch, the hook refuses the whole patch where sheriff guard refuses one of its files
- skills/tools/test/e2e/codex.test.ts · s-n76wt2bkqdmh78x each of the agent's hooks for Codex holds only the lookup of the plugin in Codex's cache and a call to its script, and does nothing where it finds no plugin
- skills/tools/test/e2e/codex.test.ts · s-n76wt2bkqdmh78x the scripts the agent's hooks for Codex call do nothing in a repository holding no sheriff.config.json
- skills/tools/test/unit/gates.test.ts · s-n76wt2bkqdmh78x judges each file a patch adds, updates, deletes or moves as an edit made with the file tools
- skills/tools/test/unit/gates.test.ts · s-n76wt2bkqdmh78x reads the paths of a patch from the directory the session works in
- skills/tools/test/unit/gates.test.ts · s-n76wt2bkqdmh78x refuses a patch it cannot read or apply
- skills/tools/test/unit/gates.test.ts · s-n76wt2bkqdmh78x refuses the whole patch where it refuses one of its files