Commit staged changes, push branch, and open a GitHub PR. Use when user asks to commit and push, create a PR, ship changes, send for review, or open a pull request. Triggers on phrases like 'commit and push', 'create a PR', 'open a pull request', 'send this for review', 'ship it', 'push and PR'.
git status shows a clean working tree with nothing to commitgit status shows no unpushed commitsgh pr view returns a valid URLGather state before acting:
git branch --show-currentgit statusgit diff HEADBefore doing anything, verify:
git status shows nothing to commit (clean working tree), stop and tell the user. Do not create empty commits.gh auth status. If not authenticated, stop and ask user to authenticate first.gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' over assumptions.If on main/master or detached HEAD, create a feature branch:
<type>/<short-description> where type is one of: feat, fix, chore, docs, refactor, test, cifeat/add-user-search, fix/null-pointer-on-login, docs/update-readmegit checkout -b <branch-name> to create and switchStage changes if not already staged, then commit:
Fixes #123 or Closes #456.env, credentials.json, *.pem, *.key)Push the branch to origin:
git push -u origin <branch-name>
If push fails:
gh auth statusgit remote -v and reportCreate a PR using gh pr create:
gh pr create --base "<base-branch>" --head "<branch-name>" --title "<imperative summary>" --body-file "<path>"
PR body structure:
If the repo has a PR template, gh pr create will use it automatically. Do not override templates.
Before creating, check if PR already exists for this branch:
gh pr view --head "<branch-name>" --json url --jq '.url'
If that returns a URL, report it and do not create a duplicate PR.
When generating PR body text, NEVER inline complex markdown in --body if it may contain shell-sensitive characters (especially backticks). Use a body file:
tmp_pr_body="$(mktemp)"
cat > "$tmp_pr_body" <<'EOF'
## Summary
- <what changed and why>
## Test plan
- [ ] <how to verify>
EOF
gh pr create --base "<base-branch>" --head "<branch-name>" --title "<title>" --body-file "$tmp_pr_body"
rm -f "$tmp_pr_body"
If gh pr create fails, handle by error pattern:
error connecting to api.github.com / network denied: retry once; if sandbox/network restrictions apply, rerun with escalated network permissions.A pull request already exists: run gh pr view --head "<branch-name>" --json url --jq '.url' and report existing URL.not logged into any GitHub hosts: stop and ask user to run gh auth login.No commits between: branch has no diff against base; report and stop.permission denied/command not found lines caused by PR body text: this usually means shell interpolation from unescaped markdown; rerun using --body-file.gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name' and retry with explicit --base.After all steps complete, report:
| Situation | Action |
|---|---|
| No changes to commit | Stop. Tell the user there's nothing to commit. |
| Already on a feature branch | Use it. Don't create a new one. |
| Existing PR for this branch | Tell the user a PR already exists. Show the URL with gh pr view. |
| Merge conflicts on push | Do not force push. Tell the user to pull and resolve. |
| Uncommitted changes + staged changes | Commit only what's staged. Warn about unstaged changes. |
| Binary files in diff | Warn the user. Include them only if intentional. |
| Sensitive-looking files (.env, keys) | Do NOT stage or commit. Warn the user. |
You MUST call multiple tools in a single response when the calls are independent. For example, git add and git status can be parallel. But git commit must follow git add, and git push must follow git commit. Chain dependent operations sequentially.
If the harness supports command files, use commands/commit-push-pr.md as the canonical entrypoint for this skill.