KERNEL

HOOKS

Shell triggers the harness runs for you.

A hook is a script that runs on an event: PreToolUse, PostToolUse, SessionStart, Stop. Think middleware. Useful for blocking edits on sensitive files, running lint after a save, firing a notification when a long session ends.

Configured in settings.json. Do not confuse it with Claude's memory. A hook is deterministic, it always runs, without depending on the agent remembering.

In Sapiens, a hook warns whenever an em-dash shows up in a .md file, because the house DNA forbids it. A rule that becomes code, not a preference that becomes wishful thinking.

In practice

// .claude/settings.json
{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Edit|Write",
      "hooks": [{
        "type": "command",
        "command": "node hooks/check-emdash.mjs"
      }]
    }]
  }
}

This practice is part of Claude Code OS, the full blueprint of the practices that separate following a tutorial from actually working with Claude. Ler em português.