Files
pnpm/.husky/pre-commit
Zoltan Kochan edbe1bcbf9 chore: add Husky hooks to prevent Claude Code from bad git practices (#10937)
- Adds two Husky hooks to prevent Claude Code from bad git practices:
  - \`prepare-commit-msg\`: blocks \`git commit --amend\` (detected via the \`commit\` source argument)
  - \`pre-commit\`: blocks committing directly to \`main\`
- Both hooks detect Claude Code sessions via the \`CLAUDECODE\` environment variable, so regular users are unaffected
- Error messages explicitly tell Claude what to do instead
2026-03-11 20:28:25 +01:00

8 lines
301 B
Bash
Executable File

#!/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