AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Nov 6, 2026, 19:01 JST

Claude Code commit size: pre-commit hook beats CLAUDE.md

Send on LINE
Claude Code commit size: pre-commit hook beats CLAUDE.md

3 Key Points

  1. What happened

    With no guard, Claude Code produced single commits of 298 and 426 lines; the pre-commit hook split both runs into six commits (max 76 and 80 lines) and refused the over-limit first attempt.

  2. Why it matters

    A hard external check reliably kept each commit small, whereas a soft written instruction only set the default habit and lost when a direct request conflicted.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

By signing up you agree to the Terms of Service and Privacy Policy.

Context & Analysis

The test set up a repository with five identical modules under src/ and asked Claude Code to add input validation, error handling, and node:test tests to all of them, then commit once npm test passed. Two guard mechanisms were compared: a CLAUDE.md rule capping each commit at 100 changed lines, and a git pre-commit hook that rejects any commit over that limit. Without either guard, the first attempt landed as a single 298-line commit and the second as a 426-line commit.

The difference showed up when the request itself changed. With the written CLAUDE.md instruction, Claude Code split the work into six commits by default, but when the prompt explicitly said to put everything into one commit, one run produced a 139-line commit and explained that it prioritized the direct instruction. The pre-commit hook, by contrast, rejected the initial bulk commit in both runs and Claude Code then re-split the work on its own; when told to make one commit, it stopped without committing and asked the user to decide, and it never used --no-verify to bypass the check. The hook is an external check outside Claude Code's own settings, so it does not depend on the model following a written rule.

Even with smaller commits, the total diff for the pull request stayed in the 304–427 line range, unchanged from the no-guard runs. Shrinking the PR itself would require a smaller initial request, a pre-push hook measuring the diff against main, or a CI check on PR size; none of those were tested. The author also notes each condition was run only twice on an easily divisible subject, so results could differ for changes that are hard to split, such as a large rewrite of a single file.

FAQ
Did the pre-commit hook ever get bypassed with --no-verify?
No. Zero uses of --no-verify occurred across the hook runs.
Does splitting commits make the pull request smaller?
No. The total stayed at 304–427 lines, the same as doing nothing; PR-level limits would need a separate check.
What did Claude Code do when the hook rejected a commit?
It stopped without committing, kept changes staged, and asked the user to choose how to proceed.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

By signing up you agree to the Terms of Service and Privacy Policy.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleNasdaq 100 sheds record $2.3 trillion as chip rout deepens