Local PR Buddy reviews code before you push
Local PR Buddy is a Python CLI that asks an LLM to review your staged or branch changes on your own machine, before you open a pull request.
You finish a feature, and the branch is ready to share. Before you click "Create Pull Request", three questions come up: is it really ready, did you overlook something, and how will you explain the changes? Those questions are what this tool answers before the code goes public.
Feedback usually starts after you open the pull request. I built Local PR Buddy to get that second look earlier, on your own machine, before the code is public. Getting the scope right first matters too, as in nailing down your user story before you build.
Local PR Buddy is a command-line tool that brings AI code analysis into your local Git environment. It helps you refine your work, understand your changes and push with more confidence.
What a pull request is and why it matters locally
On a team, you will see pull requests (PRs) on GitHub or merge requests (MRs) on GitLab. A PR proposes merging the changes on your branch into a central branch such as main, develop or master. Opening one tells the team that the work is ready and asks them to review it and approve it if it looks good.
A PR starts three kinds of work:
- Code review of correctness, style, potential issues and project standards.
- Discussion, where questions are asked, clarified and answered with suggestions.
- Automated checks, where continuous integration (CI) runs tests, linters and other quality gates.
Local work benefits from the same scrutiny, even if you work alone or are learning. Applying it before you share your code gives you four things.
- You catch mistakes when they are easiest to fix. A small logic error or a confusing variable name is simpler to correct while the code is fresh, not days later in a formal review.
- You learn in private. You get feedback on quality without public critique, and you see what good code looks like.
- You build confidence. A PR is less daunting after a first automated pass and some refinement.
- You build habits. Describing your changes, thinking about their impact and spotting issues locally makes you a more effective developer. It also reflects the AI-first philosophy of iterative refinement.
Local PR Buddy is your AI-powered assistant for these local pre-flight checks.
What Local PR Buddy does
Local PR Buddy is a Python CLI that uses large language models (LLMs) to analyze Git changes in your local repository. The core analysis does not need your code on a remote server. It looks at two kinds of changes:
- Branch diffs: the changes on your feature branch compared with a target branch such as main. It uses the merge-base for an accurate comparison.
- Staged changes: the modifications you have added with git add and are about to commit.
It has four commands.
- /describe generates a title for your changes, a type (such as Feature, Bug fix or Refactor) and a short bullet-point summary. Use it to draft commit messages or the first description for a pull request.
- /review gives a high-level AI review. It often flags areas to improve, security considerations and a rough estimate of review effort.
- /improve analyzes your new code and suggests concrete improvements. It shows your existing snippet next to the proposed version, with an explanation of the benefits. It helps you learn new patterns and catch subtle issues.
- /ask {your question} answers questions about the diff, such as "Does this new error handling cover the failure cases?"
It works like an AI peer who is always available for a quick, private look at your changes before you share them.
Who it helps
The goal is to address common pain points for developers at every level.
For experienced developers
An extra layer of automated review still helps confident developers.
- A second pair of eyes. A quick local review can catch typos, missed edge cases and unclear code.
- Pre-review polish. A PR that has had automated scrutiny makes the human review smoother and faster for your team.
- A documentation head start. The output of /describe can become the starting point for a full PR description.
For newer developers
Git, branches and code review can feel overwhelming. Local PR Buddy works as a learning companion.
- Review rehearsal. /review and /improve show what feedback you might get in a real review, in private and without pressure.
- Actionable learning. /improve shows how your code could be better. It fits the approach in leveling up your vibe coding.
- Practice describing your work. /describe helps you summarize your changes.
- Confidence. Making improvements based on local AI feedback builds confidence.
For all developers
- A true shift left. Quality checks start at the beginning of your workflow.
- Focus on what matters. You iterate faster and spend less time on minor issues in formal review.
- Privacy and control. Diffs are processed locally and sent only to the LLM API you configure, which can be a local model through Ollama.
How it works
Local PR Buddy is built with Python and several libraries.
- Git interaction. It uses GitPython for operations such as merge-bases, and it parses git diff --staged for staged changes. It sends the full content of newly added files to the AI.
- AI integration. LiteLLM connects to providers such as OpenAI, Anthropic and Google, and to local models through Ollama. It offers the same kind of flexibility as OpenRouter. API keys live in a local .env file.
- Prompt engineering. Prompts in .toml files, using Jinja2 templates, guide the AI for each tool. They draw on the same principles as code2prompt and Context7.
- Structured output. Prompts ask the AI to return YAML, which the Python tools parse.
- Modular design. The code is organized into core, providers, tools and prompts directories, which is part of my AI development power stack.
- User interface. A CLI with styled output through colorama, and a .vscode/tasks.json file for VS Code integration.
Other uses
The main goal is feedback before a PR, but the tool supports other work too.
- Commit messages. Use the /describe output as a starting point for conventional commit messages.
- Automated pre-commit checks. A Git hook could run /improve --staged. That extends local automation, much like n8n automations.
- Onboarding. New team members can learn coding standards and review expectations from it.
Next steps
The core Python CLI with its four commands works. The next step is deeper VS Code integration.
- VS Code extension. We have started building it so that commands run from the Command Palette and show results in VS Code's Output Channel.
- Webviews. The plan is for the Python tools to output structured JSON, so the extension can render results in interactive HTML Webview panels. This mirrors the UI in my Desktop AI Assistant and PlantDex projects.
- Phase 4 polish. Ideas include SARIF output for the Problems panel and interactive application of suggestions.
Questions and answers
What is the main benefit of a local PR tool?
It gives you privacy, speed and room to iterate. Your code does not go to a third-party review service before you are ready. Feedback arrives right away, without waiting for CI or human reviewers, and you can fix issues before you open a formal pull request.
I am new to Git. How can Local PR Buddy help?
It is a good learning tool. /describe helps you summarize your work for commit messages. /review and /improve give you a private preview of the feedback a real code review gives, and they show what to look for.
Does this replace human reviewers or tools like GitHub Copilot?
No, it complements them. Local PR Buddy is for pre-flight checks by the developer, while human reviewers add context and architectural oversight. Copilot helps write code line by line, and Local PR Buddy analyzes a set of changes, which is a diff.
How does it see my code changes?
It reads your local Git repository. For branch comparisons, it finds the common ancestor (the merge-base) to get an accurate diff. For staged changes, it processes the output of git diff --staged. The diff text is then sent to an AI.
Which AI models can I use?
It uses LiteLLM, which supports many models. That includes OpenAI's GPT series, Anthropic's Claude, Google's Gemini and open-source models you can run locally with Ollama. You set the model and the API key.
Is it complicated to set up the prompts?
No. The tool ships with predefined, optimized prompts for each command, stored in .toml files. Advanced users can customize them, but the tool works out of the box.
Does /improve change my code?
No. It sends your diff to the AI and asks for specific suggestions. It shows your existing code, the proposed version and an explanation. You decide whether and how to apply each suggestion.
Will it slow down my local development?
An AI call takes a few seconds. Catching issues locally avoids lengthy back-and-forth in a PR review and broken builds, which saves time overall.
What does shift left mean?
Shift left means moving quality work, such as testing and review, earlier in the development pipeline. Local PR Buddy shifts left by letting AI review your changes on your machine before you commit or push.
How will the VS Code extension improve on the CLI?
The extension will put these commands in the VS Code interface, through the Command Palette or context menus. Future versions aim to show results in rich Webview panels, which are more interactive than terminal output.
I built this tool with AI, as covered in this post on AI-first site migration. The project will appear on my GitHub soon.