diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..c14803f702 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,7 @@ +#!/bin/sh +# Prevent Claude Code from committing directly on the main branch. + +if [ -n "$CLAUDECODE" ] && [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ]; then + echo "error: Committing directly to the main branch is not allowed. Create a new branch and open a pull request instead." >&2 + exit 1 +fi diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100755 index 0000000000..6da87ff9e3 --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,8 @@ +#!/bin/sh +# Prevent Claude Code from amending commits. +# The prepare-commit-msg hook receives "commit" as $2 when --amend is used. + +if [ "$2" = "commit" ] && [ -n "$CLAUDECODE" ]; then + echo "error: Amending commits is not allowed. Create a new commit instead." >&2 + exit 1 +fi