Create a PR from staged changes automatically

VerifiedCaution

Automatically creates a GitHub pull request from staged changes with generated branch, title, and description, including draft and fork options.

Sby Skills Guide Bot
DevelopmentIntermediate
11/22/2026
Claude Code
#pull-requests#git#github#automation#code-review

Recommended for

Automated summary

Creates a GitHub pull request from staged changes, generating a branch, title, and description and defaulting to a draft PR.

Strengths

  • Validates that staged changes exist and warns when unstaged work will be excluded.
  • Generates a short hyphenated branch/task name and derives a title and description from the diff and surrounding code.
  • Supports free-form hints for draft vs ready, fork pushes, base branch, project, change type, and branch reuse.
  • Defaults to draft PRs to avoid auto-assigning a random codeowner.

Limitations

  • Requires an authenticated GitHub CLI (`gh`) and a GitHub remote; it will not work with other forges.
  • Only staged changes are considered, and unstaged changes are deliberately ignored.
  • Relies on free-form parsing and repository `CONTRIBUTING.md` conventions, so ambiguous hints or missing conventions can reduce accuracy.
When to use it

Use it when staged changes are ready to be packaged into a GitHub pull request and you want the branch, title, and description drafted automatically.

When not to use it

Avoid it when you need to include unstaged or uncommitted work, or when the repository is not hosted on GitHub.

Security analysis

Caution
Quality score84/100

The skill is a workflow wrapper around ordinary git/gh commands (diff, branch, commit, push, PR create) with no exfiltration, obfuscation, destructive filesystem operations, or safety-disabling instructions. Its power comes from pushing commits and opening PRs, which is exactly the intended function and is gated behind an explicit user confirmation. Minor concerns are unbounded memory-file reads and unquoted interpolation of user-supplied $ARGUMENTS into shell commands.

Findings
  • •Skill executes state-modifying and networked commands (`git checkout -b`, `git commit`, `git push`, `gh pr create`, `gh api user`) — all legitimate for its purpose, but they do write to remotes and create PRs, so a mis-parsed instruction could push unintended code. Mitigated by an explicit confirmation gate (AskUserQuestion) before any mutating step.
  • •Instructs the agent to 'read relevant memory files' without specifying paths, leaving scope for the agent to read arbitrary files it deems 'memory'; low risk but unbounded.
  • •Free-form `$ARGUMENTS` are parsed heuristically (fork/reuse-branch/base/type) and injected into branch names and git/gh commands via shell; no quoting guidance is given for these interpolated values, so a crafted argument could contain shell metacharacters.
  • •Performs state-modifying and external side-effect commands (git checkout -b, git commit, git push -u, gh pr create, gh api user), though these are gated behind explicit AskUserQuestion confirmation and are legitimate for the stated purpose.
  • •PR title/commit message are model-generated from staged diff content and interpolated into shell commands inside double quotes (--title "<title>"), so a crafted diff could in principle inject command substitution into the title line; the HEREDOC bodies are safely quoted ('EOF') but the title is not.
  • •Step 0 tells the agent to 'read relevant memory files' without specifying paths or contents, leaving the directory/files read implementation-defined; not dangerous but underspecified.
How this analysis is made

Examples

Draft PR from staged changes
Create a draft PR from my staged changes, base it on master, and mention that this fixes the header validation bug.
Fork and ready-for-review
Open a ready-for-review pull request for the staged refactor, push it to my fork, and use type: refactor.
Ship staged work
Ship these staged changes to GitHub with an auto-generated branch and description.

name: pr description: Create a PR from staged changes with auto-generated branch, title, and description. Use this skill whenever the user wants to create a pull request, ship changes, open a PR, send code for review, or push staged work to GitHub — even if they don't explicitly say "PR". allowed-tools: Bash, Read, Grep, Glob, AskUserQuestion

Create a pull request with automatically generated title and description based on staged changes.

Before starting, read relevant memory files (especially PR-related feedback memories). Memory preferences override the defaults below.

User instructions: $ARGUMENTS

PRs are created as drafts by default (non-draft PRs auto-assign a random codeowner as reviewer, which then has to be reassigned).

If user instructions are non-empty, parse them for the following hints (they are free-form text, not structured flags):

  • "ready" (or "not draft", "no-draft", "non-draft") → create the PR as ready-for-review instead of a draft
  • "fork" → push to the user's own fork instead of origin
  • "reuse-branch" → reuse the current branch instead of creating a new one (default is to create a new branch)
  • A base branch (e.g., "base: shreyan/project/pr1", "base is master") → use as the PR base branch instead of auto-detecting
  • A project name (e.g., "project is spice", "project: resharding") → use as the project instead of auto-detecting
  • A change type (e.g., "type: fix", "type is refactor") → use as the change type instead of auto-detecting
  • Any other text → treat as extra context to incorporate into the PR description

