husky-ai
v1.0.7
Published
Zero-config AI code review hook for git commits
Maintainers
Readme
🐶 Husky AI
Zero-config AI Code Reviewer for your git commits.
Husky AI automatically reviews your staged changes before you commit, catching bugs, security issues, and sloppy code using your favorite local AI engine (OpenCode, Claude, etc.).
✨ Features
- Zero Config: Auto-detects your installed AI tools.
- Auto-fix loop: Runs eslint/prettier/tsc (configurable), auto-formats on prettier failures, optional eslint --fix, then retries. AI fixes are left unstaged with a summary so you can review them.
- Resilient Reviews: Timeouts on AI fix/review calls, truncated large diffs, clear per-tool errors and reports.
- Detailed Reviews: "GitHub-style" comments with code snippets and line numbers.
- Focused Reviews: Reviews added/modified code only and avoids lint/format noise (those are handled by tools).
- Smart Gatekeeping: Blocks commits only for blocker-level issues; other findings are reported as non-blocking.
- Privacy First: Runs locally using your existing CLI tools. Your code goes only where your AI tool sends it.
🚀 Quick Start
1. Install & Init
Run this in your project root (we automatically install husky if you don't have it):
npx husky-ai initFollow the prompts to select your AI engine (e.g., OpenCode).
2. Commit
Just commit as usual!
git add .
git commit -m "feat: my new feature"Husky AI will intercept the commit, review the changes, and approve or reject it.
⚙️ Configuration
Your configuration is stored in package.json:
{
"huskyAi": {
"engine": "opencode",
"model": "optional-model-name",
"tools": ["eslint", "prettier", "tsc"],
"autoFix": true,
"autoFixPrettier": true,
"autoFixEslint": true,
"autoApplySafeFixes": true,
"applyRiskyFixes": false,
"fixTimeoutMs": 60000,
"reviewTimeoutMs": 90000,
"skipReviewOnFixFail": false,
"reportDir": "/path/to/reports",
"verbose": false
}
}Options:
engine(required): AI engine to use (opencode,claude,codex).model(optional): Model name for engines that support it.tools(optional): Checks to run (eslint,prettier,tsc). Defaults tonpm run lintif empty.autoFix(optional): Enables the AI auto-fix loop.autoFixPrettier(optional): Runsprettier --writewhen only prettier fails. Default true.autoFixEslint(optional): Runseslint --fixwhen only eslint fails. Default false.autoApplySafeFixes(optional): Applies AI fixes marked safe. Default true.applyRiskyFixes(optional): Applies AI fixes marked risky. Default false.fixTimeoutMs(optional): Timeout for AI fix calls.reviewTimeoutMs(optional): Timeout for semantic review calls.skipReviewOnFixFail(optional): Skip review if fix loop fails.reportDir(optional): Directory for reports and debug logs.verbose(optional): Writes debug logs toreportDir.
Notes:
- Set
verbose: trueto write debug logs (e.g., to/Users/<you>/reports/debug.log). autoFixEslintrunseslint --fixwhen eslint is the only failing tool; prettier auto-fix is on by default.- AI-applied fixes are left unstaged with a summary so you can review before committing.
fixTimeoutMs/reviewTimeoutMsguard AI calls; adjust if your model is slow.
Supported engines:
opencode(Recommended)claude(Coming soon)codex(Coming soon)
🤝 Contributing
Pull requests are welcome!
📄 License
MIT
