A powerful pre-commit quality validation tool that ensures your code meets quality and security standards before it’s committed.
Overview
Pre-Commitator is designed to detect code quality and security issues at the earliest possible point in development - before code is committed to your repository. It’s particularly useful for validating AI-generated code and ensuring all code contributions meet your project’s quality standards.
Security Note: Pre-Commitator uses only verified, trusted sources for all dependencies. All tools are from official repositories (PyPI, npm) and well-established organizations like PSF (Black), PyCQA (Bandit, Flake8), and r2c (Semgrep).
Features
✅ Multiple Language Support: Fully supports Python, JavaScript, and TypeScript, with architecture ready for other languages
⚡ Fast Execution: Only scans files staged for commit or specific files you select
🧠 AI-Friendly: Provides clear error messages that both humans and AI can understand
# Interactive installation (recommended for first-time users)
./install.sh
# Non-interactive installation
./install.sh -y# Installation with detailed output
./install.sh -v
The installer will:
Install required Python dependencies
Set up pre-commit hooks
Configure the tool for immediate use
Ask if you want to use VS Code mode or terminal mode
Basic Usage
# Check staged files (files about to be committed)
./run_quality_check.sh
# Check specific files
./run_quality_check.sh path/to/file1.py path/to/file2.js
# Check all files in the repository
./run_quality_check.sh --all# Get help
./run_quality_check.sh --help# Switch between VS Code and terminal modes
./switch_mode.sh vscode # For VS Code users (disables problematic validators)
./switch_mode.sh terminal # For terminal users (enables all validators)
These environment variables are automatically set by the switch_mode.sh script based on the selected mode. In VS Code mode, these validators are disabled to prevent issues with SSL certificates and command not found errors.
Auto-Stage Feature
Pre-Commitator includes an auto-stage feature that automatically stages files modified by pre-commit hooks:
# Install the auto-stage hook
./src/auto_stage_hook.sh
This feature addresses a common pain point where pre-commit hooks fix issues (like trailing whitespace) but require you to manually stage these changes before committing again.
With the auto-stage hook enabled:
Pre-commit hooks run and may modify files
Modified files are automatically staged
You only need to run git commit once more to complete the commit
Using with AI-Generated Code
Pre-Commitator works exceptionally well with AI coding assistants:
Generate code with your AI assistant
Save the code to a file
Run ./run_quality_check.sh filename to validate
If issues are found, ask the AI to fix based on the specific error messages
Re-run validation until all issues are resolved
Troubleshooting
Common Issues
Q: The pre-commit hook isn’t running when I commit. A: Make sure you’ve installed pre-commit hooks with pre-commit install or by running the installer.
Q: I get “command not found” errors. A: Ensure all dependencies are installed. Run ./install.sh again.
Q: How do I temporarily bypass checks? A: Use git commit --no-verify (not recommended for production code).
Q: Pre-commit hook fixes issues but I have to manually stage the fixed files before committing again. A: Install the auto-stage hook: ./src/auto_stage_hook.sh. This will automatically stage files modified by pre-commit hooks.
Q: I get SSL certificate errors like [SSL: CERTIFICATE_VERIFY_FAILED] when installing eslint environment or running other pre-commit hooks. A: This is a common issue on macOS with Python’s SSL certificate verification. You have three options:
Run ./fix_certificates.sh or ./fix_certificates_unix.sh to fix Python SSL certificate verification
This creates a temporary SSL context fix and sets PYTHONPATH environment variable
Set PYTHONPATH manually: export PYTHONPATH=/path/to/pre-commitator
Switch to VS Code mode: ./switch_mode.sh vscode (disables problematic validators that require network access)
The VS Code mode option is the most reliable solution as it completely bypasses the certificate validation issues.
Q: I see a warning about “pre-commit’s script is installed in migration mode”. A: This happens when multiple pre-commit hooks are installed. Fix it with:
pre-commit uninstall
pre-commit install-f
./switch_mode.sh vscode # Or terminal, depending on your preference
Q: How do I install Horusec? A: Horusec installation is handled by the ./src/install_horusec.sh script, which will be called when you run ./switch_mode.sh. If installation fails, Horusec hooks will be skipped without breaking other validations.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.