Skill: Push Changes and Create Pull Request
Use this skill only when the working tree contains changes and the intent is to push those changes and open a pull request on GitHub.
This skill assumes:
- •A git repository already exists
- •A remote
originis configured - •The user wants a clean, review-ready pull request
Entry Conditions
Invoke this skill when:
- •
git statusshows modified, added, or deleted files - •The user asks to push changes, open a PR, or "create a pull request"
- •The task implies code review or merging into a base branch
Do NOT use this skill for:
- •Repository initialization
- •Complex rebases or conflict resolution
- •Multi-branch release orchestration
Execution Flow
1) Inspect Working Tree
- •Run
git status --short - •If no changes are present, stop and report that no action is required
- •If changes exist, proceed
2) Determine Branch Context
- •Identify current branch
- •If on a protected branch (e.g.
main,master,develop):- •Create a new feature branch using a descriptive name derived from changes
- •Checkout the new branch
- •If already on a non-protected branch, continue
3) Stage Changes
- •Stage all relevant files using
git add . - •If large or unrelated changes are detected, suggest splitting commits
4) Commit Changes
- •Generate a concise, descriptive commit message (less than 50 characters when possible)
- •Follow conventional commit style:
- •
feat:for new features - •
fix:for bug fixes - •
docs:for documentation changes - •
refactor:for code refactoring - •
test:for test additions/changes - •
chore:for maintenance tasks
- •
- •Use commit body only if absolutely required for additional context
- •Create the commit using
git commit -m 'message'
5) Push Branch
- •Push the current branch to
originusinggit push - •Set upstream tracking if not already configured
6) Create Pull Request Using GitHub CLI
REQUIRED: Use gh pr create with the following parameters:
- •
--title: Derived from commit message or change summary - •
--body: Include:- •Summary of changes
- •Reason for change
- •Testing performed (if detectable)
- •
--base main: Target the main branch - •
--label: Add appropriate label(s):- •
bugfor bug fixes - •
enhancementfor improvements - •
featurefor new features - •
bugfixfor bug repairs - •
workflowfor workflow/CI changes - •
documentationfor docs changes
- •
Example command:
bash
gh pr create --title "feat: add user validation" --body "Added input validation for user registration form" --base main --label feature
7) Final Output
- •Confirm:
- •Branch name
- •Commit hash
- •Pull request URL
- •Provide a brief summary of actions taken
8) Merge Pull Request Using GitHub CLI
When user requests to merge a PR:
- •Use
gh pr merge <number> --mergecommand- •IMPORTANT: Always use
--mergeflag (creates merge commit) - •Do NOT use
--squashor--rebaseunless explicitly requested
- •IMPORTANT: Always use
- •After successful merge, ALWAYS run post-merge cleanup
9) After Merging PR (Post-Merge Cleanup)
IMPORTANT: When a pull request is merged:
- •ALWAYS run
git checkout main && git pullto:- •Switch back to the main branch
- •Pull the latest merged changes from remote
- •Ensure local main branch is up-to-date
- •This prevents working on stale branches
- •Keeps the local repository synchronized with remote
Example workflow:
bash
gh pr merge 7 --merge git checkout main && git pull
Expected Behavior Examples
Example 1
User prompt:
“Push my changes and open a PR.”
Actions:
- •Detect modified files
- •Create feature branch if needed
- •Commit changes
- •Push to origin
- •Open PR against
main
Example 2
User prompt:
“I’m done with this feature, create a pull request.”
Actions:
- •Stage all changes
- •Commit with feature-appropriate message
- •Push branch
- •Generate PR with summary and test notes
Failure Handling
- •If push fails → explain cause and corrective action
- •If PR creation fails → provide CLI output and next steps
- •If authentication is missing → instruct how to authenticate with GitHub CLI
Constraints
- •Do not modify commit history unless explicitly requested
- •Do not rebase or squash unless instructed
- •MUST use GitHub CLI (
gh pr create) for creating pull requests - •MUST use GitHub CLI (
gh pr merge) for merging pull requests - •Always include appropriate labels when creating PRs
This skill is optimized for fast, safe PR creation and merging from local changes using GitHub CLI exclusively.