pr-agent-cli
v1.1.5
Published
AI-powered CLI tool for generating PR descriptions, fixing review comments, and performing code reviews using Ollama, OpenAI, or Anthropic
Downloads
1,011
Maintainers
Readme
pr-agent-cli
AI-powered CLI tool for PR descriptions, code reviews, and auto-fixing review comments.
Features
| Feature | Description | |---------|-------------| | 🤖 AI PR Generation | Auto-generate PR titles and descriptions from git diffs | | 🔍 AI Code Review | Intelligent code reviews with severity levels | | 🛠️ Auto-Fix Reviews | Fix PR comments using GitHub Copilot or AI | | 🌐 Multi-Provider | Ollama (local), OpenAI, Anthropic support | | 🚀 GitHub Integration | Create PRs directly from CLI |
Prerequisites
- Node.js >= 14.0.0
- Git repository
- LLM Provider: Ollama (default), OpenAI, or Anthropic
- GitHub CLI (
gh) - Required for--fix-reviews
Installation
# Install CLI
npm install -g pr-agent-cli
# Install Ollama (for local AI)
# macOS
brew install ollama
# Linux
curl -fsSL https://ollama.ai/install.sh | sh
# Windows: Download from https://ollama.ai/download
# Install GitHub CLI
# macOS
brew install gh
# Windows
winget install --id GitHub.cli
# Linux: See https://cli.github.com/Quick Start
# 1. Start Ollama and pull model
ollama serve
ollama pull deepseek-coder:6.7b
# 2. Authenticate GitHub CLI
gh auth login
# 3. Generate PR description
cd your-repo
git checkout -b feature/new-feature
# ... make changes ...
git add .
git commit -m "Add feature"
pr-agent
# 4. Get AI code review
pr-agent --review-pr
# 5. Auto-fix review comments
pr-agent --fix-reviewsCommands
| Command | Description | Example |
|---------|-------------|---------|
| pr-agent | Generate PR description | pr-agent --base main --create |
| pr-agent --review-pr | AI code review | pr-agent --review-pr --base main |
| pr-agent --fix-reviews | Fix PR review comments | pr-agent --fix-reviews |
| pr-agent --diff-only | View diff statistics | pr-agent --diff-only |
Configuration
Quick Setup
Create .pr-agent.json in your repo:
{
"llmProvider": "ollama",
"model": "deepseek-coder",
"baseBranch": "main",
"reviewFixMode": "copilot"
}Environment Variables
# Option 1: Export variables
export OPENAI_API_KEY=your_key_here
export ANTHROPIC_API_KEY=your_key_here
# Option 2: Create .env file in same dir (recommended)
echo "OPENAI_API_KEY=sk-your-key" > .env
echo "ANTHROPIC_API_KEY=sk-ant-your-key" >> .envKey Configuration Options
| Option | Description | Default |
|--------|-------------|---------|
| llmProvider | ollama, openai, anthropic | ollama |
| model | Model name | deepseek-coder |
| baseBranch | Default base branch | development |
| reviewFixMode | copilot or ollama | copilot |
LLM Providers
| Provider | Setup | Example |
|----------|-------|---------|
| Ollama | ollama pull deepseek-coder:6.7b | pr-agent |
| OpenAI | Set OPENAI_API_KEY | pr-agent --provider openai --model gpt-4o |
| Anthropic | Set ANTHROPIC_API_KEY | pr-agent --provider anthropic --model claude-3-5-sonnet-20241022 |
Available Models
OpenAI: gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo
Anthropic: claude-3-5-sonnet-20241022, claude-3-opus-20240229, claude-3-sonnet-20240229, claude-3-haiku-20240307
Ollama: deepseek-coder:6.7b, codellama, llama2
Troubleshooting
| Issue | Solution |
|-------|----------|
| "Ollama is not running" | ollama serve |
| "GitHub CLI not installed" | Install: brew install gh (macOS) or see cli.github.com |
| "Not a git repository" | Run inside a git repo: git init |
| "No pull request found" | Create PR first: gh pr create |
License
MIT - see LICENSE file
Support
- Issues: github.com/shreyas116/PRBrain/issues
- Discussions: github.com/shreyas116/PRBrain/discussions
Made with ❤️ by Shreyas Joshi
