git-branch-and-pr

Moves uncommitted changes from the default branch to a new feature branch as one commit and opens a pull request.

Updated Dec 18, 2025
One-click install
npx skills add https://github.com/l0lxl0lw/dotfiles --skill git-branch-and-pr-l0lxl0lw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-branch-and-pr
Source: https://github.com/l0lxl0lw/dotfiles/tree/main/ai/shared/skills/git/git-branch-and-pr
Command: npx skills add https://github.com/l0lxl0lw/dotfiles --skill git-branch-and-pr-l0lxl0lw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Uncommitted work often piles up directly on the default branch, where it cannot be reviewed or merged safely. This Skill moves that work onto a new feature branch as a single commit and opens a GitHub pull request, with repo-declared consistency checks gating the process. ## Core Features & Use Cases - Branch, commit, and PR in one flow: Analyzes the working tree, drafts a branch name, commit message, and PR title/body, then creates the branch, one commit, the push, and the PR after a single approval gate. - Repo-local pre-PR checks: Runs REQUIRED checks the repository declares in its own skills' pre-pr: frontmatter (spec drift, stale generated artifacts) and stops before creating anything if one fails. - Safety guardrails: Refuses to run off the default branch, warns about sensitive files when staging, rejects AI attribution in commits and PR bodies, and never force-pushes. - Use Case: You finished a bug fix but realize you are still on main with uncommitted changes. Ask to branch it and open a PR, review the proposed branch name, commit message, and PR body in one dialog, and get a PR URL back. ## Quick Start Ask the assistant to move my uncommitted changes on main to a new branch and open a pull request for them.

Frequently Asked Questions about git-branch-and-pr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I move uncommitted changes from main to a new branch and open a PR?

Run this Skill while on the default branch. It analyzes the working tree, drafts a branch name, commit message, and PR text, then after one approval creates the branch with git checkout -b, makes a single commit, pushes, and opens the PR with gh pr create.

What is the difference between git-branch-and-pr and git-pr?

git-branch-and-pr runs only on the default branch with uncommitted work, creating the branch and one commit before opening the PR. git-pr opens a PR for a branch that already exists with its own commits.

Can I open the pull request as a draft?

Yes. The single approval dialog includes an Open as draft option, which passes --draft to gh pr create. You can also request a draft in your original instruction.

Why does the Skill stop before creating the branch?

It stops when a REQUIRED repo-local pre-PR check fails, such as spec drift or stale generated artifacts declared in the repo's own skills. You choose to fix the drift, open the PR anyway with the drift recorded, or abort.

Does it work in a linked git worktree?

No. Worktree-based setups put you on a feature branch from the start, so this Skill is never reachable there. It detects the worktree and routes you to git-pr, which covers that flow including fresh worktrees with uncommitted work.

Will it commit sensitive files like .env or keys?

No. The staging script detects files matching patterns like .env, .pem, .key, .secret, .credentials, and .token, warns about them, and excludes them from automatic staging. You must stage such files manually if intended.