Setup codex pre-check
You install (and verify) a codex "double-check" gate into the current project only: a
PreToolUse hook that pipes every proposed Edit/Write/MultiEdit to the codex CLI for
an independent review before it is written. codex returns VERDICT: APPROVE (edit proceeds)
or VERDICT: BLOCK (edit denied, concerns fed back to Claude). It fails open — if codex
is missing/logged-out/erroring, edits are allowed with a warning, never blocked.
This skill bundles the canonical hook and an idempotent installer. Do not hand-write the
hook — always install the bundled copy so it stays consistent.
What it installs (into the current project)
.claude/hooks/codex-precheck.py — the hook (copied from this skill's directory).
.claude/settings.json — a PreToolUse entry (matcher: "Edit|Write|MultiEdit"), merged
in without clobbering existing settings/hooks.
CLAUDE.md — a short policy section (appended only if not already present).
At runtime (not install time) the hook also creates, inside the project's .claude/:
codex-precheck.log — an append-only audit trail; one tab-separated line per gated edit:
<timestamp> <OUTCOME> <tool> <file> <detail>, where OUTCOME is APPROVE, BLOCK,
CACHE_HIT, or SKIP (any fail-open reason). Tell users they can tail -f it to watch
the gate, or to confirm whether a given edit was actually reviewed.
.codex-cache — sha256 digests of already-approved changes, so an identical re-write is a
CACHE_HIT and isn't re-sent to codex (avoids redundant reviews and loops).
The bundled hook scans only stderr on a non-zero exit to detect a logged-out codex, so a
file that legitimately contains auth strings (e.g. the hook itself) no longer trips a false
"logged out" skip.
Process
Run the installer from this skill's directory, targeting the current project. Pass
$ARGUMENTS as the target dir if the user supplied one, otherwise default to $PWD:
bash "$HOME/.claude/skills/setup-codex-precheck/install.sh" ${ARGUMENTS:-"$PWD"}
The installer prints a status report: prerequisites (python3, codex, codex login),
what was already present (✓), what it added (+), warnings (!), and a self-test.
Read the report back to the user in plain language: which prerequisites are satisfied,
what was installed vs already present, and the self-test result.
If codex is logged out or not installed, tell the user clearly that the gate is active
but currently fails open (no real review happens) until they run codex login (or
install codex). Suggest they run ! codex login in the session. Do not attempt the
interactive login yourself.
If codex is installed and logged in, optionally confirm the live path with a quick
smoke test, then show the user how to verify the block path:
printf 'Reply exactly: VERDICT: APPROVE' | codex exec --skip-git-repo-check -s read-only -
Remind the user to restart Claude Code or run /hooks so the new hook is loaded — a
freshly written settings.json is not picked up mid-session automatically.
Critical Rules
- Current project only. Install into the target dir (default
$PWD); never touch
~/.claude/settings.json. This is a per-project gate by design.
- Idempotent. The installer is safe to re-run; it detects an existing install and skips.
If the user re-invokes the skill, just run it again and report "already present".
- Never clobber existing
settings.json or CLAUDE.md — the installer merges/appends.
Don't bypass it with a raw overwrite.
- Fail-open is intentional. Don't "fix" the hook to hard-block when codex is unavailable —
that would brick editing. A logged-out codex must allow edits with a warning.
- Don't fake the prereq check. Report exactly what
install.sh found. If python3 is
missing, the hook can't run — say so.
- Flag the trade-off if asked: this reviews on every code edit, so each edit waits for a
codex call (up to the 120s hook timeout). Mention an end-of-task
Stop hook as the lighter
alternative if the user finds per-edit latency annoying.
Final Note
$ARGUMENTS is an optional target project directory; default to the current directory when
empty. The skill's job is: run the bundled installer, faithfully report its findings, and tell
the user the one manual step (codex login) if it's needed.
1---2name: setup-codex-precheck3description: Install the codex pre-edit "double-check" hook into the current project — a PreToolUse hook that asks the codex CLI to review every Edit/Write/MultiEdit before it is written, blocking risky changes. Checks prerequisites (codex, python3, codex login) and installs anything missing, idempotently. Use when the user wants to "set up the codex check", "install the codex double-check / pre-check / review hook", "make Claude check with codex before editing", or "add the codex gate to this project".4---56# Setup codex pre-check78You install (and verify) a codex "double-check" gate into the **current project only**: a9`PreToolUse` hook that pipes every proposed `Edit`/`Write`/`MultiEdit` to the `codex` CLI for10an independent review before it is written. codex returns `VERDICT: APPROVE` (edit proceeds)11or `VERDICT: BLOCK` (edit denied, concerns fed back to Claude). It **fails open** — if codex12is missing/logged-out/erroring, edits are allowed with a warning, never blocked.1314This skill bundles the canonical hook and an idempotent installer. Do **not** hand-write the15hook — always install the bundled copy so it stays consistent.1617## What it installs (into the current project)18- `.claude/hooks/codex-precheck.py` — the hook (copied from this skill's directory).19- `.claude/settings.json` — a `PreToolUse` entry (`matcher: "Edit|Write|MultiEdit"`), merged20 in without clobbering existing settings/hooks.21- `CLAUDE.md` — a short policy section (appended only if not already present).2223At runtime (not install time) the hook also creates, inside the project's `.claude/`:24- `codex-precheck.log` — an append-only audit trail; one tab-separated line per gated edit:25 `<timestamp> <OUTCOME> <tool> <file> <detail>`, where OUTCOME is `APPROVE`, `BLOCK`,26 `CACHE_HIT`, or `SKIP` (any fail-open reason). Tell users they can `tail -f` it to watch27 the gate, or to confirm whether a given edit was actually reviewed.28- `.codex-cache` — sha256 digests of already-approved changes, so an identical re-write is a29 `CACHE_HIT` and isn't re-sent to codex (avoids redundant reviews and loops).3031The bundled hook scans **only stderr on a non-zero exit** to detect a logged-out codex, so a32file that legitimately contains auth strings (e.g. the hook itself) no longer trips a false33"logged out" skip.3435## Process36371. **Run the installer** from this skill's directory, targeting the current project. Pass38 `$ARGUMENTS` as the target dir if the user supplied one, otherwise default to `$PWD`:39 ```bash40 bash "$HOME/.claude/skills/setup-codex-precheck/install.sh" ${ARGUMENTS:-"$PWD"}41 ```42 The installer prints a status report: prerequisites (`python3`, `codex`, codex login),43 what was already present (`✓`), what it added (`+`), warnings (`!`), and a self-test.44452. **Read the report back to the user** in plain language: which prerequisites are satisfied,46 what was installed vs already present, and the self-test result.47483. **If codex is logged out or not installed**, tell the user clearly that the gate is active49 but currently **fails open** (no real review happens) until they run `codex login` (or50 install codex). Suggest they run `! codex login` in the session. Do not attempt the51 interactive login yourself.52534. **If codex is installed and logged in**, optionally confirm the live path with a quick54 smoke test, then show the user how to verify the block path:55 ```bash56 printf 'Reply exactly: VERDICT: APPROVE' | codex exec --skip-git-repo-check -s read-only -57 ```58595. **Remind the user to restart Claude Code or run `/hooks`** so the new hook is loaded — a60 freshly written `settings.json` is not picked up mid-session automatically.6162## Critical Rules63641. **Current project only.** Install into the target dir (default `$PWD`); never touch65 `~/.claude/settings.json`. This is a per-project gate by design.662. **Idempotent.** The installer is safe to re-run; it detects an existing install and skips.67 If the user re-invokes the skill, just run it again and report "already present".683. **Never clobber** existing `settings.json` or `CLAUDE.md` — the installer merges/appends.69 Don't bypass it with a raw overwrite.704. **Fail-open is intentional.** Don't "fix" the hook to hard-block when codex is unavailable —71 that would brick editing. A logged-out codex must allow edits with a warning.725. **Don't fake the prereq check.** Report exactly what `install.sh` found. If `python3` is73 missing, the hook can't run — say so.746. **Flag the trade-off** if asked: this reviews on *every* code edit, so each edit waits for a75 codex call (up to the 120s hook timeout). Mention an end-of-task `Stop` hook as the lighter76 alternative if the user finds per-edit latency annoying.7778## Final Note7980`$ARGUMENTS` is an optional target project directory; default to the current directory when81empty. The skill's job is: run the bundled installer, faithfully report its findings, and tell82the user the one manual step (`codex login`) if it's needed.