Skip to content
BoringStack
Star

Factory hooks

2 min read

The hooks live in .claude/settings.json. Codex reads the generated .codex/hooks.json. They are tripwires, not a sandbox: they stop the common unsafe moves and make the gate hard to skip. They do not contain a determined agent.

factory hook guard refuses:

  • force pushes;
  • pushes to a protected branch (main, master);
  • reading or printing secret files such as .env files and private keys;
  • branch switches in the main checkout;
  • commands that reach real infrastructure: kubectl, helm, argocd, vault, and the apply, destroy and import subcommands of OpenTofu and Terraform.

A person does those things. An agent that needs one writes the reason to the BLOCKED marker and stops. See For the owner.

factory hook baseline records the commit the session started from, so the Stop gate knows what this session changed.

factory hook stop will not let a session finish while:

  • a changed app has no passing factory verify at the current commit, or
  • a pushed branch has no complete verification record.

If only a person can unblock the session, write the reason to .agent-state/factory/BLOCKED. The hook challenges that once. Three identical blocks in a row release the session, so a broken gate cannot trap it forever.

The factory’s own planning gate, from tools/spec-loop, runs alongside these.