Follow these steps in order:

  1. Validate:

    • Record the current branch name
    • Run git diff --cached to capture the staged diff. If empty, warn the user and stop
    • If there are unstaged changes, briefly warn the user that they won't be included in the PR
    • Do NOT analyze unstaged changes
    • Fetch the GitHub username by running: gh api user --jq .login
    • Determine reuse-branch and base branch:
      • If user instructions specify "reuse-branch", set reuse-branch = true.
      • Otherwise, set reuse-branch = false (this is the default).
      • Base branch: if user instructions specify a base branch, use that. If reuse-branch is true, use master. Otherwise, use the current branch.
      • When reuse-branch is true, use the current branch name as the branch name.
    • Detect push remote:
      • If user instructions contain "fork", determine the user's fork remote:
        1. List remotes: git remote -v
        2. Look for a remote whose URL contains the GitHub username (e.g., github.com/{username}/). This is the fork remote.
        3. Record the fork remote name for later use.
      • If "fork" is not specified, the push remote is origin.
  2. Analyze staged changes (reuse the diff output from Step 1):

    • Read the modified files to understand the surrounding code context
    • Identify the project/area (e.g., spice, resharding, state-sync, ci). If changes span multiple projects, pick the most dominant one. If user instructions specify a project, use that instead.
    • Read the CONTRIBUTING.md "## Pull Requests" section for valid change types and PR title conventions
    • Determine the change type (fix, feat, refactor, doc, test, chore, perf, revert). If multiple apply, pick the most dominant. If user instructions specify a type, use that instead.
    • Generate a short hyphenated task name, 2-4 words (e.g., add-metrics, fix-header-validation, refactor-chunk-apply)
  3. Generate all details — do NOT run any state-modifying commands (no creating branches, committing, or pushing) in this step:

    • Branch name (local) and remote branch name:
      • If reuse-branch is true: the local branch name is the current branch. Skip collision checks.
      • Otherwise, generate a new local branch name:
        • If pushing to a fork: {project}/{task}
        • If pushing to origin: {username}/{project}/{task}
        • Check for collisions: git branch --list <name> (local) and git ls-remote --heads <push-remote> <name> (remote)
        • On collision, append -2, -3, etc.
      • Remote branch name: when pushing to origin, the remote branch must have the {username}/ prefix. If the local branch name already starts with {username}/, the remote name is the same. Otherwise, prepend it: {username}/{local-branch-name}. When pushing to a fork, the remote branch name is the same as the local branch name.
    • Commit message: single line, same style as the PR title
    • PR title: <type>(<project>): <title> — title must be lowercase (per CONTRIBUTING.md)
      • Example: feat(state-sync): add metrics tracking
    • PR description:
      • Concise summary of what changed and why. Use prose, bullet points, or a mix — whatever fits the change best. A one-line description is fine for small changes.
      • Incorporate any extra context from user instructions
      • Do not include implementation details, test plan sections, or AI attribution
    • Draft: false if user instructions opt out via "ready" (or "not draft", "no-draft", "non-draft"), true otherwise
    • Push remote: the fork remote name if "fork" was specified, otherwise origin
  4. Confirm with user:

    • First, print the details in exactly this format (no horizontal rules, no extra fields):
      Branch: <local-branch-name> (remote: <remote-branch-name>)
      Push remote: <push-remote>
      Base branch: <base-branch>
      Draft: Yes/No
      
      PR title: <title>
      
      PR description:
      <description>
      
    • Then use AskUserQuestion with two options: "Yes, create PR" / "Abort"
      • Do NOT put the details inside the AskUserQuestion options
      • The user can select "Other" (built-in) to provide edits — apply their changes and re-confirm
    • If "Abort": stop immediately. Nothing was modified, so no cleanup is needed.
  5. Execute — only after user confirms:

    • If reuse-branch is false, create the branch: git checkout -b <branch-name>
    • Commit staged changes using a HEREDOC for the message:
      git commit -m "$(cat <<'EOF'
      <commit message>
      EOF
      )"
      
    • Push: git push -u <push-remote> <local-branch-name>:<remote-branch-name> (If local and remote names are the same, git push -u <push-remote> <branch-name> is fine.)
    • Create the PR using a HEREDOC for the body:
      • If pushing to a fork, use --head <username>:<remote-branch-name>:
        gh pr create --base <base-branch> --head <username>:<remote-branch-name> \
          --title "<title>" \
          --body "$(cat <<'EOF'
        <description>
        EOF
        )"
        
      • If pushing to origin, use --head <remote-branch-name>:
        gh pr create --base <base-branch> --head <remote-branch-name> \
          --title "<title>" \
          --body "$(cat <<'EOF'
        <description>
        EOF
        )"
        
      Add --draft if the draft flag is set.
    • Display the PR URL on success
    • If push or PR creation fails but the branch was already created locally, tell the user the branch exists and suggest how to retry

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/create-a-pr-from-staged-changes-automatically-mwpwqffk/download' --output '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md.part' && mv '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md.part' '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Bash, Read, Grep, Glob, AskUserQuestion

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md' && test -s '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/pr' && cp -R '.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk' '.claude/skills/pr'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk'

openskills read 'create-a-pr-from-staged-changes-automatically-mwpwqffk'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/create-a-pr-from-staged-changes-automatically-mwpwqffk/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills