PR Preparer Skill
This skill guides the AI assistant in comparing the current branch against the base/default branch (develop, main, master), analyzing all added, modified, and deleted files, and generating a conventional commit title, PR title, and a comprehensive, GitHub-ready markdown PR description.
Workflow Steps
Step 1: Determine the Base Branch & Diff Scope
- Identify the current branch and default target branch:
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
BASE_BRANCH=$(gh pr view --json baseRefName --jq '.baseRefName' 2>/dev/null || git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@refs/remotes/origin/@@' || echo "develop")
- Empty Diff & Branch Validation Check:
Run a diff check against $BASE_BRANCH and working directory:
BRANCH_DIFF=$(git diff --name-only "$BASE_BRANCH"...HEAD)
WORKING_DIFF=$(git status -s)
Case A: Zero changes anywhere (branch is identical to base & working tree is clean):
Case B: Same branch or uncommitted-only changes:
Case C: Feature branch with committed changes (Standard Flow):
Step 2: Analyze Code Changes
Fetch detailed diffs to understand the scope and intent of all changes:
git diff "$BASE_BRANCH"...HEAD
Categorize all changed files:
- 🟢 Added (
[NEW]): Newly created files, modules, scripts, or tests.
- 🟡 Modified (
[MODIFY]): Updated configuration, refactored logic, schema edits, or updated docs.
- 🔴 Deleted (
[DELETE]): Removed obsolete files, dead code, or redundant scripts.
Identify key themes and impact:
- Architecture & logic changes.
- Dependency or configuration updates.
- CI/CD workflow modifications.
- Database migrations or schema updates.
- Documentation adjustments.
Step 3: Format Conventional Commit & PR Details
Generate output with clear separation between titles and description, using formatted markdown blocks for easy one-click copy/pasting.
Format Template:
### 📝 Conventional Commit Title
```text
<type>(<scope>): <short imperative summary in lower case, max 72 chars>
```
---
### 🔤 Pull Request Title
```text
<Type>: <Capitalized Concise Description of PR Goal>
```
---
### 📄 Pull Request Description
```markdown
## 📌 Overview
<Brief 2-3 sentence overview explaining the problem, context, and what this PR accomplishes.>
---
## 🛠 Key Changes
### [Component / Feature Area 1]
- 🟢 `path/to/new_file`: Brief description of what was added.
- 🟡 `path/to/modified_file`: Brief description of what changed.
### [Component / Feature Area 2]
- 🔴 `path/to/deleted_file`: Brief description of why this file was removed.
---
## 🧪 Verification & Testing
- [x] Ran unit tests: `uv run python manage.py test --settings=besties_backend.test_settings_sqlite`
- [x] Ran linters/pre-commit: `uv run pre-commit run --all-files`
- [x] Manual verification steps performed.
---
## ⚠️ Notes & Risk Assessment
- **Breaking Changes:** None / <List breaking changes if any>
- **Migration Required:** No / Yes (`python manage.py migrate`)
- **Environment Variables:** No new env vars required / <List new env vars>
```
Guidelines & Best Practices
- Conventional Commit Types: Use
feat, fix, refactor, chore, docs, test, ci, or style.
- Imperative Mood: Use imperative present tense in titles ("add feature" instead of "added feature").
- Concise Summaries: Group individual file changes by logical component (e.g., API, Database, CI/CD, Documentation) rather than listing random files.
- Copy/Paste Friendly: Always enclose output in markdown fenced code blocks (
```text and ```markdown).
1---2name: pr-preparer3description: Analyzes git branch diffs (added, modified, deleted files) against the default or target branch, and generates a conventional commit title, PR title, and formatted markdown PR description for copy-pasting to GitHub. Use when the user asks to prepare a PR, generate a PR description, generate a commit message, summarize branch changes, or create a PR template.4---56# PR Preparer Skill78This skill guides the AI assistant in comparing the current branch against the base/default branch (`develop`, `main`, `master`), analyzing all added, modified, and deleted files, and generating a conventional commit title, PR title, and a comprehensive, GitHub-ready markdown PR description.910---1112## Workflow Steps1314### Step 1: Determine the Base Branch & Diff Scope15161. **Identify the current branch and default target branch:**17 ```bash18 CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)19 BASE_BRANCH=$(gh pr view --json baseRefName --jq '.baseRefName' 2>/dev/null || git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@refs/remotes/origin/@@' || echo "develop")20 ```212. **Empty Diff & Branch Validation Check:**22 - Run a diff check against `$BASE_BRANCH` and working directory:23 ```bash24 BRANCH_DIFF=$(git diff --name-only "$BASE_BRANCH"...HEAD)25 WORKING_DIFF=$(git status -s)26 ```27 - **Case A: Zero changes anywhere (branch is identical to base & working tree is clean):**28 - Notify the user:29 ```markdown30 ℹ️ No changes detected on branch `<CURRENT_BRANCH>` compared to `<BASE_BRANCH>`.31 Please make code edits or switch to a branch with changes before running PR preparation.32 ```33 - Exit early without generating a PR description.3435 - **Case B: Same branch or uncommitted-only changes:**36 - If `CURRENT_BRANCH == BASE_BRANCH` or `BRANCH_DIFF` is empty, but `WORKING_DIFF` has local edits, analyze uncommitted changes against `HEAD`:37 ```bash38 git diff HEAD39 git status -s40 ```4142 - **Case C: Feature branch with committed changes (Standard Flow):**43 - Compare branch changes against `$BASE_BRANCH`:44 ```bash45 git diff --stat "$BASE_BRANCH"...HEAD46 git status -s47 ```4849---5051### Step 2: Analyze Code Changes52531. **Fetch detailed diffs** to understand the scope and intent of all changes:54 ```bash55 git diff "$BASE_BRANCH"...HEAD56 ```572. **Categorize all changed files:**58 - 🟢 **Added (`[NEW]`)**: Newly created files, modules, scripts, or tests.59 - 🟡 **Modified (`[MODIFY]`)**: Updated configuration, refactored logic, schema edits, or updated docs.60 - 🔴 **Deleted (`[DELETE]`)**: Removed obsolete files, dead code, or redundant scripts.61623. **Identify key themes and impact:**63 - Architecture & logic changes.64 - Dependency or configuration updates.65 - CI/CD workflow modifications.66 - Database migrations or schema updates.67 - Documentation adjustments.6869---7071### Step 3: Format Conventional Commit & PR Details7273Generate output with clear separation between titles and description, using formatted markdown blocks for easy one-click copy/pasting.7475#### Format Template:7677````markdown78### 📝 Conventional Commit Title7980```text81<type>(<scope>): <short imperative summary in lower case, max 72 chars>82```8384---8586### 🔤 Pull Request Title8788```text89<Type>: <Capitalized Concise Description of PR Goal>90```9192---9394### 📄 Pull Request Description9596```markdown97## 📌 Overview9899<Brief 2-3 sentence overview explaining the problem, context, and what this PR accomplishes.>100101---102103## 🛠 Key Changes104105### [Component / Feature Area 1]106107- 🟢 `path/to/new_file`: Brief description of what was added.108- 🟡 `path/to/modified_file`: Brief description of what changed.109110### [Component / Feature Area 2]111112- 🔴 `path/to/deleted_file`: Brief description of why this file was removed.113114---115116## 🧪 Verification & Testing117118- [x] Ran unit tests: `uv run python manage.py test --settings=besties_backend.test_settings_sqlite`119- [x] Ran linters/pre-commit: `uv run pre-commit run --all-files`120- [x] Manual verification steps performed.121122---123124## ⚠️ Notes & Risk Assessment125126- **Breaking Changes:** None / <List breaking changes if any>127- **Migration Required:** No / Yes (`python manage.py migrate`)128- **Environment Variables:** No new env vars required / <List new env vars>129```130````131132---133134## Guidelines & Best Practices135136- **Conventional Commit Types**: Use `feat`, `fix`, `refactor`, `chore`, `docs`, `test`, `ci`, or `style`.137- **Imperative Mood**: Use imperative present tense in titles ("add feature" instead of "added feature").138- **Concise Summaries**: Group individual file changes by logical component (e.g., API, Database, CI/CD, Documentation) rather than listing random files.139- **Copy/Paste Friendly**: Always enclose output in markdown fenced code blocks (` ```text ` and ` ```markdown `).