Getting Started
Getting Started
Get a working Prompt2PR workflow in under 5 minutes.
Prerequisites
- A GitHub repository where you have admin access
- An API key from one of the supported LLM providers (or a GitHub Copilot subscription for GitHub Models)
Step 1: Get an API Key
Choose a provider and get your API key:
| Provider | Where to get the key |
|---|---|
| Mistral | console.mistral.ai → API Keys |
| OpenAI | platform.openai.com → API Keys |
| Anthropic | console.anthropic.com → API Keys |
| GitHub Models | No key needed — uses the built-in GITHUB_TOKEN |
Step 2: Add the Secret
In your GitHub repository:
- Go to Settings → Secrets and variables → Actions
- Click New repository secret
- Add your API key with the correct name:
| Provider | Secret Name |
|---|---|
| Mistral | MISTRAL_API_KEY |
| OpenAI | OPENAI_API_KEY |
| Anthropic | ANTHROPIC_API_KEY |
| GitHub Models | No secret needed |
Step 3: Create a Workflow File
Create .github/workflows/prompt2pr.yml in your repository:
name: Prompt2PR
on:
workflow_dispatch:
inputs:
prompt:
description: 'What should the AI fix?'
required: true
permissions:
contents: write
pull-requests: write
jobs:
prompt2pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: davd-gzl/Prompt2PR@v1
with:
prompt: $
provider: mistral
env:
MISTRAL_API_KEY: $
GITHUB_TOKEN: $
Note: Replace provider: mistral and MISTRAL_API_KEY with your chosen
provider and its corresponding secret. {: .notice–info }
Step 4: Enable PR Creation
Go to Settings → Actions → General → Workflow permissions and check:
- “Allow GitHub Actions to create and approve pull requests”
Without this, the action will fail with a permission error.
Step 5: Trigger the Workflow
- Go to the Actions tab in your repository
- Select the Prompt2PR workflow
- Click Run workflow
- Enter your prompt (e.g., “Add missing error handling to all async functions”)
- Click Run workflow
The action will scan your files, call the LLM, apply the changes, and open a PR. Check the workflow run logs for details on what was changed.
What Happens Next
After the workflow runs successfully:
- A new branch is created (e.g.,
prompt2pr/1707900000) - A Pull Request is opened with the LLM’s changes
- The PR body includes the original prompt, a summary of changes, and metadata
- The
prompt2prlabel is applied
Review the PR like any other — merge it, request changes, or close it.
Using GitHub Models (No API Key)
If you prefer not to manage external API keys, GitHub Models lets you use LLMs directly through GitHub’s infrastructure:
permissions:
contents: write
pull-requests: write
models: read # Required for GitHub Models
jobs:
prompt2pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: davd-gzl/Prompt2PR@v1
with:
prompt: 'Fix typos in documentation'
provider: github
model: openai/gpt-4o
env:
GITHUB_TOKEN: $
Important: GitHub Models requires the models: read permission and a GitHub
Copilot subscription. {: .notice–warning }
Next: Configuration Reference