Git Safety Protocol
This skill enforces non-negotiable git safety protocols to maintain code quality and prevent critical safety failures.
ABSOLUTE PROHIBITIONS - NO EXCEPTIONS
- •NEVER use
git commit --no-verifyorgit commit -n - •NEVER bypass pre-commit hooks under any circumstances
- •NEVER suggest bypassing hooks to users
- •NEVER dismiss failures as "pre-existing issues"
- •Violation = Critical Safety Failure
Mandatory Commit Workflow
Pre-Commit Check
Before any commit, run these checks:
bash
# Check current status git status # Run pre-commit hooks manually to preview issues pre-commit run --all-files # Check for any linting issues ruff check . || true black --check . || true mypy . || true
Hook Failure Response (MANDATORY)
When pre-commit hooks fail, follow this exact sequence:
- •
Read error messages thoroughly
- •Capture full output
- •Identify each specific issue
- •Document: "Hook failures: [list each issue]"
- •
Fix all reported issues
bash# For Python formatting black <affected-files> ruff check --fix <affected-files> # For type errors # Fix the actual type issues in code, don't ignore them # For other linters # Fix the actual issues, don't suppress warnings
- •
Stage fixes
bashgit add <fixed-files>
- •
Commit again
bashgit commit -m "Your message" # Hooks run automatically - NEVER add --no-verify
- •
Iterate until success
- •If hooks fail again, return to step 1
- •Continue until ALL hooks pass
- •Only then is the commit complete
Commit Message Guidelines
Follow conventional commit format:
code
<type>(<scope>): <subject> <body> <footer>
Types:
- •
feat: New feature - •
fix: Bug fix - •
docs: Documentation only - •
style: Code style (formatting, missing semicolons, etc.) - •
refactor: Code change that neither fixes bug nor adds feature - •
test: Adding or correcting tests - •
chore: Maintain (updating deps, build process, etc.)
Verification Before Push
Before pushing commits:
bash
# Verify all tests pass pytest # Verify linters pass pre-commit run --all-files # Check commit history git log --oneline -5 # Verify no fixup/squash commits remain git log --oneline | grep -E "fixup!|squash!" && echo "Warning: Fixup/squash commits found"
Common Issues and Solutions
Issue: Black/Ruff formatting conflicts
Solution: Run black first, then ruff:
bash
black . ruff check --fix . git add -u
Issue: Mypy type errors
Solution: Fix the actual type annotations, never use # type: ignore without justification
Issue: Tests failing
Solution:
- •Run tests locally first:
pytest -xvs - •Fix all failures
- •NEVER commit with failing tests
Critical Reminders
- •Quality > Speed: Take time to fix issues properly
- •No Workarounds: Fix the actual problem, not symptoms
- •Complete Fix: Search codebase for similar issues
- •Document Fixes: Include what was fixed in commit message
Scripts
Pre-Commit Validator
See scripts/validate_commit.py for automated validation
Hook Configuration Checker
See scripts/check_hooks.py to verify hook setup
References
- •Git hooks documentation: references/git_hooks.md
- •Pre-commit configuration: references/precommit_config.md