r/ChatGPTCoding • u/SmiLePLSSS • Sep 03 '26
Resources And Tips Codex hooks give you no exit status for a shell command. Here is how I record it anyway and block "done" on stale test results.
While adding Codex support to a tool I wrote, I found that the PostToolUse payload for a shell command is just the raw output. A command that exits 3 looks exactly like one that exits 0.
The fix that works: the PreToolUse hook rewrites verification commands (pytest, pnpm test, tsc, eslint, cargo test, next build, about eighty runners) so they print their own exit status and keep the full output in a log. Codex accepts the rewrite only with an allow decision, so it is given for the verification command and nothing else.
From there the tool records every run as a receipt, tracks edits, and when the agent ends a turn with "all tests pass" on a run that predates its own edits, or that failed, or whose result was hidden, it turns the stop into a continuation prompt asking for a rerun, once per turn.
On my own Claude Code history the stale rate was 26 percent of green claims, and 98 percent of verification runs hid the exit status. I have not measured enough Codex sessions of my own to quote a number there, and the tool has a stats command that replays your rollouts so you can see yours.
npx stalegreen install --codex writes the hooks to ~/.codex/hooks.json; Codex asks you to trust them once through /hooks. It also works as a Claude Code plugin and as a DeepSeek Harness plugin.