Claude Code Hooks: Where the Harness Enforces

Claude Code Hooks: Where the Harness Enforces A sequence diagram generated by Archify. prompt UserPromptSubmit context + tools tool_use: Edit PreToolUse allow (exit 0) run tool PostToolUse: format tool result end turn Stop: run tests exit 2 + stderr keep working Prompt Tool call Stop Developer · prompt · Sequence participant Developer prompt Claude Code · harness · Sequence participant Claude Code harness Claude · model · Sequence participant Claude model Hook script · your code · Sequence participant Hook script your code Tool · Edit, Bash, MCP · Sequence participant Tool Edit, Bash, MCP Legend request return security default message

Before

  • • PreToolUse and deny rules can block any call

After

  • • PostToolUse formats, lints or logs each edit

Done

  • • A Stop hook keeps the turn open until checks pass
© 2026 Samir Kumar Sahoo. All rights reserved.