Created
August 27, 2025 20:59
-
-
Save karlbunch/b66ae29cd3a0c71080549836acfef4c7 to your computer and use it in GitHub Desktop.
keep q from doing commits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Pre-commit hook to prevent AI commits | |
| # Check if any ancestor process is qchat (walk up the process tree) | |
| current_pid=$$ | |
| while [ "$current_pid" -ne 1 ] && [ -n "$current_pid" ]; do | |
| exe=$(readlink /proc/$current_pid/exe 2>/dev/null || echo "") | |
| if [[ "$exe" == *"qchat"* ]]; then | |
| echo "ERROR: AI commit blocked - running under qchat" | |
| echo "" | |
| echo "This appears to be an AI session. Commits require human approval." | |
| echo "To commit as a human:" | |
| echo " Exit qchat and run: git commit ..." | |
| echo "" | |
| echo "Or to allow this specific commit:" | |
| echo " ALLOW_AI_COMMIT=1 git commit ..." | |
| # Allow override with explicit flag | |
| if [ "$ALLOW_AI_COMMIT" != "1" ]; then | |
| exit 1 | |
| fi | |
| echo "WARNING: AI commit allowed by ALLOW_AI_COMMIT flag" | |
| break | |
| fi | |
| # Move to parent process | |
| parent_pid=$(cut -d ' ' -f4 /proc/$current_pid/stat 2>/dev/null) | |
| if [ -z "$parent_pid" ] || [ "$parent_pid" = "$current_pid" ]; then | |
| break | |
| fi | |
| current_pid=$parent_pid | |
| done | |
| # Continue with normal pre-commit checks | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment