<- all tokdocs

Claude Code Hooks vs Pre-Commit Checks: Matt Pocock's Advice Checked

By , founder of Mavric and Apso

View on TikTok ->

Matt Pocock argues that running lint and tests in a Claude Code hook on every file edit is slow and floods the agent with tokens, and that those checks belong in a Git pre-commit hook instead. The core advice is reasonable. But the Claude Code docs show that a passing hook costs no tokens, async hooks add no delay, and Stop and PostToolBatch hooks batch feedback without waiting for a commit.

The video, posted as @mattpocockuk with the title "STOP running your checks in hooks," shows no terminal, config file or timing.

What does Matt Pocock recommend?

He says many people run automated checks "on every single file edit" inside agent hooks. He objects that this makes things slower and is "incredibly noisy for the agent," because "The agent is receiving a ton of tokens on every single file and it will often know that it's putting the file into a broken state."

His alternative is a Git pre-commit hook: "you're batching all that information to the right moments, to when the agent is actually committing it to the history." He says pre-commit checks should ideally be "shorter than three seconds," with anything slower delegated "to CI, which will run before the PR merges."

Do the Claude Code docs recommend per-edit hooks?

They do, so the pattern he is arguing against is real. The first worked example in the Claude Code hooks guide is a PostToolUse hook with an Edit|Write matcher:

"PostToolUse": [
  {
    "matcher": "Edit|Write",
    "hooks": [{ "type": "command", "command": "jq -r '.tool_input.file_path' | xargs npx prettier --write" }]
  }
]

The guide describes it as a way to "Automatically run Prettier on every file Claude edits." One difference the video does not draw: Prettier is a formatter. It rewrites the file and exits without producing a verdict. The noise he describes starts when you replace it with eslint, tsc --noEmit or a test command.

Do per-edit hooks waste tokens?

They do only when they fail. The hooks guide says of the Prettier example: "When the hook succeeds, Claude Code shows nothing in the conversation." A hook that exits zero and prints nothing adds nothing to the model's context.

Output reaches the model in three documented ways, and each requires the hook to report something:

  • Exit code 2 on a PostToolUse hook "Shows stderr to Claude; the tool already ran."
  • decision: "block" "adds the reason next to the tool result."
  • additionalContext is a "String added to Claude's context alongside the tool result."

So the token cost scales with failures, not edits. Pocock's point holds for a long refactor that leaves the code broken for many edits in a row, where each edit triggers a failing check. It does not hold for every edit.

Are there options between every edit and every commit?

There are, though the video presents only two. The hooks reference documents PostToolBatch, which "fires exactly once with the full batch" of parallel tool calls, "before Claude Code sends the next request to the model." That turns a burst of edits into one check.

The hooks guide also suggests the Stop event: "If your hook must see every file change, such as for compliance scanning or audit logging, add a Stop hook that scans the working tree once per turn." One check per agent turn runs less often than per edit and more reliably than per commit.

That matters because Pocock's approach depends on the agent committing. He says "you encourage your agent to commit and the moment it commits, it will send back the information to the agent." A Stop hook runs whether or not the agent commits. The docs note that Stop hooks "fire whenever Claude finishes responding, not only at task completion. They don't fire on user interrupts."

Do hooks slow Claude Code down?

Synchronous hooks do. Async hooks do not. The hooks reference says: "When an async hook fires, Claude Code starts the hook process and immediately continues without waiting for it to finish." When the background process exits, Claude Code delivers its additionalContext "to Claude on the next conversation turn."

An async lint hook adds no wait to the edit and still returns its result one turn later.

Command hooks also default to a 10-minute timeout, so the slowness comes from the check itself, not the hook system.

Is a three-second pre-commit hook realistic?

I found no source for the three-second figure in his skills repo, on aihero.dev, or in the Claude Code docs. Treat it as his personal target.

His own tooling sets a heavier default. His mattpocock/skills repo, described as "Skills for Real Engineers. Straight from my .agents directory," includes a setup-pre-commit skill that writes this .husky/pre-commit:

npx lint-staged
npm run typecheck
npm run test

The skill notes say "The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests." A full typecheck and test suite on a real project will rarely finish in three seconds. Keeping only lint-staged at commit time and moving typecheck and tests to CI would fit his stated budget.

Is Pocock against Claude Code hooks?

The title suggests so, but his published work splits hooks by purpose. His git-guardrails-claude-code skill "Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them," including git push, git reset --hard, git clean -f, git branch -D and git checkout ..

His aihero.dev post "How To Use Claude Code Hooks To Enforce The Right CLI," updated February 25, 2026, uses PreToolUse the same way, calling hooks a "deterministic solution" where an instruction in CLAUDE.md is "not deterministic." That post does not discuss lint, typecheck or tests in hooks.

The consistent position is PreToolUse hooks for actions that must never happen, pre-commit for checks that produce a verdict, and CI for slow checks.

Why pre-commit works in any agent

The agent runs git commit through its shell tool. Husky fails the commit, Git exits with an error, and the shell tool returns that output as an ordinary tool result. No Claude Code hook configuration is involved, so the approach works in any agent harness that can run shell commands.

Bottom line

Pocock's pre-commit approach is sound and works across agent tools. His case against per-edit hooks is overstated: passing hooks cost no tokens, async hooks add no delay, and PostToolBatch and Stop hooks batch checks without relying on the agent to commit. The three-second budget is his own heuristic, and his own pre-commit skill runs a full typecheck and test suite that will usually exceed it.

Sources

Published October 13, 2026. Based on a TikTok by @mattpocockuk. Full video notes (markdown)