JSPM

  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q73723F
  • License Apache-2.0

Prefl AI code review CLI that analyzes staged changes using Groq.

Package Exports

  • @preflight-ai/cli
  • @preflight-ai/cli/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@preflight-ai/cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Prefl AI - Professional Code Review Tool ✨

AI-powered code review that catches bugs before they reach production

Website: prefl.run


🚀 Features

  • 🤖 AI-Powered Analysis - Deep semantic code review with Groq LLM (senior architect-level analysis)
  • 🐛 Production Bug Detection - Catches critical bugs that pass code review & testing but crash in production
  • đŸŽ¯ Smart Context Tracking - Analyzes related code and imports to maintain full context
  • 🚨 Critical Issue Detection - Identifies production-critical problems
  • 🌍 Multi-Language Support - Works with any programming language (JavaScript, Python, Go, Java, C#, Ruby, PHP, Rust, etc.)
  • ⚡ Lightning Fast - AI analysis in 2-5 seconds
  • đŸĒ Automatic Pre-commit Hook - Installs git pre-commit hook automatically on init

đŸ“Ļ Installation

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

đŸ› ī¸ Setup

1. Initialize in your project

cd your-project
prefl init

This will:

  • ✅ Create prefl.json config file
  • ✅ Create .env and ask for your GROQ API key
  • ✅ Add .env to .gitignore
  • ✅ Automatically install pre-commit hook (if git repository)

2. Get your Groq API Key

  1. Visit console.groq.com
  2. Create a free account
  3. Generate an API key
  4. Paste it when prompted during prefl init

đŸŽ¯ Usage

Automatic Review (Pre-commit Hook)

Once initialized, Prefl automatically reviews your code before every commit:

git add .
git commit -m "feat: add new feature"
# ✨ Prefl analyzes your changes automatically!

Manual Analysis

# Analyze staged changes (default)
prefl analyze

# Analyze entire project
prefl analyze --full

# Save results to prefl-log.txt
prefl analyze --output

Fix Issues

# Generate AI-suggested patch (saves to prefl-log.txt automatically)
prefl fix

# Apply the patch automatically
prefl fix --apply

# Validate patch without applying
prefl fix --dry-run

📊 How It Works

Prefl uses Groq AI to analyze your code like a professional code reviewer and tester:

  1. Analyzes staged files - Reviews the code you're changing
  2. Checks related context - Examines imports, dependencies, and connected files
  3. Tests mentally - Thinks through various scenarios and edge cases
  4. Finds issues - Identifies bugs, critical problems, and potential issues
  5. Reports findings - Provides detailed explanations and fix suggestions

Context-Aware Analysis

Prefl automatically:

  • Loads staged files (the code being changed)
  • Finds related files via imports and dependencies
  • Maintains full context to understand how code interacts with the rest of the system
  • Analyzes compatibility to ensure changes don't break related code

📋 Commands

prefl init                # Setup Prefl in your project (installs pre-commit hook automatically)
prefl analyze             # Analyze staged changes
prefl analyze --full      # Analyze entire project
prefl analyze --output    # Analyze and save results to prefl-log.txt
prefl fix                 # Generate AI-suggested patches (saves to prefl-log.txt)
prefl fix --apply         # Auto-apply generated fixes
prefl fix --dry-run       # Validate patch without applying
prefl --version           # Show version
prefl --help              # Show help

🎨 Example Output

🤖 Analyzing with AI (5 staged files + 12 related files for context)...
✨ Analysis complete! Found 3 issue(s)

📊 Code Review Results

🚨 Critical: 3 | âš ī¸  Warnings: 0 | â„šī¸  Info: 0
────────────────────────────────────────────────────────

🚨 CRITICAL ISSUES (Must Fix)

1. ⚡ Race Condition
   File:     src/payment.ts:45
   Issue:    Race condition: shared state modified in async function without locking.
             Multiple concurrent requests will corrupt balance data.
   Fix:      Use db.transaction() or mutex.lock() to ensure atomicity

2. 🔒 Security
   File:     src/api/user.ts:23
   Issue:    Missing authentication middleware on /admin/users endpoint.
             Anyone can access admin-only data.
   Fix:      Add requireAuth and requireAdmin middleware before handler

3. 🧮 Business Logic
   File:     src/utils.ts:89
   Issue:    Function returns undefined for non-premium users.
             Missing else branch causes caller code to break.
   Fix:      Add explicit return for all code paths

âš™ī¸ Configuration

Edit prefl.json in your project root:

{
  "ignore": {
    "globs": [
      "node_modules/**",
      "dist/**",
      ".git/**",
      "*.test.js",
      "coverage/**"
    ]
  },
  "review": {
    "blockSeverities": ["critical"],
    "context": {
      "importExpansionLimit": 50
    }
  }
}

Configuration Options

  • ignore.globs: Files/folders to skip (supports glob patterns)
  • review.blockSeverities: Which severity levels block commits (["critical"], ["critical", "warning"], or [])
  • review.context.importExpansionLimit: Max files to add via import tracking (default: 50)

🌟 Why Prefl?

Prefl uses AI to catch bugs that humans miss - issues that look correct in review, pass tests, but crash in production.

The AI analyzes:

  • Context - How code interacts with related files and dependencies
  • Edge cases - Boundary conditions, null checks, error handling
  • Security - Authentication, authorization, input validation
  • Business logic - Completeness, missing returns, undefined results
  • And more - Anything that could cause problems in production

🤝 Contributing

We welcome contributions! Please see our Contributing Guide.


📄 License

Apache 2.0 - See LICENSE for details


đŸ’Ŧ Support


Made with â¤ī¸ by developers, for developers