# Pr Create - Prepare and Push Feature Branch Commits for PR

Prepare clean, atomic commits for the current feature branch, push to remote, and create or update a PR to main. Requires a feature branch, not main, and a plan doc in `docs/plans/completed/`.

**Canonical URL:** https://skillshunter.net/skills/discovered-853ebeca47c147395471d3891974fd68d562a527ce1d5b0d

**JSON URL:** https://skillshunter.net/api/public/v1/skills/discovered-853ebeca47c147395471d3891974fd68d562a527ce1d5b0d

**Markdown URL:** https://skillshunter.net/skills/discovered-853ebeca47c147395471d3891974fd68d562a527ce1d5b0d.md

**Instructions download URL:** https://skillshunter.net/skills/discovered-853ebeca47c147395471d3891974fd68d562a527ce1d5b0d/download

**Category:** Software & Development

**Source URL:** https://github.com/AnotherSava/claude-code-common/blob/1a7f9f9cce53f6946ae1e3a9cc0733f2524a4b93/claude/skills/pr-create/SKILL.md

**Source commit:** 1a7f9f9cce53f6946ae1e3a9cc0733f2524a4b93

**Listing approved at:** 2026-12-01

**Created at:** 2026-11-30T08:08:19.000000Z

**Updated at:** 2026-12-01T12:48:20.000000Z

## Catalog information

The following descriptions are catalog information. Listing approval does not mean the skill has been tested or is safe for every environment.

### Editor's note

Ensure the current branch is not `main` and that there are commits ahead of `main` or uncommitted changes. Locate the latest completed plan doc in `docs/plans/completed/` to guide commit messages and PR description.

### When to use it

- Prepare and push feature branch commits for a PR
- Update an existing PR with new commits
- Ensure commits are based on the latest main branch
- Create a PR with a detailed description from a plan doc

## Skill instructions

---
name: pr-create
description: Prepare commits for the current feature branch, push, and create or update a PR to main.
allowed-tools: Bash(git status:*), Bash(git log:*), Bash(git diff:*), Bash(git reset --soft:*), Bash(python ~/.claude/skills/shared/commit.py:*), Bash(python3 ~/.claude/skills/shared/commit.py:*), Bash(git push:*), Bash(git rev-parse:*), Bash(git branch:*), Bash(git fetch:*), Bash(git checkout:*), Bash(git merge:*), Bash(git rebase:*), Bash(gh pr create:*), Bash(gh pr view:*), Bash(gh pr edit:*), Bash(ls:*), Bash(python ~/.claude/skills/shared/gate_pushed_tree.py:*), Bash(python3 ~/.claude/skills/shared/gate_pushed_tree.py:*), Bash(python ~/.claude/scripts/review_scope.py status), Bash(python3 ~/.claude/scripts/review_scope.py status), Bash(python ~/.claude/scripts/review_scope.py forecast), Bash(python3 ~/.claude/scripts/review_scope.py forecast), Read, Glob, Grep
---

# Create PR for Plan-Based Changes

Prepare commits on the current feature branch, push, and create or update a PR to main.

Read `~/.claude/skills/shared/bash-rules.md` for bash command constraints.

## Context
- Repo root: !`git rev-parse --show-toplevel 2>/dev/null || pwd`
- Current branch: !`git rev-parse --abbrev-ref HEAD`
- Working tree status: !`git status --short`
- Commits ahead of main: !`git log main..HEAD --oneline`

## Working directory

`docs/plans/` and any other file paths in this skill are relative to **Repo root** from Context. The cwd may be a subdirectory — prefix Repo root when calling Read/Glob/Grep/ls. Bare paths are cwd-relative and will silently miss plans at the actual root.

## Workflow

### Step 1: Gather context

1. Use **Current branch** from context. If on `main`, abort — the user must check out the feature branch first.

2. Use **Working tree status** and **Commits ahead of main** from context. Abort if there are no commits ahead of main and no uncommitted changes.

3. Find the latest completed plan doc — look in `docs/plans/completed/` for the most recently created file whose name relates to the current branch or the work described in the commits.

4. Read the plan to understand the scope and intent of the changes.

### Step 2: Prepare commits

Reset commits back to the working tree and re-commit them as clean, atomic commits:

1. Run `/reset` — let the user choose which commits to reset.

2. Group the change set as `~/.claude/skills/shared/commit-grouping.md` describes, drawing on the plan doc for the messages, and show the plan for the user's approval. Then commit each group with `python ~/.claude/skills/shared/commit.py -F <message-file> <paths…>` (`python3` on macOS), which stages exactly those paths, checks the message, scans what they add and signs the commit.

### Step 3: Rebase onto main

Ensure commits are based on the latest main so pr-merge can fast-forward:
```
git fetch origin main
git rebase main
```
If the rebase produces conflicts, stop and ask the user to resolve them.

### Step 4: Push and create/update PR

1. Push the branch. Gate the published state first, then use `--force-with-lease` if the remote branch already exists (commits were reset and recommitted), with the review bookmark's forecast before the push and its status after, as `~/.claude/skills/shared/review-bookmark-status.md` describes:
   ```
   python ~/.claude/skills/shared/gate_pushed_tree.py --caller pr-create
   python ~/.claude/scripts/review_scope.py forecast
   git push -u origin <branch-name> --force-with-lease
   python ~/.claude/scripts/review_scope.py status
   ```
   Use `python3` on macOS. For a new remote branch, a regular push works too — `--force-with-lease` is safe either way.

   A non-zero exit stops the push. The branch's commits were written here and never measured against the repo's own gate, and a reviewer reading the PR cannot see that: the gate runs on a working tree, so a branch that fails it looks the same on GitHub as one that passes.

2. Draft the PR description. The PR body should be **more detailed than the commit message** — it is the primary review artifact. Build it from the plan doc and diff:

   - **Overview**: 2-3 sentences on what this PR accomplishes and why (from the plan's Overview section)
   - **What changed**: bulleted list of concrete changes grouped by area (new modules, modified behavior, structural changes, test coverage). Derive from the diff, not just the plan — if the implementation added things not in the original plan, include them here.
   - **Design decisions**: key trade-offs and rationale (from plan's Design Notes). Highlight anything a reviewer should pay attention to.
   - **Scope reconciliation**: compare the plan against the actual diff. If the implementation diverged from the plan (added features, dropped features, changed approach), note the differences and why.
   - **Plan reference**: link to the plan document filename
   - **Test coverage**: summary of test files and what they cover

3. Check if a PR already exists for this branch: `gh pr view --json number,title,url`. If the command fails, no PR exists.

   **If no PR exists** — create one:
   ```
   gh pr create --base main --title "<title>" --body "<PR description>"
   ```

   **If a PR already exists** — update it with the new description:
   ```
   gh pr edit --title "<title>" --body "<PR description>"
   ```

4. Report the PR URL to the user, then close the report as `~/.claude/skills/shared/review-bookmark-status.md` describes.

