Purpose
Selvage (official website https://github.com/selvage-lab/selvage)是一款 AI-driven code review automation tool, provided in the form of a modern CLI. It helps AI analyze Git diffs to discover code quality issues, potential bugs, and security vulnerabilities, providing instant feedback without waiting for manual review.
Key Capabilities
- Multi-model support: Use multiple LLMs through OpenRouter with a single API key, including OpenAI GPT-5, Anthropic Claude Sonnet-4, Google Gemini, and models from providers such as MiniMax, Zhipu AI, Qwen, Moonshot AI, DeepSeek, etc.; free-tier models are also available.
- Smart context analysis (AST): AST analysis based on Tree-sitter automatically extracts the minimal code block containing changed lines and its dependency statements (such as imports), sending only the necessary context, reducing token consumption while maintaining review quality.
- Git workflow integration: Supports analyzing staged, unstaged, and changes between specified commits/branches.
- Automatic multi-round processing: Automatically splits prompts when the context exceeds the model limit, and automatically triggers Large Context Mode when the total tokens exceed about 200k, stably supporting large-scale code review.
- MCP mode: Can be registered as an MCP mode in tools such as Cursor and Claude Code, and reviews can be requested through natural language.
- Claude Code plugin: Installed with one command from the marketplace, includes a dedicated /review skill and selvage-reviewer agent, and can use Claude Code's own LLM to complete reviews without an API key.
- Agent-delegated review (get_review_context): Returns structured review context (diff + Smart Context + system prompt) for the host agent (such as Claude Code, Cursor, Antigravity) to perform the review with its own LLM, without requiring a Selvage API key.
- Result storage: Review results are output to the terminal and automatically saved as Markdown and JSON files, making them easy to read or integrate programmatically.
- Open-source license: Uses Apache-2.0 license, allowing commercial use, modification, and distribution.
Usage
Installation
- Recommended method: use uv
- Alternative method: use pipx
- Traditional method: use pip (macOS/Linux users who encounter pip installation errors are advised to use uv or pipx)
After installation, you need to obtain an API key from OpenRouter and set it up.
MCP mode (recommended) Register it in the MCP configuration file of tools such as Cursor and Claude Code (for example, the common Cursor path ~/.cursor/mcp.json), then request reviews through natural language in the IDE.
Claude Code plugin After installing from the plugin marketplace, you can directly use the /review skill without an external API key; the plugin uses get_review_context to complete reviews with Claude Code's own LLM.
CLI usage Provides various command-line arguments:
--repo-path <path>: Git repository path (defaults to the current directory)--staged: Review only staged changes--target-commit <commit_id>: Review changes from the specified commit to HEAD--target-branch <branch_name>: Review changes between the current branch and the specified branch--model <model_name>: Specify the AI model to use (such as claude-sonnet-4-thinking)--open-ui: Automatically launch the UI after the review is complete--no-print: Do not output results to the terminal (output by default)--skip-cache: Skip cache and execute a new review
Web UI Review results are output to the terminal and saved to a file, and reviews can also be managed and re-viewed through the Web UI. UI features include displaying a list of all review results, Markdown-format display, and a JSON structured results view.
Use Cases
- Developers quickly get AI code quality feedback before committing code
- Integrate automated reviews into CI/CD pipelines
- Perform stable, large-scale reviews of large codebases
- Request reviews in natural language within the IDE via MCP mode
- Multi-model comparative review and step-by-step code improvement workflows
Limitations
- An API key must be obtained from OpenRouter (except for the Claude Code plugin mode, which uses the host's own LLM).
- Using the CLI requires Git to be installed locally and a repository to be configured.
- Specific charging, pricing, and free quota details are not yet clearly provided.
- For specific values such as the list of supported languages and model context length, please refer to the official documentation; the languages supported by Smart Context are continuously expanding.