Generate PR description from PR diff

It would be great if given a PR’s diff, cursor could generate a PR description. Is there a way to do this now?

6 Likes

Hi @oveddan

Right now, no, I’ve passed the feature request on to the devs.

@oveddan not sure how much prompting you are OK with doing but I am sure you can do it by modifying my existing prompt, push it to a git repo, crawl it with cursor’s doc crawling feature and use it as:

@create-description @PR Diff

1 Like

This is my semi hacky way to do things. I squash the commits in the PR into one.

Then I run:
git diff HEAD~1 >> dif.txt

I then prompt cursor to make a pr description from that file

5 Likes

Smart!

Here’s how I just did this:

  • in the terminal, use Cmd K and ask cursor to diff with main and output that into a pull request summary in pr_request.md
  • use Cmd+I to activate composer, ask to update @pr_request.md to remove diff and make pr request a better, more human summary, referencing and closing the issue
  • in github pull requests view, I created a new pull request and copied the contents of pr_request.md in, creating the pull request

Perhaps I’ll find a better way to automate this using something like “Project Rules”; see also Using the “project-rules” in 0.45.2 - Discussion - Cursor - Community Forum

Wow, this is next level @gokcin - are you still using this often? here, is @create-description the name of the “doc” indexed with @Docs, or is there some other way to run a prompt? I can’t seem to find much info on this custom prompting technique on cursor’s website, is it pretty much just through @Docs or is there some other way you are using prompting?

hello @codekiln and thanks!

yes I am generating my prs and commits on a daily basis with the prompts in that are included in that repository which are crawled with the docs feature. and yes you just reference the crawled doc with @ and than add whatever you want as additional context.

To answer your other question about easier ways of prompting in cursor, when I discovered this usage, cursor did not have the notepads feature so you can accomplish the same result by creating a notepad(cmd + shift + pNotepad: Create and Open New Notepad) and than reference it with @ with the same name if you want simplify the process. However I like putting my prompts under version control so thats why I have not changed my approach.

On an unrelated note about creating custom prompts in an easy way, I have a tip for you. There is an amazing CLI tool called fabric which is like a huge collection of amazing prompts that you can use with local/cloud LLMs. One specific pattern there gave me inspiration to use the create_pattern pattern and create this prompt in my repo that just creates prompts. So what you can do is to add the prompt generator prompt to a notepad, name it as generate-prompt and than when you want to create a new prompt, mention it with @generate-prompt <what you want your prompt to do in plain text english> and than paste the nicely formatted markdown output to a new prompt and use it.

1 Like

So with github cli, you can create PRs, through your terminal. You can combine this with advanced prompting and make cursor output the github cli command that creates the PR. Here is an example that uses this prompt and claude-3.5-sonnet to create this pr. The trick is to force cursor to output the cli command under backticks and bash as the language so that the play icon appears and you just click and boom :slight_smile:

2025-01-30 15.17.30

2 Likes

I used the new cursor commands feature for this, then I created a file called generate-pr-description.md under .cursor/commands folder with the following content

# Generate PR Description Command

## Overview

Analyze the git diff in pr-diff.txt and create a comprehensive PR description (max 300 words) highlighting:

- High-level architectural changes
- Key features, added/modified
- Performance improvements
- Breaking changes (if any)
- Business impact
 
Focus on the 'why' and 'what' rather than detailed code changes.

**IMPORTANT**: Output ONLY the PR description markdown content that can be copied directly to GitHub/Azure DevOps. Do not include any AI commentary, tool execution details, or explanatory text. Start directly with the PR title and content.

After generating the PR description, clean up by deleting pr-diff.txt file.

## Manual Workflow

1. **Generate diff**: `git diff main > pr-diff.txt`
2. **Analyze with AI**: Use this prompt with the generated file
3. **Cleanup**: `rm pr-diff.txt` (or `del pr-diff.txt` on Windows)

## AI Prompt Template

```
Based on the git diff in pr-diff.txt, create a comprehensive PR description (max 300 words).

**CRITICAL**: Output ONLY the markdown PR description content. No AI commentary, no tool execution details, no explanatory text. Start immediately with the PR title and description that can be copied directly to GitHub/Azure DevOps.

Include these sections:

## Overview
Brief summary of what this PR accomplishes

## 🏗️ High-Level Architectural Changes
Focus on system design changes, new patterns, architectural decisions

## 🎯 Key Features
Major features added, modified, or removed

## 🚀 Performance & Operational Improvements
Resource optimization, monitoring enhancements, deployment improvements

## 🔄 Service Changes
How each service/component behavior changed

## 🎯 Business Impact
Reliability, operational excellence, developer experience improvements

## Technical Details
- Files changed: X files (Y added, Z modified, W deleted)
- Breaking changes: None/List them
- Related issue: #XXXXX

Focus on architectural significance rather than implementation details.
```

## PowerShell Script Alternative

Create `generate-pr-description.ps1`:

```powershell
#!/usr/bin/env pwsh
param(
    [string]$BaseBranch = "main",
    [string]$OutputFile = "pr-diff.txt"
)

Write-Host "🔍 Generating diff against $BaseBranch..." -ForegroundColor Cyan
git diff $BaseBranch > $OutputFile

$fileCount = (git diff --name-only $BaseBranch | Measure-Object).Count
$stats = git diff --stat $BaseBranch

Write-Host "📊 Changes Summary:" -ForegroundColor Green
Write-Host "Files changed: $fileCount" -ForegroundColor Yellow
Write-Host $stats -ForegroundColor Gray

Write-Host "`n✅ Generated $OutputFile" -ForegroundColor Green
Write-Host "💡 Next: Ask AI to analyze the diff and generate PR description" -ForegroundColor Blue
Write-Host "🧹 Remember to delete $OutputFile after generating the description" -ForegroundColor Yellow
```

Usage: `./generate-pr-description.ps1 -BaseBranch origin/main`

Then I simply invoke it with /generate-pr-description job done.

1 Like