Skip to content

Add git commit blocking hook with /commit skill enforcement#150

Merged
nhorton merged 3 commits intomainfrom
claude/reliable-commit-job-iJrFp
Jan 24, 2026
Merged

Add git commit blocking hook with /commit skill enforcement#150
nhorton merged 3 commits intomainfrom
claude/reliable-commit-job-iJrFp

Conversation

@nhorton
Copy link
Contributor

@nhorton nhorton commented Jan 24, 2026

Summary

This PR implements a pre-tool-use hook system to block direct git commit commands and enforce the use of the /commit skill workflow. This ensures all commits go through a standardized process that includes code review, testing, and linting.

Key Changes

  • Added Block_Bash_With_Instructions.sh hook: A pre-tool-use hook that intercepts Bash tool calls and blocks commands matching configurable patterns (currently blocks git commit). When a blocked command is detected, it returns a helpful error message directing users to the /commit skill instead.

  • Added commit_job_git_commit.sh wrapper script: A bypass script that allows the commit job's commit_and_push step to perform actual git commits without triggering the block. This maintains the enforcement for regular tool use while enabling the automated workflow to function.

  • Updated .claude/settings.json:

    • Registered the new PreToolUse hook for Bash tool calls
    • Added permission for the commit job to execute the wrapper script
  • Updated commit job documentation: Modified commit_and_push.md to instruct users to use the wrapper script instead of git commit directly, with clear emphasis on this requirement.

Implementation Details

The hook system uses a configurable BLOCKED_COMMANDS array with regex patterns and instructions. This makes it easy to add additional blocked commands in the future. The hook only processes Bash tool calls and safely handles edge cases like missing input or non-matching commands by allowing them through.

The wrapper script approach allows the commit job to bypass the restriction while maintaining the enforcement for interactive use, creating a clear separation between automated and manual workflows.

Add a PreToolUse hook that intercepts Bash commands and blocks direct
git commit usage, directing users to use the /commit skill instead.
This ensures all commits go through the proper workflow with code review,
testing, and linting.

Changes:
- Add Block_Bash_With_Instructions.sh hook with configurable blocked commands
- Add commit_job_git_commit.sh wrapper for the commit job to bypass the block
- Register the hook in settings.json
- Update commit_and_push.md to use the wrapper script
@nhorton nhorton merged commit a52eb60 into main Jan 24, 2026
4 checks passed
@nhorton nhorton deleted the claude/reliable-commit-job-iJrFp branch January 24, 2026 19:03
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