Skip to content

fix(hooks): correct PreToolUse if-condition syntax and add explicit settings defaults - #10

Merged
skateddu merged 1 commit into
mainfrom
fix/hook-if-syntax-and-explicit-settings
Jul 19, 2026
Merged

fix(hooks): correct PreToolUse if-condition syntax and add explicit settings defaults#10
skateddu merged 1 commit into
mainfrom
fix/hook-if-syntax-and-explicit-settings

Conversation

@skateddu

Copy link
Copy Markdown
Owner

Summary

  • Fixed enforce-uv.sh/protect-main.sh PreToolUse entries in .claude/settings.json: the if field combined multiple patterns in one string (Bash(python *)|Bash(pytest *)|...), which is not valid syntax (if holds exactly one permission rule, no ||/list syntax). The condition never matched, so both hooks silently stopped firing — including protect-main.sh's guardrails against force-push, direct push to main, hard resets, and broad rm -rf. Split into separate hook handler entries per pattern (8 for enforce-uv.sh, 2 for protect-main.sh).
  • Added permissions.defaultMode: "default" and CLAUDE_CODE_DISABLE_BUNDLED_SKILLS="0" explicitly, matching current Claude Code defaults, so they're visible and easy to customize. Documented permissions.disableAutoMode and language in the README instead, since neither has a neutral value that preserves default behavior when set explicitly.

Test plan

  • python -c "import json; json.load(open('.claude/settings.json'))" — valid JSON
  • Confirm protect-main.sh now blocks a force-push/hard-reset/broad rm -rf attempt in a live session
  • Confirm enforce-uv.sh still rewrites bare python/pytest/ruff calls to uv run ...

🤖 Generated with Claude Code

…ettings defaults

The enforce-uv.sh/protect-main.sh PreToolUse entries combined multiple
patterns in one `if` string (e.g. `Bash(python *)|Bash(pytest *)|...`).
Per code.claude.com/docs/en/hooks, `if` holds exactly one permission
rule with no `||`/list syntax, so the condition never matched and both
hooks silently stopped firing -- including protect-main.sh's guardrails
against force-push, direct push to main, hard resets, and broad
`rm -rf`. Split each pattern into its own hook handler entry.

Also add permissions.defaultMode: "default" and
CLAUDE_CODE_DISABLE_BUNDLED_SKILLS="0" explicitly, matching current
Claude Code defaults so they're visible and easy to customize.
permissions.disableAutoMode and language are documented in the README
instead, since neither has a neutral value that preserves default
behavior when set explicitly.
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.

1 participant