How to Start Automated Code Review with LLMs Using Effective Prompts

Introduction: Why automated code review with LLMs is the solution of the moment

Automated code review using large language models (LLMs) has become a critical practice for teams aiming to accelerate releases while maintaining high-quality standards. Within seconds, an LLM can analyze code diffs, suggest corrections, and flag potential bugs, significantly reducing manual workloads.

This practical guide demonstrates how to set up an end-to-end workflow, craft effective prompts, and integrate LLM-based code review into your existing CI/CD processes.

Why automated code review with LLMs is transforming software development

Speed and scalability

  • LLMs process thousands of lines of code in under a second, far outpacing human reviewers.
  • They operate 24/7 across multiple repositories without fatigue.

Consistency and reduced human error

  • They enforce uniform coding standards across entire projects.
  • They eliminate the risk of spending hours searching for typos or poor practices.

Key components of an LLM-based workflow

1. Extracting diffs from the repository

The first step is to retrieve the modified code. Here’s a GitHub Actions example that sends the diff to an LLM endpoint:

name: LLM Code Review on: [pull_request] jobs: review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Get diff id: diff run: | git diff ${{ github.event.pull_request.base.sha }} HEAD > diff.txt - name: Call LLM API run: | curl -X POST https://api.example.com/review \ -H "Content-Type: multipart/form-data" \ -F "file=@diff.txt" \ -F "model=llama-3-70b" > review.json

2. Crafting effective prompts for code review

A strong prompt is specific, structured, and action-oriented. Here’s an example:

You are an expert senior developer reviewing the following changes: ### File: src/main.py ### Diff: @@ -1,5 +1,6 @@ def calculate_total(items): - return sum(i.price for i in items) + return sum(i.price * i.quantity for i in items) Please: 1. Highlight any potential bugs. 2. Suggest improvements for readability. 3. Provide a concise comment for each suggestion. Output format: - Bug:- Suggestion:- Comment:

Such structures help the model stay focused and generate reusable outputs.

Integration with CI/CD and development tools

  • GitHub Actions / GitLab CI:Add a job that runs the LLM prompt after code is pushed.
  • Pre-commit hooks:Usepre-committo run the review before each commit.
  • IDE extensions:Plugins for VS Code or JetBrains that display LLM comments in real time.

These tools create an "always-on" code review ecosystem that adapts to any existing workflow.

Real-world use cases and examples

Below is an example of a comment generated by an LLM for a pull request:

These comments are inserted directly into the PR, providing reviewers with a clear starting point.

Best practices and security considerations

  • Context limitation:
  • Human review:Use the LLM as a first filter, then pass to a human reviewer for edge cases.
  • Data policy:Never send proprietary code or sensitive data to external LLM services.
  • Prompt versioning:Store effective prompts in a version-controlled repository for reproducibility.

The latest LLM models offer extended context and improved reasoning, making them ideal for complex code review tasks. The open-source community has released several specialized wrappers, such asllm-code-review, that seamlessly integrate self-hosted LLMs (e.g., LLaMA-3, Mistral-31B) into existing pipelines.

Additionally, integration with "document intelligence" platforms is opening new possibilities: the same models that analyze PDFs can extract internal coding standards from documents and feed them back into the prompt for customized compliance.

Conclusion: 5 concrete steps to get started

  1. Set up a repository for diff extraction (GitHub Actions, GitLab CI, or pre-commit).
  2. Design a structured prompt that covers bugs, security, and readability.
  3. Integrate the LLM endpoint into your CI system (use hosted or self-hosted APIs).
  4. Monitor false positives, collect successful prompts, and store them in a shared repository.

By following these steps, you’ll transform code review from a slow, manual task into an automated, data-driven process, freeing up time for higher-value work.

Quick summary

  • LLMs deliver speed, scalability, and consistency in code review.
  • A well-structured prompt is key to reliable output.
  • Integrate the LLM workflow with CI/CD, IDE, and pre-commit extensions.
  • Maintain human oversight for complex cases and protect sensitive data.
  • Leverage the latest LLM models and open-source tools to stay ahead of the market.

Start today: set up a CI job, write your first prompt, and see how code review becomes faster and smarter.

IMPORTANT: We are in 2026. All temporal references must be current. Do not mention past years such as 2024, 2023, etc. The content must be fresh and relevant to the present. CURRENT CONTEXT (August 2026): Here are some recent trends and news stories to inspire you: - Google tests AMIE for clinical video consultations: Google’s research medical AI system, AMIE (Video), conducted synchronous video consultations with professional patient actors and received clinical ... [2026-08-12] - Novo Nordisk and AWS bring agentic AI into drug discovery: Novo Nordisk is expanding its use of AWS artificial intelligence tools across drug discovery, including AI agents for target identification, therapy d... [2026-08-11] - Fine-Tuning Tool-Calling LLMs: A Complete Guide Using XYZ-Aquila-SFT and Qwen3: Implement an end-to-end fine-tuning pipeline for tool-calling language models. This tutorial covers parsing trajectories, structured tool-call extract... [2026-08-15] Use this current information as inspiration to create an original and relevant prompt for 2026.

💼 Vuoi ottimizzare i tuoi processi con l'AI?

Scopri come possiamo aiutarti a creare prompt personalizzati e strategie AI su misura per il tuo business.

Richiedi Consulenza Gratuita