AI-powered PR automation, commit messages, and code review (Gemini, DeepSeek, and Ollama)
pip install gitpr-cli==1.9.0 Copy PIP instructions
GitPR CLI is a command-line automation tool that uses Google Gemini, DeepSeek, and Ollama artificial intelligence to analyze your code changes (git diff) or entire files. The tool automatically generates commit messages in the Conventional Commits standard, detailed Pull Request descriptions, and deep Code Reviews aimed at reducing technical debt.
🌐 Website: gitpr.natanfiuza.dev.br · 📂 Repository: https://github.com/gitpr-cli/gitpr.git
pip install gitpr-cli 2. Seeing It Work (No Configuration) GitPR ships a guided tour over an example diff. It needs no API key, no Git repository and no connection:
gitpr demo Guided Tour: Six screens walking through a real example — the diff, the commit message, the code review and the pull request description — with the answers recorded once and replayed. Add --no-tui for plain text, --scenario security-issue for the other example. 📖 Full Documentation: https://gitpr.natanfiuza.dev.br/docs/demo
To set up GitPR in a folder of a new repository, run:
gitpr --install Guided Setup: Guided configuration that downloads skill templates, installs Git Hooks, configures MCP for your editors, and verifies the API key for your AI provider. 📖 Full Documentation: https://gitpr.natanfiuza.dev.br/docs/install-wizard
This project was developed in Python and uses the following main libraries:
To ensure the Git capture logic and AI integration are working correctly, we use unit tests.
Install test dependencies (if you haven't already):
pipenv install --dev pytest Run the tests with the command:
pipenv run pytest -v Pytest will automatically detect files inside the tests/ folder and display a detailed execution report.
pip install gitpr-cli On the first run, the wizard will guide you: $ gitpr 🚀 Intelligent PR Automation with AI 🔧 First run detected! Let's configure GitPR CLI. 🔑 Enter your GEMINI_API_KEY: 📄 Default output filename pattern [{branch}_{datetime}_PR_DESC.md]: Note: Your configuration will be securely saved in the ~/.gitpr/.env file.
Note (updates): GitPR is distributed exclusively through PyPI. On every run it checks whether a newer version has been published, and when one exists it blocks the execution and asks you to run pip install --upgrade gitpr-cli. See gitpr.natanfiuza.dev.br/docs/auto-update.
🔒 Security Note: GitPR CLI uses symmetric encryption (Fernet). Your API key is stored as a hash in the .env file, and the master key for decryption is automatically generated in ~/.gitpr/secret.key. Never share your secret.key file.
Clone the repository: git clone https://github.com/gitpr-cli/gitpr.git
pip install -e . Run: gitpr Prefer an isolated environment? Install the dependencies with pipenv install google-genai openai python-dotenv click cryptography and run pipenv run python src/main.py instead.
Note on the update gate: a source install reports the version found in your checkout, so a tree behind the published release is stopped at startup. See Installing GitPR from Source.
GitPR has a powerful default behavior and several advanced options to assist you in your day-to-day as a developer.
Simply run the bare command in your terminal:
gitpr The tool will sync with the remote (git fetch), compare your changes with the remote main branch (e.g.: origin/main), and generate a Markdown file (e.g.: feature-login_20260421110134_PR_DESC.md) at the root of your project with the complete suggestion for your Pull Request.
You can pass the following flags for specific actions:
⚙️ Technical Note (--hook): GitPR has a hidden flag --hook that is triggered exclusively by the Git Hooks system in the background. It allows the AI to inject the suggested message directly into Git's temporary file, without cluttering your terminal.
⚙️ Technical Note (--pre-save): GitPR has a hidden debug flag --pre-save that can be combined with any AI command (e.g.: gitpr -c --pre-save). Before each AI call, it saves the full payload that will be sent to the model (system instruction + prompt + character counters) to a _{action}-{datetime}.json file in the current folder, and then proceeds normally. Useful for inspecting very large prompts. Note: when the response comes from the local cache, no call is made and no file is generated.
When your diff is too large for a single AI call (over ~90k estimated tokens), GitPR automatically splits it into batches by file, asks the AI for a technical summary of each part (Map), and unifies everything into the final commit message, review, or PR description (Reduce). No flags needed — it activates on demand and shows the progress in the console.
📚 Full documentation: gitpr.natanfiuza.dev.br/docs/map-reduce-diff
GitPR CLI allows you to define strict rules that will be validated instantly during --review or --fullreview, without depending on AI. This is ideal for preventing common errors (like console.log or test IPs) from reaching the repository.
When running gitpr --skill, a template will be generated. You can configure rules using Regular Expressions (Regex):
rules: - name: "check-localhost" extensions: ["js", "php"] # Extensions to be validated regex: 'http(s)?://(localhost|127\.0\.0\.1)' # What to look for message: "🚨 Localhost usage detected in file {file_name}" ignore_comments: true # Ignores if the line is commented ignore_paths: # Folders or files ignored (accepts *) - "vendor/*" - "node_modules/*" The Linter analyzes only the added lines in your git diff, ensuring a focused and extremely fast execution. If there are violations, they will appear highlighted at the top of your review file.
If your project already uses tools like ESLint, PHP_CodeSniffer, Stylelint, Semgrep, Gitleaks, or Bandit, GitPR can act as a bridge — running them in the background and filtering errors only for the lines you changed in your current diff. Any linter or SAST scanner that emits reports in the checkstyle format is supported. In addition, GitPR includes embedded secret scanning rules to catch leaked API keys, tokens, and credentials before they leave your machine.
Instead of configuring the YAML manually, use the interactive wizard:
gitpr --linter-setup The wizard shows pre-configured presets (PHPCS, ESLint, Stylelint — controlled remotely via templates/gitpr.linter-presets.json), guides you through the native installation command (e.g.: npm install --save-dev eslint), and injects the correct external_linters block into your .gitpr.linter.yml.
Every run — manual via --linter or automatic before commits — consolidates the Regex Rules, Embedded Security Rules, and External Linters into a single Markdown report saved at .gitpr/reports/linter/ (customizable via OUTPUT_FILE_NAME_LINTER). The report is generated only when violations are found — clean runs create no files.
GitPR computes a local, deterministic, and explainable risk score (from 0.0 to 100.0) for individual modified files and the pull request as a whole. It requires no network calls, consumes zero AI tokens, and evaluates repository and Git signals offline:
When enabled (GITPR_RISK_INCLUDE_IN_REVIEW=true in ~/.gitpr/.env), GitPR automatically appends a ## ⚡ Risk Assessment section to generated code review reports (-r, -f, gitpr review-pr) and primes the AI review prompt with critical risk areas.
gitpr risk # Compute risk for current diff gitpr risk --file src/auth.py # Decompose risk for a single file gitpr risk --format json # Output JSON for CI/CD pipelines gitpr risk --base main # Evaluate against specific git base ref 📖 Full documentation: gitpr.natanfiuza.dev.br/docs/risk-scoring
Adopting GitPR in a repository that already carries hundreds of findings is the moment the tool is least useful: the gate fails on problems nobody in this change introduced, and the alternatives are turning it off or spending a sprint fixing code nobody is touching. A baseline is the record of what the repository already has, committed to Git, so that every run classifies what it finds instead of starting from zero.
gitpr baseline create # Record the findings of the current diff gitpr baseline show # The findings, the decisions and the counts gitpr baseline validate # Every defect in the file — exit 1 on any gitpr baseline update # Re-record today's diff, keeping decisions gitpr baseline suppress --reason "…" # A decision about one finding gitpr baseline unsuppress # Take a decision back A suppression is not a silent filter: it carries a reason, an author and a date, and accepted debt carries an owner and an optional deadline. --scope finding|line|file|rule widens a decision beyond one finding, and anything wider than a single finding lives in .gitpr/baseline.overrides.yml, where it is reviewed with the code. A checksum over the record catches an edit made outside GitPR — gitpr baseline validate names the divergence instead of applying the file. A Policy Pack may carry a baseline: block of its own, applied in memory and attributed to the pack.
Four variables in ~/.gitpr/.env, also editable through gitpr config in the section Baseline:
Only a new error-level finding exits non-zero, and only new findings carry risk points — everything else reaches the risk report as zero-point evidence with its status. The baseline is never sent to the AI, and no entry stores code or a secret: the file is committed, so only a digest of the offending line is kept.
Every commit message generated by GitPR automatically carries the co-author trailer:
Co-Authored-By: Gitpr-cli The trailer is appended programmatically (never by the AI) in all flows: console suggestion (gitpr -c), the prepare-commit-msg hook, auto-commit (--no-edit), the PR publication TUI, and the MCP generate_commit_message tool. It is idempotent — never duplicated when the message already contains it — and is hidden from the TUI edit screen, injected only when the commit is executed.
Every pull request GitPR publishes carries a badge at the foot of the body, with what the local linter counted on that very diff:
GitPR | 0 errors · 2 warnings It is built from a real measurement, never from a claim: red when a blocking finding is there, yellow for advice, green when the rules found nothing — and no badge at all when no linter rules are configured, because a green badge over a diff nobody checked would say something GitPR cannot back. It is on by default; GITPR_BADGE=false turns it off, and gitpr --skill is what gives it rules to count.
For your own README there is a static badge. gitpr badge --readme prints the line and writes nothing — pasting it is your call:
gitpr -is creates an issue, and the pull request is where it gets closed. This feature carries the number between the two: when F3 creates the issue on GitHub, GitPR records it in .gitpr/conf/github.yml (added to .gitignore automatically) — one issue at a time, the last one wins.
On the next gitpr run, before the description is generated, GitPR checks the recorded issue on GitHub. While it is still open, it offers to add close #N to the pull request body; the line becomes its own paragraph at the end and is never duplicated. Merging the pull request then closes the issue automatically.
GitHub only; the other forges skip the feature in silence. A run with no terminal does not ask — use --close-issue to opt in. The record survives a failed or cancelled publish and is cleared only after the body reaches the forge; a closed, deleted or pull-request number forgets itself, and a record from another repository is ignored and kept.
GitPR is not tied to a single Artificial Intelligence. During initial setup, the user can choose their default engine. We currently support:
You can dynamically switch models by configuring the GEMINI_API_MODEL_PRIMARY or DEEPSEEK_API_MODEL_PRIMARY variables in your ~/.gitpr/.env file, or switch in real-time using the --provider flag.
Instead of hiding AI instructions in the source code, GitPR uses local Markdown files that act as System Instructions. When running gitpr -s, the following files are generated inside .gitpr/skill/ to customize the AI's "persona" according to your company's business rules:
GitPR automatically detects your system language and displays messages in your native language. The i18n system is inspired by Laravel's __() helper:
To force a specific language, set GITPR_LANG=pt_br or GITPR_LANG=en in ~/.gitpr/.env.
📖 Full developer guide: gitpr.natanfiuza.dev.br/docs/i18n_explanation — architecture, usage patterns, circular import precautions, and how to add new languages.
GitPR includes an automatic versioning system for Git hook scripts (pre-commit, prepare-commit-msg, pre-push, post-checkout, post-merge). Every time you run gitpr, the system silently checks whether your installed hooks match the latest version and automatically updates them if needed — all while respecting your language preference.
# First run — no hooks installed yet $ gitpr --installhooks 📥 Downloading pre-commit... 📥 Downloading prepare-commit-msg... ✅ Scripts synced successfully! # Subsequent runs — silent checks $ gitpr # (no output = hooks are up to date) The system supports 5 languages: English (default), Portuguese (Brazil), Portuguese (Portugal), French, and Spanish. Scripts are thin shims — the real logic lives in the CLI, so even slightly stale hooks continue working correctly.
GitPR can run as an MCP server, exposing its AI-powered capabilities as tools that your editor's AI assistant can invoke directly — no terminal needed. This enables a fully integrated workflow where you can generate commit messages, review code, run linters, trace code origins, and create issues without leaving your IDE.
Use the built-in installer to configure your editor automatically:
gitpr-mcp --install vscode # Creates .vscode/mcp.json gitpr-mcp --install cursor # Creates .cursor/mcp.json gitpr-mcp --install claude-code # Creates .mcp.json gitpr-mcp --install claude # Updates Claude Desktop config gitpr-mcp --install zed # Updates Zed settings gitpr-mcp --install auto # Auto-detect and install for all found The installer creates the config directory if needed, merges with any existing config (never overwrites other servers), and is safe to run multiple times.
Manual setup is also supported — see gitpr.natanfiuza.dev.br/docs/mcp-integration for the JSON config format for each editor.
Once configured, use natural language in your editor's AI chat:
All GitPR MCP tools can be invoked directly from the terminal without starting the stdio server:
# List all available tools with their parameter signatures gitpr-mcp --tool # Invoke a specific tool gitpr-mcp --tool get_git_context gitpr-mcp --tool review_code gitpr-mcp --tool generate_commit_message --tool-args '{"diff_text":"..."}' gitpr-mcp --tool analyze_blame --tool-args '{"file_path":"src/main.py","start_line":"270","end_line":"284"}' This is useful for scripting, CI/CD pipelines, and one-off queries where you don't need a persistent MCP server. JSON output goes to stdout; all diagnostic messages go to stderr — safe for piping.
🧩 Official VS Code & Cursor Extension — Prefer native editor commands, SCM toolbar buttons, and inline Problems diagnostics? Download the ready-to-use .vsix from GitHub Releases or see the Editor Extension Guide for 1-click install in VS Code and Cursor. Maintainers can run scripts/marketplace-setup-wizard.sh to configure and publish to Visual Studio Marketplace and Open VSX Registry.
💬 MCP Prompts — GitPR also exposes 7 pre-defined message templates (prompts) for common flows like "Review PR", "Generate Commit Message", and "Create Issue from Diff". See the MCP Prompts guide for the full list.
GitPR automatically removes non-code files from your git diff before sending them to the AI — reducing token consumption and API costs with zero configuration required.
Documentation tracking: Even though documentation content is excluded from the diff, GitPR still tells the AI which documentation files changed by injecting their paths as metadata into the system instructions. The AI has full context about doc updates without consuming tokens on their prose.
Project-local configuration: Each project can define extra exclusions at .gitpr/conf/gitpr.smart-excludes.json. The file is auto-seeded on first run and merged with the global list at runtime:
{ "_comment": "Project-specific Smart Excludes.", "excludes": [ "dist/", "*.pyc", "build/", "node_modules/" ] } Add framework-specific build artifacts, generated folders, or any pattern that only applies to this project. The file is safe to commit — your team gets the same exclusions.
By default, GitPR saves all generated files in the .gitpr/reports/ directory, organized by artifact type:
Directories are created automatically on first use. Backward compatible: if your .env already contains custom paths with directory separators (e.g., OUTPUT_FILE_NAME=/home/user/prs/my_pr.md), those are honored as-is — GitPR only redirects bare filenames to .gitpr/reports/.
To keep this README concise, we detail the most advanced DevOps and Continuous Integration focused implementations in separate documents.
If you want to implement GitPR as an automated quality barrier in your team, check out the guides below.
🌐 Each guide is available in 5 languages — add .pt_br, .pt_pt, .fr_fr, or .es_es before the .md extension for translated versions (e.g., docs/understanding_chat_functionality.pt_br.md). English is the default with no suffix.
GitPR has an intelligent MD5-based cache engine. Whenever you run a command (--review, --commit, etc.), the tool generates an exact hash of your current code (diff) and instructions. If you run the same command again without changing the code, GitPR intercepts the request and returns the result instantly (in milliseconds) from the ~/.gitpr/cache/prompts/ folder, saving you time and your Gemini API quotas!
Never worry about manually downloading new versions again. GitPR has a Connection Guardian and a built-in updater:
pipenv run python -m build pipenv run twine upload dist/* 🤝 How to Contribute Contributions are very welcome! To contribute:
This project is licensed under the GNU Lesser General Public License v2.1 (LGPL-2.1). See the LICENSE file for more details.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




