A minimal Husky pre-commit hook with AI-powered code review via Amp's Oracle feature.
- 🔮 AI Code Review: Optional Oracle review via Amp before committing
- 🧪 Test Validation: Runs all tests before allowing commit
- ⚡ Minimal & Fast: No unnecessary dependencies
- 🌍 Universal: Works with any Node.js project
-
Install Husky:
npm install --save-dev husky
-
Initialize Husky:
npx husky init
-
Replace the pre-commit hook:
# Copy the script content to .husky/pre-commit chmod +x .husky/pre-commit
Normal commit (with Oracle review):
git commit -m "your commit message"Skip Oracle review:
SKIP_ORACLE_REVIEW=true git commit -m "your commit message"- Runs Oracle review (if Amp CLI is available and not explicitly skipped)
- Executes all tests via
npm test - Prevents commit if tests fail
- Allows commit if all checks pass
- Node.js project with
npm testcommand configured - Optional: Amp CLI for Oracle reviews
- Husky for git hooks
Need environment variables? Add them safely:
export MY_VAR="safe_value"Need different test command? Replace npm test with:
yarn test
pnpm test
npm run test:ci