-
Notifications
You must be signed in to change notification settings - Fork 1
BLOCKING_NO_VERIFY
Problem: AI agents (like GitHub Copilot Agent Mode) can bypass pre-commit hooks using git commit --no-verify, allowing commits with failing tests.
Goal: Prevent --no-verify from being used by agents while keeping it available for emergency human overrides.
Pre-commit hooks enforce:
- ✅ All tests must pass (351 backend + 260 frontend + 36 E2E = 100%)
- ✅ Code formatting (Black, Prettier)
- ✅ Linting (Ruff, ESLint)
- ✅ Security checks (Bandit)
- ✅ Conventional commit format
Using --no-verify bypasses ALL of this → broken commits in history.
Create a Git alias that replaces git commit with a wrapper script that refuses --no-verify.
File: .git/hooks/commit-wrapper.sh
#!/bin/bash
# Git commit wrapper that blocks --no-verify
# Check if --no-verify is in arguments
for arg in "$@"; do
if [[ "$arg" == "--no-verify" || "$arg" == "-n" ]]; then
echo "❌ ERROR: --no-verify is STRICTLY FORBIDDEN"
echo ""
echo "Pre-commit hooks exist for a reason:"
echo " - Ensures ALL tests pass (Backend + Frontend + E2E)"
echo " - Validates code formatting and linting"
echo " - Prevents security issues"
echo ""
echo "If hooks fail:"
echo " 1. Fix the actual problem (failing tests, format, etc.)"
echo " 2. Do NOT bypass hooks"
echo ""
echo "For emergency human override (HUMANS ONLY):"
echo " Use: git-commit-force-override (see docs/GIT_HOOKS.md)"
exit 1
fi
done
# All good - run normal git commit
exec git commit "$@"PowerShell:
# Git Bash required for executable permission
git update-index --chmod=+x .git/hooks/commit-wrapper.shFile: .gitconfig (in repository root)
[alias]
# Override 'git commit' with wrapper that blocks --no-verify
commit = !bash .git/hooks/commit-wrapper.sh
# Emergency override for HUMAN use only
commit-force-override = commit --no-verifygit config --local include.path ../.gitconfigNow:
- ✅
git commit -m "..."→ Uses wrapper (blocks --no-verify) - ❌
git commit --no-verify→ Blocked with error message - 🚨
git commit-force-override -m "..."→ Emergency human override (logged in docs)
If using a Git server (GitHub, GitLab, Gitea), add server-side pre-receive hook.
File: .git/hooks/pre-receive (on Git server)
#!/bin/bash
# Server-side hook - cannot be bypassed by --no-verify
while read oldrev newrev refname; do
# Get list of commits being pushed
commits=$(git rev-list $oldrev..$newrev)
for commit in $commits; do
# Check if commit message contains bypass marker
message=$(git log -1 --pretty=%B $commit)
if [[ "$message" == *"--no-verify"* ]]; then
echo "❌ PUSH REJECTED: Commit $commit was created with --no-verify"
echo "This is strictly forbidden. Please fix locally and force-push."
exit 1
fi
done
done
exit 0Limitation: Only works if you control the Git server.
Restrict Git operations in VS Code for AI agents.
File: .vscode/settings.json
{
"git.allowNoVerifyCommit": false,
"git.confirmNoVerifyCommit": true,
"github.copilot.chat.allowCommitWithoutHooks": false,
"github.copilot.chat.requireTestsBeforeCommit": true
}Limitation: VS Code AI agents may not respect these settings (experimental).
Add to $PROFILE (PowerShell profile):
File: C:\Users\<YourUser>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
# Override git command to block --no-verify
function git {
$args_string = $args -join ' '
# Check if commit command contains --no-verify
if ($args[0] -eq 'commit' -and ($args_string -like '*--no-verify*' -or $args_string -like '*-n *')) {
Write-Host "❌ ERROR: --no-verify is STRICTLY FORBIDDEN" -ForegroundColor Red
Write-Host ""
Write-Host "Pre-commit hooks ensure:"
Write-Host " - All tests pass (Backend + Frontend + E2E)"
Write-Host " - Code is formatted and linted"
Write-Host " - Security checks pass"
Write-Host ""
Write-Host "If hooks fail: Fix the problem, don't bypass!"
Write-Host ""
Write-Host "Emergency override: git-real commit --no-verify (HUMANS ONLY)"
return
}
# Normal git command
& "C:\Program Files\Git\bin\git.exe" @args
}
# Alias for emergency human override
function git-real {
& "C:\Program Files\Git\bin\git.exe" @args
}Reload Profile:
. $PROFILENow in PowerShell:
- ✅
git commit -m "..."→ Allowed - ❌
git commit --no-verify→ Blocked - 🚨
git-real commit --no-verify→ Emergency override
The .pre-commit-config.yaml now includes:
- id: all-tests-must-pass
name: "🚨 MANDATORY: Run ALL tests - 100% must pass"
entry: bash -c 'npm test'
language: system
pass_filenames: false
always_run: true
stages: [pre-commit]This hook:
- Runs on EVERY commit attempt
- Executes full test suite (Backend + Frontend + E2E)
- Blocks commit if ANY test fails
- Can be bypassed by
--no-verify⚠️ (hence need for solutions above)
Layer 1: Pre-commit hook (catches 99% of issues)
Layer 2: PowerShell function override (blocks --no-verify in terminal)
Layer 3: Git alias wrapper (blocks --no-verify in Git directly)
Layer 4: Server-side hook (final safety net)
Apply ALL layers for maximum protection against accidental bypasses.
If you absolutely must commit without hooks (e.g., fixing broken hooks):
-
Document reason in commit message:
git commit-force-override -m "fix(hooks): repair broken pre-commit hook EMERGENCY OVERRIDE REASON: Pre-commit hook itself is broken and prevents all commits. This commit fixes the hook. Tests verified manually."
-
Log in team chat that override was used
-
Fix issue immediately in next commit
-
Never use for "tests are failing" - fix tests instead!
Check recent commits:
# Show commits that bypassed hooks (heuristic - checks for missing hook markers)
git log --all --oneline --no-merges | head -20Verify commit has hook signatures:
# Pre-commit hooks should have added formatting changes
git show <commit-hash> --stat | grep -E "(black|prettier|ruff)"If commit lacks hook evidence:
- Likely bypassed with
--no-verify - Investigate with
git log -p <commit-hash>
| Solution | Effectiveness | Complexity | Recommended |
|---|---|---|---|
| 1. Git Alias Wrapper | 🟢 High | Medium | ✅ Yes |
| 2. Server-Side Hook | 🟢 Perfect | High | ✅ If you control server |
| 3. VS Code Settings | 🟡 Experimental | Low | |
| 4. PowerShell Override | 🟢 High | Low | ✅ Yes (Windows) |
| 5. Pre-Commit Hook | 🟡 Medium | Low | ✅ Already done |
- Prevent accidental bypasses (especially by AI agents)
- Make intentional bypasses obvious (logged, documented)
- Educate team that bypassing hooks is serious policy violation
Add to AGENTS.md:
### GIT COMMITS - ABSOLUTE PROHIBITIONS
**❌ VERBOTEN - NEVER USE:**
```bash
git commit --no-verify
git commit -nWhy: Pre-commit hooks enforce test quality. Bypassing = broken commits.
If hooks fail:
- Fix the actual problem (failing tests, format errors)
- Do NOT look for workarounds
- Do NOT use --no-verify
Consequence: Commits bypassing hooks will be reverted immediately.
---
**Last Updated:** 2026-02-13
**Enforcement Level:** 🔴 CRITICAL - Zero tolerance for violations
🇩🇪 Benutzerhandbuch
🇬🇧 User Guide
Development
API & Architecture
- REST API
- ADR 001 Clean Architecture
- ADR 002 FastAPI App State
- ADR 003 SSDP Discovery
- ADR 004 React/TS/Vite
Technical Reference
Legal