Sign in
Explore
Add-ons · HookEveryday codingReviewedRuns shell commands

git/prevent-direct-push

Blocks git pushes to main or develop, so changes go through feature branches and pull requests.

Kind
Hook
Works with
Claude Code
Source
Claude Code Templates @ 72e5f237f64d
Path
cli-tool/components/hooks/git/prevent-direct-push.json
License
MIT
Jobs
Git workflow, Guardrails
InstallInstall it by hand, following the source.
{
  "description": "Prevent direct pushes to protected branches (main, develop). Blocks git push commands targeting main or develop branches to enforce Git Flow workflow. Requires using feature/release/hotfix branches and pull requests instead of direct commits to protected branches.",
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/prevent-direct-push.py"
          }
        ]
      }
    ]
  }
}