Back to cookbook

AI Prompt to Review Pull Requests for Bugs and Security Using GitHub's MCP Server

1 views Published

Make this prompt yours

Share

This prompt gives developers and engineering leads a repeatable way to review pull requests for bugs, security issues, and style problems by connecting an AI model to GitHub's MCP server, so it reads the actual diff, file list, and CI status instead of relying on pasted code snippets. It's built for developers, tech leads, and reviewers who want a consistent first pass on incoming pull requests before a human review.

With the MCP connection live, the model can pull the real diff for a specific PR number, check it against the team's house rules (naming conventions, error handling, test coverage expectations), and flag security-sensitive patterns like unsanitized input or hardcoded secrets. Because the review runs against the actual repository state rather than a copy-pasted chunk, the output stays accurate even as the PR gets updated with new commits.

Before wiring this into a review workflow, it helps to tighten the instructions themselves — running the prompt through Prompt Optimizer's Coding mode first will tighten vague review criteria into the specific checks a model can reliably apply.

Prompt template

Make this prompt yours

prompt-template
250 tokens
Role: You are a senior code reviewer with access to a GitHub MCP connection. Context: - Repository: [REPO_NAME] - Pull request: [PR_NUMBER] - Primary language/framework: [LANGUAGE_OR_FRAMEWORK] - Team coding standards: [LIST_KEY_STANDARDS_OR_LINT_RULES] Task: 1. Pull the current diff, changed file list, and CI status for the specified pull request. 2. Review the changes for: functional bugs, security issues (e.g. unvalidated input, hardcoded secrets, injection risks), and violations of the team's coding standards. 3. Note any missing or inadequate test coverage for the changed code. Constraints: - Base feedback only on the actual diff and files pulled from the repository, not assumptions about unseen code. - Separate findings into "Blocking" and "Suggestion" categories. - Reference the specific file and line number for each finding. - Do not approve, merge, or close the pull request; this review is advisory only. Output format: - Summary: one paragraph on overall PR readiness - Blocking issues: bulleted list with file:line and explanation - Suggestions: bulleted list with file:line and explanation - Test coverage notes: bulleted list

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
70 tokens
Review PR #482 in the repo acme-inc/billing-service. It's a Python/FastAPI service. Our standards: all new endpoints need request validation with Pydantic, no bare except blocks, and at least one test per new endpoint. Pull the diff and CI status via the GitHub MCP connection and flag anything that would block merge.

When to use it

  • Reviewing an incoming pull request before assigning it to a human reviewer, to catch obvious issues early
  • Auditing a backlog of open PRs for security-sensitive patterns like hardcoded credentials or unvalidated input
  • Checking a PR against team-specific style and testing conventions before merge
  • Giving a junior developer automated feedback on their PR before it goes to a senior reviewer

Best practices

  • Scope the review to one PR or one file set at a time rather than asking the model to review an entire repository at once
  • Give the model your team's actual lint rules and PR checklist instead of asking for generic "best practices"
  • Ask for inline, file-and-line-referenced feedback rather than a general summary, so comments map back to the diff
  • Re-run the review after new commits are pushed to the same PR, since the diff changes

Common mistakes

  • Pasting a static copy of the diff into the prompt instead of letting the MCP connection pull the live version, so feedback goes stale after new commits
  • Asking the model to approve or merge the PR directly instead of treating its output as a first-pass review for a human to confirm
  • Not specifying the project's language version or framework, leading to suggestions that don't match the actual codebase
  • Treating every flagged issue as equally severe instead of asking the model to separate blocking issues from minor style notes

FAQs

How do I connect ChatGPT or Claude to a GitHub MCP server for code review?

You connect through an MCP-compatible client (such as Claude Desktop, Claude Code, or an MCP-enabled ChatGPT integration) that has a GitHub MCP server configured with a personal access token or GitHub App credentials. Once connected, the model can call tools to read repository contents, pull requests, and CI status directly instead of relying on text you paste in.

Can AI actually read a live pull request diff instead of a pasted code snippet?

Yes, when it's connected through an MCP server with GitHub access, the model can request the current diff, file list, and check status for a specific PR number in real time. This means the review reflects the latest commits on that PR rather than a snapshot you copied earlier.

Is an AI code review from an MCP-connected prompt a replacement for human review?

No. It's best used as a first pass that catches obvious bugs, security issues, and style violations before a human reviewer looks at the PR, not as a substitute for a maintainer's sign-off, especially for security-sensitive or architecturally significant changes.

Which Cuelara tool can help me tighten this prompt before using it on a real PR?

Prompt Optimizer — its Coding mode is built to turn vague review instructions into specific, checkable criteria, which is useful for sharpening the constraints in this exact prompt before you run it against a real pull request.

