Preflight AI Documentation
AI-powered code review tool that catches bugs before they reach production. Powered by Groq's real-time intelligence.
📦 Installation
Global Installation (Recommended)
Project-Specific Installation
🚀 Quick Start
1️⃣Initialize Prefl in Your Project
This will:
- Create .env file with your Groq API key
- Generate prefl.json configuration
- Install pre-commit Git hook automatically
2️⃣Run Your First Analysis
Analyze staged files (default)
Analyze all files
3️⃣Start Committing with Confidence
git add . git commit -m "feat: add new feature" # ✨ Prefl automatically runs before commit!
⚡ Commands
prefl init
Initialize Prefl in your project
prefl analyze [options]
Analyze code changes for issues
| Option | Description | Default |
|---|---|---|
| --staged | Analyze only staged files | true |
| --all | Analyze all project files | false |
| --output <file> | Save results to file | - |
| --full | Full project scan + report | - |
| --format <type> | pretty or json | pretty |
| --auto-fix | Apply safe fixes automatically | false |
Examples:
prefl fix [options]
Generate AI-powered fix suggestions
Preview fixes without applying
Auto-apply generated fixes
prefl hook [command]
Manage Git pre-commit hook
Install hook
Remove hook
⚙️ Configuration
Edit prefl.json in your project root:
{
"ignore": {
"globs": [
"**/node_modules/**",
"**/dist/**",
"**/*.test.js"
]
},
"review": {
"showSeverities": ["critical", "warning"],
"blockSeverities": ["critical"]
}
}ignore.globs
Array of glob patterns to exclude from analysis
review.blockSeverities
Which severity levels should block commits:["critical"],["critical", "warning"], or[]
🪝 Git Hook Integration
Prefl automatically runs before every commit to catch issues early.
Automatic Installation
The pre-commit hook is installed automatically when you run:
How It Works
- You stage files:
git add . - You attempt to commit:
git commit -m "message" - Prefl analyzes only staged files
- If critical issues → commit is blocked ❌
- If no critical issues → commit proceeds ✅
Disable Hook Temporarily
🎯 Use Cases
1. Local Development
Catch issues while coding:
2. CI/CD Pipeline
Integrate into your CI workflow:
name: Code Review
on: [push, pull_request]
jobs:
prefl:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install -g @preflight-ai/cli
- run: prefl analyze --all --format json
env:
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}3. Team Code Reviews
Generate detailed reports for team discussions:
Creates prefl-report.md
🔐 Environment Variables
Required
GROQ_API_KEYYour Groq API key. Get one free at console.groq.com
Optional
PREFL_MODELOverride the default AI model
Default: llama-3.3-70b-versatile
PREFL_MAX_CONTEXT_FILESMaximum number of context files to analyze
Default: 5
💡 Examples
Example 1: First-Time Setup
# Install globally npm install -g @preflight-ai/cli # Navigate to your project cd my-awesome-project # Initialize prefl init # Enter your Groq API key when prompted # Done! Now commits are automatically reviewed git add . git commit -m "feat: new feature"
Example 2: Fix Issues Automatically
# Preview fixes prefl fix --dry-run # Apply safe fixes prefl fix --apply # Verify changes git diff
❓ FAQ
What languages are supported?▼
Prefl supports all programming languages, including JavaScript, TypeScript, Python, Java, Go, C/C++, PHP, Ruby, Rust, and more. No configuration needed!
How is this different from ESLint?▼
ESLint uses static rules. Prefl uses AI to understand your code's context, logic, and business rules.
It catches race conditions, memory leaks, and production bugs that pass code review — issues that rule-based tools can't detect.
Best Practice: Use both! ESLint for syntax/style, Prefl for semantic issues.
Is my code sent to external servers?▼
Only changed files are sent to Groq's API for analysis. Your code is not stored, trained on, or shared. Groq is SOC2 compliant and enterprise-ready.
How much does Groq API cost?▼
Groq offers a generous free tier suitable for most developers. Check pricing at groq.com/pricing