Skip to content

Add PreToolUse hook to enforce git -C pattern#397

Merged
bschwedler merged 1 commit intomainfrom
enforce-git-c-hook
Mar 26, 2026
Merged

Add PreToolUse hook to enforce git -C pattern#397
bschwedler merged 1 commit intomainfrom
enforce-git-c-hook

Conversation

@bschwedler
Copy link
Copy Markdown
Contributor

When committing in sibling repositories, Claude chains
"cd

&& git add" which doesn't match permission rules
like "Bash(git add:*)" — the entire string starts with "cd".
This triggers interactive permission prompts every time.

  • Add hook that blocks "cd && git ..." and instructs
    Claude to use "git -C ..." instead
  • Exclude .claude/settings.json from pretty-format-json
    pre-commit hook to preserve key ordering

@bschwedler bschwedler requested a review from ianpittwood as a code owner March 25, 2026 16:41
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

Test Results

1 229 tests  ±0   1 229 ✅ ±0   13m 15s ⏱️ -9s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 5845db5. ± Comparison against base commit 1969d25.

♻️ This comment has been updated with latest results.

When committing in sibling repositories, Claude chains
"cd <dir> && git add" which doesn't match permission rules
like "Bash(git add:*)" — the entire string starts with "cd".
This triggers interactive permission prompts every time.

- Add hook that blocks "cd <dir> && git ..." and instructs
  Claude to use "git -C <dir> ..." instead
- Exclude .claude/settings.json from pretty-format-json
  pre-commit hook to preserve key ordering
@bschwedler bschwedler added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit 060b591 Mar 26, 2026
16 checks passed
@bschwedler bschwedler deleted the enforce-git-c-hook branch March 26, 2026 20:26
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