fix(git-guards): replace 'branch' with 'worktree' in error messages#191
fix(git-guards): replace 'branch' with 'worktree' in error messages#191JacobPEvans merged 3 commits intomainfrom
Conversation
Claude interprets 'main branch' literally and creates a git branch instead of a worktree. Use 'main worktree' consistently in all user-facing error messages. (claude)
There was a problem hiding this comment.
Pull request overview
This PR updates the user-facing deny reasons emitted by the main-branch-guard hooks to prefer “main worktree” terminology, aiming to steer users/Claude toward creating Git worktrees instead of creating branches when edits are blocked.
Changes:
- Updated deny message when the file is detected under a
main/worktree directory to say “main worktree”. - Updated deny message for the fallback “on main” detection path to also say “main worktree” (in both shell and Python implementations).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| git-guards/scripts/main-branch-guard.sh | Adjusts permissionDecisionReason strings to say “main worktree” |
| git-guards/scripts/main-branch-guard.py | Adjusts permissionDecisionReason strings to say “main worktree” |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request updates the error messages in both the Python and Shell versions of the main branch guard script to use 'main worktree' terminology instead of 'main branch'. The review feedback suggests including the specific file path in all error messages for better context and consistency across the scripts. Additionally, it was noted that these hooks should exit with code 0 when returning a JSON payload, even for 'deny' decisions.
Add file path to the branch-name fallback check for consistency with the worktree directory check. Both error messages now show the blocked file. (claude)
(claude)
Summary
Replace "main branch" with "main worktree" in error messages to clarify terminology and prevent Claude from misinterpreting the guard's intent. Users were creating git branches instead of worktrees when blocked by the guard, indicating confusion about whether "main branch" meant the branch name or the literal main worktree directory.
Changes
All changes are user-facing error messages only — no logic changes.
Test Plan
main/worktree