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 initThis will:
- â
Create
prefl.jsonconfig file - â
Create
.envand ask for your GROQ API key - â
Add
.envto.gitignore - â Automatically install pre-commit hook (if git repository)
2. Get your Groq API Key
- Visit console.groq.com
- Create a free account
- Generate an API key
- 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 --outputFix 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:
- Analyzes staged files - Reviews the code you're changing
- Checks related context - Examines imports, dependencies, and connected files
- Tests mentally - Thinks through various scenarios and edge cases
- Finds issues - Identifies bugs, critical problems, and potential issues
- 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
- đ Website: prefl.run
- đ§ Email: support@prefl.run
- đ Issues: GitHub Issues
Made with â¤ī¸ by developers, for developers