Skip to content

feat: add Claude hooks for pre-commit quality gates#3701

Merged
dotNomad merged 1 commit intomainfrom
dotnomad/claude-hook
Mar 11, 2026
Merged

feat: add Claude hooks for pre-commit quality gates#3701
dotNomad merged 1 commit intomainfrom
dotnomad/claude-hook

Conversation

@dotNomad
Copy link
Collaborator

@dotNomad dotNomad commented Mar 11, 2026

Summary

  • Adds two Claude hooks (.claude/settings.json) to automate quality checks that were previously manual:
    • PostToolUse hook: Runs prettier --write on every file after Edit or Write operations
    • PreToolUse hook: Gates git commit commands by inspecting staged files and conditionally running esbuild, eslint, vitest, and webview build checks
  • Adds .claude/hooks/pre-commit-checks.sh implementing the commit gate logic with dependency guards and staged-file detection
  • Removes the manual "Pre-Commit Checks" section from CLAUDE.md since hooks now enforce this automatically

Test plan

Locally tested the different flows:

  • verified commands that were not git commit passed through immediately with no extra prompting
  • verified git commit skipped checks if it was Go code only
  • verified that the filtering on the changed files worked
    • extensions/vscode/src/ triggers esbuild, lint, and unit tests
    • Vue files in webviews triggers webview build and lint
  • if node_modules weren't installed which is common when using a worktree the message is clear and actionable for Claude to continue
  • prettier gets run on all file edits using --ignore-unknown to avoid files Prettier doesn't support just like we do in the package.json npm script

Add two Claude hooks to automate quality checks:
- PostToolUse hook runs prettier on every edited file
- PreToolUse hook gates git commits by running esbuild, eslint,
  vitest, and webview build based on which files are staged

Remove the manual Pre-Commit Checks section from CLAUDE.md since
the hooks now enforce this automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dotNomad dotNomad requested a review from a team as a code owner March 11, 2026 21:27
Copy link
Collaborator

@christierney christierney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good stuff!

@dotNomad dotNomad merged commit 11abfda into main Mar 11, 2026
51 of 52 checks passed
@dotNomad dotNomad deleted the dotnomad/claude-hook branch March 11, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants