CLI Code Review powered by ChatGPT
Make sure you have at least Node18 and npx
in your path. You'll need an OpenAI API key to use this tool. You can set it up in two ways:
- Environment variable: Set
OPENAI_API_KEY
in your environment - Settings command: Use
aair settings --key YOUR_API_KEY
npm install -g auto-ai-review
The tool supports three different review modes:
Review changes that are currently staged in git:
aair review
Review one or more specific files, regardless of git status:
aair files path/to/file1.ts path/to/file2.ts
Review changes between branches (defaults to comparing against 'main'):
# Compare feature branch against main
aair branch feature-branch
# Compare between any two branches
aair branch feature-branch develop
Generate AI-powered commit messages for your staged changes:
aair commit
The tool will:
- Generate a commit message following best practices
- Show you the suggested message
- Allow you to edit it if needed (press Enter twice to finish editing)
- Ask for confirmation before creating the commit
The generated commit messages follow best practices:
- Brief summary line (max 50 chars)
- Detailed bullet points of key changes
- Focus on WHAT and WHY, not HOW
- Use imperative mood ("Add feature" not "Added feature")
The tool supports customizable settings that are stored in ~/.aair-settings.json
. You can manage these settings using the following commands:
aair settings --show
aair settings --key YOUR_API_KEY
aair settings --model MODEL_NAME
Default: gpt-4
aair settings --prompt "Your custom review prompt"
aair settings --commit-prompt "Your custom commit message prompt"
You can combine multiple settings in a single command:
aair settings --model gpt-4-turbo-preview --prompt "Your custom prompt"
Default settings:
- Model:
gpt-4
- Prompt: Basic code review prompt focusing on code quality
- Commit Prompt: Generates conventional commit messages with detailed descriptions
- API Key: Loaded from settings or environment variable
OPENAI_API_KEY
All settings are stored securely in ~/.aair-settings.json
.
- Review staged changes:
git add .
aair review
- Review specific files:
# Review a single file
aair files src/main.ts
# Review multiple files
aair files src/*.ts test/*.ts
- Review branch changes:
# Review feature branch against main
aair branch feature/new-feature
# Compare feature branch against develop
aair branch feature/new-feature develop
# Review changes in a PR branch
aair branch pr-123 main
- Generate commit messages:
# Stage your changes
git add .
# Generate commit message
aair commit
- Update settings:
# Set API key
aair settings --key your-api-key
# Change model and prompts
aair settings --model gpt-4-turbo-preview --commit-prompt "Focus on conventional commits"