Skip to content

fix(pre-tool-use): normalize git flags in dangerous pattern detection #184

Closed

Description

@danielvm-git

Problem

In hooks/pre-tool-use.sh, DANGEROUS_PATTERNS matches exact literal strings (e.g. "git reset --hard"). Commands that include intermediate flags or alternative syntax (e.g., git reset -q --hard, git checkout -- ., or git -C <dir> reset --hard) can bypass literal substring matching.

Proposed Solution

Update hooks/pre-tool-use.sh to use regex token matching with optional flag allowances:

  • Match git followed by optional global flags, then subcommand and arguments (git.*reset.*--hard, git.*checkout.*(\.|\-\-)).
  • Ensure destructive actions are intercepted consistently across Claude Code, Cursor, and Gemini CLI modes.

Affected Files

  • hooks/pre-tool-use.sh
  • skills/guard-git/SKILL.md

Activity

  1. added
    bug
    on Nov 2, 2026
  2. added a commit that references this issue on Nov 3, 2026
  3. github-actions commented on Nov 3, 2026

    @github-actions

    🎉 This issue has been resolved in version 2.91.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions