SpecSheriff
rule · _guidelines/tools/15 · s-n76wt2bkqdmh78x

The agent's hooks for Codex CLI

Checkedconfirmed by its owner

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.

Why

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

The links made to it

The tests bound to it