Skip to content

feat: add git-safety hook with tests and README docs#11

Open
shawndrake2 wants to merge 1 commit into
karanb192:mainfrom
shawndrake2:main
Open

feat: add git-safety hook with tests and README docs#11
shawndrake2 wants to merge 1 commit into
karanb192:mainfrom
shawndrake2:main

Conversation

@shawndrake2
Copy link
Copy Markdown

Summary

Adds a git-safety PreToolUse hook that blocks destructive git and gh CLI operations:

  • Force push protection — blocks git push --force (allows --force-with-lease)
  • Protected branch enforcement — prevents commits, merges, rebases, resets, and pushes on main/master
  • gh CLI guardrails — blocks gh pr merge, gh pr close, gh issue close, gh repo delete, and gh release delete

Also includes 379 lines of tests covering all patterns, branch-aware rules, and stdin/stdout integration.

Changes

  • hook-scripts/pre-tool-use/git-safety.js — the hook
  • hook-scripts/tests/pre-tool-use/git-safety.test.js — comprehensive test suite
  • README.md — added git-safety to hooks table, removed branch-guard from ideas (now implemented)

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