hk agent stop-hook
- Usage:
hk agent stop-hook [--timeout <SECONDS>] [--target <TARGET>]
Run hk run check --safe as an agent Stop hook
Reads the agent's Stop hook JSON from stdin and does nothing when stop_hook_active is true. In a project without an hk config, or one with no check hook, it passes like a hook from hk install --global, so it is safe in user-level agent settings. Always exits 0. When the check fails or --safe refuses to run, prints only {"decision":"block","reason":"..."}, the decision both Claude Code and Codex accept. A check still running after --timeout seconds is stopped and reported the same way. When the check passes, prints nothing, or {} with --target codex, because Codex's documentation is inconsistent about empty stdout and {} is valid under either reading.
Flags
--timeout <SECONDS>— Seconds to let the check run before stopping it (default 100). Keep it below the agent's own hook timeout.--target <TARGET>— Agent running the hook;codexprints{}when the check passesChoices:
codex,claude-code-h --help— Print help
Examples
Run as the command of a Claude Code or Codex Stop hook; see the hook snippet from hk agent hooks.
hk agent stop-hook