Prefl.run

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)

npm install -g @preflight-ai/cli@latest

Project-Specific Installation

npm install --save-dev @preflight-ai/cli

🚀 Quick Start

1️⃣Initialize Prefl in Your Project

prefl init

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

prefl analyze --staged

Analyze staged files (default)

prefl analyze --all

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 init

prefl analyze [options]

Analyze code changes for issues

OptionDescriptionDefault
--stagedAnalyze only staged filestrue
--allAnalyze all project filesfalse
--output <file>Save results to file-
--fullFull project scan + report-
--format <type>pretty or jsonpretty
--auto-fixApply safe fixes automaticallyfalse

Examples:

prefl analyze --staged
prefl analyze --all --output report.txt
prefl analyze --format json

prefl fix [options]

Generate AI-powered fix suggestions

prefl fix --dry-run

Preview fixes without applying

prefl fix --apply

Auto-apply generated fixes

prefl hook [command]

Manage Git pre-commit hook

prefl hook install

Install hook

prefl hook uninstall

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:

prefl init

How It Works

  1. You stage files: git add .
  2. You attempt to commit: git commit -m "message"
  3. Prefl analyzes only staged files
  4. If critical issues → commit is blocked ❌
  5. If no critical issues → commit proceeds ✅

Disable Hook Temporarily

git commit --no-verify -m 'emergency fix'

🎯 Use Cases

1. Local Development

Catch issues while coding:

prefl analyze
prefl analyze --auto-fix

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:

prefl analyze --full

Creates prefl-report.md

🔐 Environment Variables

Required

GROQ_API_KEY

Your Groq API key. Get one free at console.groq.com

Optional

PREFL_MODEL

Override the default AI model

Default: llama-3.3-70b-versatile

PREFL_MAX_CONTEXT_FILES

Maximum 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

💬 Support