Modern QA2026Step 12 — Prepare hooks for automated quality checks — tiles
Log inJoin
36 / 139 · 13 Browser Automation with Playwright · Quick Start Preparation: Turn Discovery into a Scaffolding-Ready Package← prev⊞ allnext →☰ Read as one page

2.16Step 12 — Prepare hooks for automated quality checks

Claude Code supports hooks — shell commands that run automatically at specific points in Claude's workflow. Unlike CLAUDE.md instructions (which are advisory), hooks are deterministic. If a hook fails, Claude's action is blocked.

Recommended hooks for the scaffold

Add these to .claude/settings.json (or ask Claude to write them: "Write a hook that runs eslint after every file edit"):

Lint after every file edit

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "npx eslint --fix $CLAUDE_FILE_PATH 2>/dev/null || true"
          }
        ]
      }
    ]
  }
}

Notify when Claude needs attention

If you step away during scaffolding, get a desktop notification:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}

Block commits without a changelog entry

Claude can update CHANGELOG.md when asked, but it does not do it consistently. A CLAUDE.md instruction helps (~70–80% of the time), but the only guaranteed enforcement is a hook that blocks the commit if CHANGELOG.md is not staged:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash(git commit*)",
        "hooks": [
          {
            "type": "command",
            "command": "git diff --cached --name-only | grep -q 'CHANGELOG.md' || (echo 'BLOCKED: Update CHANGELOG.md before committing. Summarize what was done, why, and which files changed.' && exit 1)"
          }
        ]
      }
    ]
  }
}

When Claude tries to commit without updating the changelog, the hook fails with a clear message. Claude sees the error, goes back, updates CHANGELOG.md, stages it, and retries the commit. This works in every permission mode, including auto.

Pair this hook with the /log skill from Step 6 and the CLAUDE.md rule below for a three-layer approach:

Layer Mechanism Reliability
Hook (PreToolUse on commit) Blocks the commit — Claude cannot skip it 100%
CLAUDE.md rule Reminds Claude to update the log throughout the session ~70–80%
/log skill Manual trigger when you want an entry without committing 100% (you invoke it)

Why hooks matter for autonomous work

When Claude runs in acceptEdits or auto mode, it makes many changes without pausing. Hooks ensure that standards are enforced on every edit, even when you are not watching. This is especially important during scaffolding, where dozens of files are created in sequence.