GitHub - masonbeater/codepr-cli: AI-powered pull request reviews from your terminal

AI-powered code review for Git.

CodePR CLI analyzes your Git diff, extracts changed functions, understands commit intent, and generates a structured AI review report before you open a PR.

Built for developers who want fast feedback on risky code changes.

Why CodePR

Traditional PR review often has three bottlenecks:

  • Feedback speed depends on reviewer availability
  • Large diffs are hard to inspect quickly
  • Many AI reviewers send full files to LLMs, increasing cost and noise

CodePR takes a different approach:

  • Extracts only changed functions
  • Adds focused surrounding context
  • Analyzes commit intent
  • Returns structured issues for easy action

This keeps prompts small, focused, and cost-efficient.

Key Features

  • Diff parsing
    • Detects changed files, lines, and patches
  • Function-level context extraction
    • Supports Go, Java, JavaScript, and Python
  • Commit intent analysis
    • Summarizes change intent
    • Identifies affected components
    • Estimates risk level
  • Smart Context
    • Adaptive Extraction: Dynamically adjusts context size based on function length (more context for small functions, focused view for large ones)
    • Smart Filtering: Automatically ignores system files, lockfiles, and binaries while keeping important config files
  • High Performance
    • Concurrent Review: Processes multiple functions in parallel for faster feedback
  • Token & Output Guardrails
    • Response token limits by stage (intent/review/test)
    • Patch truncation in prompts to avoid oversized requests
    • Output caps for issues/tests with deduplication
  • AI code review
    • Generates structured issues:
      • severity
      • file
      • line
      • title
      • explanation
      • suggestion
  • Config-aware review prompts
    • Uses specialized review prompts for build/dependency files (pom.xml, build.gradle, package.json, etc.)
    • Uses specialized review prompts for runtime config files (.yaml, .yml, .properties, .toml, .conf, .ini)
  • Test suggestions
    • Identifies missing test coverage
  • Debug mode
    • Shows extracted functions
    • Shows estimated token usage
    • Shows prompts sent to the LLM
  • Compact mode
    • --compact prints a shorter report with tighter issue/test caps
  • Bilingual output (ZH/EN)
    • Auto-detects output language from PR text + system locale
    • Supports manual override via config

Installation

Build from source

git clone https://github.com/<your-org>/codepr-cli
cd codepr-cli
go build -o codepr .

Optional: move the binary into your PATH.

sudo install -m 755 codepr /usr/local/bin/codepr

Then run:

Quick Start

1) Configure API key

codepr config set api_key <your_api_key>

Show active config:

Optional provider settings (OpenAI-compatible gateways):

codepr config set base_url https://api.deepseek.com/v1
codepr config set model deepseek-chat
codepr config set timeout_seconds 60
codepr config set language auto

Default config file path:

  • ~/.codepr/config.json (global, persists across terminal restarts and reinstalls)

Override config file path:

  • CODEPR_CONFIG=/path/to/config.json

You can also use environment variables:

export CODEPR_API_KEY=<your_api_key>
export CODEPR_BASE_URL=<base_url>
export CODEPR_MODEL=<model_name>
export CODEPR_LANGUAGE=auto

2) Review changes (auto-detect default base branch)

3) Review changes against a specific base branch

4) Review a repository by path (without cd)

codepr review --repo /path/to/target-repo
codepr review main --repo /path/to/target-repo

5) Review the latest commit

6) Enable debug mode

codepr review main --debug

7) Compact output mode

codepr review --compact
codepr review main --compact
codepr review --last --compact

Debug output includes:

  • extracted functions
  • estimated token usage
  • prompts sent to the LLM

Example Output

CodePR Review Report
====================

PR Intent
---------
Fix payment validation bug

Components: payment service
Risk: medium

Issues
------

[HIGH] payment_service.go:84
Missing null check before ProcessPayment call
Suggestion: Validate input before invoking ProcessPayment.

Tests
-----

- Add test for invalid payment amount

Typical Use Cases

  • Pre-PR local review
  • CI code quality checks
  • High-risk module validation (payments, permissions, financial systems)
  • Automated review reports in delivery pipelines

How CodePR Works

Git diff
  ↓
Extract changed functions
  ↓
Add surrounding context
  ↓
Analyze commit intent
  ↓
Send focused code to LLM
  ↓
Generate structured issues

Instead of reviewing entire files, CodePR focuses on relevant code regions, reducing token usage while improving signal quality.

Interested in the implementation details? Check out our Technical Design (Chinese).

CLI Command Reference

codepr review [base_branch] [--repo <path>] [--debug] [--compact]
codepr review --last [--repo <path>] [--debug] [--compact]
codepr config set api_key <value>
codepr config set base_url <value>
codepr config set model <value>
codepr config set timeout_seconds <value>
codepr config set language <auto|zh|en>
codepr config show

Release Notes

Roadmap

  • More language support (TypeScript, Kotlin, Scala)
  • AST-based function detection
  • Call graph impact analysis
  • Parallel review execution
  • CI integrations
  • GitHub Action support
  • SaaS review gateway

Contributing

Contributions are welcome.

Please read CONTRIBUTING.md before opening a pull request. For vulnerability reports, see SECURITY.md.

If you’d like to improve CodePR:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

Suggested contribution areas:

  • AST-based context extraction
  • Additional language support
  • CI integrations
  • Performance improvements

Disclaimer

CodePR is designed to assist code review, not replace human judgment.

For production use, combine it with:

  • automated tests
  • static analysis
  • human review

License

MIT License