Found this prompt useful? Share it.

Share

More in Code Generation & Software Engineering

Code Generation & Software Engineering

AI Prompt to Write a GitHub Actions CI/CD Workflow from Plain English

This is a prompt for turning a plain English description of your build, test, and deploy process into a working GitHub Actions workflow YAML…

Role: You are a DevOps engineer writing a GitHub Actions workflow file.

Context:
Project type: [LANGUAGE/FRAMEWORK, e.g. Node.js with npm, Python with Poetry]
Repository structure notes: [e.g. monorepo with /api and /web folders, single app at root]
Runner: [e.g. ubuntu-latest]

Task:
Write a GitHub Actions workflow (.github/workflows/[FILENAME].yml) that does the following, in this order:
1. Trigger on: [TRIGGER EVENTS, e.g. pull_request to main, push of tags matching v*]
2. Job 1 - [JOB NAME, e.g. lint]: [WHAT IT DOES]
3. Job 2 - [JOB NAME, e.g. test]: [WHAT IT DOES], must run only after Job 1 succeeds
4. Job 3 - [JOB NAME, e.g. deploy]: [WHAT IT DOES], must run only after Job 2 succeeds and only on [CONDITION, e.g. tag pushes to main]

Secrets/environment variables needed (reference by name only, do not invent values): [SECRET NAMES, e.g. DEPLOY_TOKEN, AWS_ACCESS_KEY_ID]

Constraints:
- Pin third-party actions to a specific major version (e.g. actions/checkout@v4)
- Use caching for dependencies where the ecosystem supports it
- Keep job names and step names descriptive enough to read clearly in the Actions UI

Output format:
Return the complete YAML file in a fenced code block, followed by a short bullet list explaining what each job does and when it runs.

Make this prompt yours

Code Generation & Software Engineering

AI Prompt to Debug a Failed Vercel Deployment Using Vercel's MCP Server

This Vercel MCP prompt helps developers and DevOps engineers figure out why a deployment failed without manually scrolling through build log…

ROLE: You are a deployment troubleshooting assistant with access to Vercel's MCP server.

CONTEXT:
- Project: [PROJECT_NAME]
- Framework: [FRAMEWORK, e.g. Next.js 14]
- Deployment ID or URL: [DEPLOYMENT_ID_OR_URL]
- Last known good deployment: [PREVIOUS_DEPLOYMENT_ID_OR_URL, or 'none']
- What changed since the last successful deploy: [RECENT_CHANGES_SUMMARY]

TASK:
1. Retrieve the build and runtime logs for the failing deployment.
2. Identify the failure category: build error, runtime error, environment/configuration issue, or dependency issue.
3. Quote the specific log lines that show the root cause.
4. If a last known good deployment is provided, compare configuration and environment variables between the two.
5. Propose a ranked list of likely fixes, most probable first.

CONSTRAINTS:
- Do not guess at a cause without quoting supporting log evidence.
- Flag if critical information (e.g. an environment variable value) is missing rather than assuming it.

OUTPUT FORMAT:
- Failure category
- Root cause (with quoted log evidence)
- Ranked fix recommendations
- Any missing information needed to confirm the diagnosis

Make this prompt yours

Code Generation & Software Engineering

ChatGPT Prompt to Generate a Production-Ready Dockerfile for Your App

This Dockerfile generator prompt gives ChatGPT, Claude, or Gemini everything needed to write a secure, production ready Dockerfile for your…

You are an expert DevOps engineer who writes secure, production-ready Dockerfiles.

Context:
- Application language and version: [LANGUAGE AND VERSION, e.g., Node.js 20]
- Framework: [FRAMEWORK, e.g., Express, Django, Spring Boot]
- Package manager: [PACKAGE MANAGER, e.g., npm, pip, Maven]
- Target deployment platform: [PLATFORM, e.g., AWS ECS, Kubernetes, linux/amd64]
- Special requirements: [e.g., private package registry, native dependencies, health checks]

Task:
Write a production-ready Dockerfile for this application. Use a multi-stage build that separates the build/dependency-install stage from the final runtime stage. The final image should:
1. Use the smallest reasonable base image for the runtime.
2. Run as a non-root user.
3. Only copy the files needed to run the application, not build tools or source maps.
4. Include a HEALTHCHECK instruction appropriate for this type of service.
5. Set any necessary environment variables and expose the correct port.

Constraints:
- Do not use the "latest" tag for any base image; pin a specific version.
- Keep the final image size as small as possible.
- Explain, in a short comment above each non-obvious instruction, why it's there.

Output format:
1. The complete Dockerfile in a single code block.
2. A short bullet list explaining the base image choice and any trade-offs.
3. One suggested .dockerignore entry list for this stack.

Make this prompt yours