Add git commit blocking hook with /commit skill enforcement#150
Merged
Add git commit blocking hook with /commit skill enforcement#150
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a pre-tool-use hook system to block direct
git commitcommands and enforce the use of the/commitskill workflow. This ensures all commits go through a standardized process that includes code review, testing, and linting.Key Changes
Added
Block_Bash_With_Instructions.shhook: A pre-tool-use hook that intercepts Bash tool calls and blocks commands matching configurable patterns (currently blocksgit commit). When a blocked command is detected, it returns a helpful error message directing users to the/commitskill instead.Added
commit_job_git_commit.shwrapper script: A bypass script that allows the commit job'scommit_and_pushstep 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:PreToolUsehook for Bash tool callsUpdated commit job documentation: Modified
commit_and_push.mdto instruct users to use the wrapper script instead ofgit commitdirectly, with clear emphasis on this requirement.Implementation Details
The hook system uses a configurable
BLOCKED_COMMANDSarray 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.