ai-code-reviewer-cli

1.3.4 • Public • Published

📦 AI Code Review CLI Tool

A command-line interface (CLI) tool designed to automate code reviews using AI, helping developers quickly identify potential issues, optimize performance, and maintain code quality.

中文


🚀 Features

  • AI-Powered Code Review: Analyze code differences (diff) to identify potential bugs, performance issues, and security risks.
  • Interactive Mode: Engage with AI in an interactive code review session.
  • Custom Prompt Templates: Support for custom prompt templates to fit various review needs.
  • Cache Management: Easily clear cached data to maintain updated settings.
  • Code Quality Metrics: Provide code quality scores based on AI analysis to quickly assess code health.
  • Git Integration: (Coming Soon) Automatically post review comments to Pull Requests and integrate with CI/CD workflows.

⚙️ Installation

1️⃣ Global Installation via NPM

npm install -g ai-code-reviewer-cli

2️⃣ Verify Installation

ai-review --help

3️⃣ Environment Variable Setup

This tool requires an OpenAI API key provided via environment variables:

export OPENAI_KEY=your_openai_api_key

Or configure it in a .env file:

OPENAI_KEY=your_openai_api_key

📖 Usage

🔍 1. Run Code Review

Perform code reviews using AI:

ai-review review --from HEAD~1 --to HEAD

Optional Parameters:

  • --from <commit>: Specify the starting commit for the diff (default: HEAD~1)
  • --to <commit>: Specify the ending commit for the diff (default: HEAD)
  • --exclude <paths...>: Override default exclusion rules (comma-separated paths)
  • --show-diff: Display the diff data sent to AI
  • --prompt-template <templateName>: Use a specific prompt template
  • --show-quality-score: Display AI-analyzed code quality scores

🤖 2. Interactive Mode

Start an interactive code review session with AI:

ai-review interactive

🗑️ 3. Clear Cache

Clear cached data to ensure the latest settings are loaded:

ai-review clear-cache

📊 4. Code Quality Metrics

Display code quality scores in the review results:

ai-review review --show-quality-score

These metrics assess code readability, maintainability, potential issues, and performance.

🔗 5. Git Integration

⚠️ This feature is under development. Stay tuned!

Automatically post review comments to Pull Requests (planned support for GitHub/GitLab):

ai-review review --git-integration

Can be automated in CI/CD workflows to ensure consistent code quality.


🛠️ Development Guide

Build the Project

npm run build

Package as an Executable

npm run pkg

Troubleshooting

  • Permission Issues: Ensure the file has execute permissions (chmod +x).
  • Cache Issues: Use the clear-cache command to reset the cache.
  • Missing Environment Variables: Verify that OPENAI_KEY is correctly configured.
  • Deprecation Warnings: Deprecation warnings are suppressed by default.

📄 License

ISC License


Package Sidebar

Install

npm i ai-code-reviewer-cli

Weekly Downloads

0

Version

1.3.4

License

ISC

Unpacked Size

188 MB

Total Files

13

Last publish

Collaborators

  • hom-chen