Overview
The Zenable pre-commit hook automatically checks your code against organizational policies before each commit, preventing policy violations from entering your codebase. This ensures consistent code quality and compliance across your entire development team.Quick Start
1
Install UV
2
Configure pre-commit
Add to your
.pre-commit-config.yaml:3
Install the hook
Run this one-time setup in your repository:This installs the pre-commit hook into your local git repository.
All-in-one setup: After installing UV, you can run everything with:
How It Works
When you commit code, the pre-commit hook:- Intercepts the commit before it’s finalized
- Checks changed files against your configured policies
- Reports violations with specific line numbers and fix suggestions
- Blocks the commit if violations are found (configurable)
- Allows the commit once all issues are resolved
Example Workflow
When issues are found, the commit is blocked:Common Use Cases
Security Policies
Prevent security vulnerabilities:Code Quality
Enforce quality standards:Compliance Requirements
Ensure regulatory compliance:Troubleshooting
Hook not running?
Hook not running?
Ensure the hook is installed:
Bypassing the hook temporarily?
Bypassing the hook temporarily?
In emergencies, you can bypass:⚠️ Use sparingly - this defeats the purpose of policy enforcement
Updating the Hook
Keep your policies current:Best Practices
- Start gradually - Begin with warnings before enforcing. Review our deployment guide for proven adoption strategies
- Run manually first - Test with
pre-commit run --all-files - Keep hooks fast - Use file filters to check only relevant files
- Update regularly - Run
pre-commit autoupdatemonthly via scheduled pipelines - Document exceptions - Make policy exceptions visible and temporary
- Provide context - Help developers understand why policies exist
- Be Automation-first - See starting new projects to see how you can have pre-commit hooks automatically configured from the first commit
Comparison with Other Tools
| Feature | Zenable Pre-commit | Traditional Linters | SAST Tools |
|---|---|---|---|
| Policy customization | ✅ Natural language | ❌ Code rules only | ❌ Fixed rules |
| Setup complexity | Simple | Moderate | Complex |
| Speed | Fast | Fast | Slow |
| AI-powered fixes | ✅ | ❌ | ❌ |
| Cross-language | ✅ | ❌ Per-language | ✅ |
| Policy-as-code | ✅ | ❌ | Partial |
Next Steps
- Configure the IDE integration for real-time feedback
- Set up GitHub or GitLab integrations for pull request checks
- Define custom policies for your organization
- Explore advanced use cases