Workflow
Confirm the user asked — in their latest message. Pushing to a remote / opening a PR is outward-facing and hard to undo. Do it only when the user's most recent request actually says to push, ship, or open a PR. Approval from an earlier turn does not carry forward — "make the change" is not "push it." If you finished work and the user didn't ask to push, stop and ask. Never push proactively.
Branch off the default branch. Unless the user explicitly says to push straight to main (e.g. "commit straight to main", "push to main directly"), create a feature branch named with Conventional Commits:
<type>/<kebab-description>, e.g.feat/add-logout-button.Commit with a Conventional Commit message, then push the branch. Always make a new commit. Never force-push (
git push --force/--force-with-lease) and never amend (git commit --amend) or otherwise rewrite existing commits — unless the user explicitly asks for it in their latest message. To update a PR or fix a previous commit, add another commit and push normally.Open the PR with a Conventional-Commit title (
<type>[(scope)][!]: <subject>, e.g.feat(auth): add OAuth login). For the body: if a.githubPR template exists, use it verbatim and add no extra sections, summaries, or "test plan" fields. If there's no template, keep the body to a one-line description — don't invent a template.
type is one of: feat fix docs style refactor perf test build ci chore revert.
Notes
- Default branch: the base for the PR is the repo's default branch — read it
from
origin/HEAD, falling back tomain. - Branch names: lowercase the description, replace spaces and punctuation
with dashes, prefix the type —
"Add Login (OAuth)"with typefeat→feat/add-login-oauth. - Finding the PR template: check
.github/PULL_REQUEST_TEMPLATE.mdfirst, then the lowercase variant, then the repo root, thendocs/. The.github/PULL_REQUEST_TEMPLATE/directory form holds multiple templates — if the repo uses it, pass the chosen file togh pr create --body-file. - Opening the PR:
gh pr create --base <default-branch> --title "<conventional title>"with--body-file <template>when a template exists, or a one-line--bodywhen it doesn't.
Gotchas
- "The user asked earlier" is not the latest message. Step 1 is about the most recent request. If it was "fix the bug" and you fixed it, you have not been asked to push. Ask first.
- A PR template is not a checklist for you to fill in. Use it verbatim as the body; leave its checkboxes/headings exactly as written unless the user fills them. Stacking your own "## Summary / ## Test plan" on top of an existing template is wrong.
- Never rewrite history to "clean up." Force-pushing and amending are destructive and break anyone who pulled the branch. Even when a previous commit was wrong, the default is a new follow-up commit, not an amend or force-push. Only rewrite when the user explicitly tells you to in their latest message.
- The template lookup checks
.githubfirst, then the repo root, thendocs/, and includes the.github/PULL_REQUEST_TEMPLATE/directory form (multiple templates). If the repo has several, ask which to use.
Troubleshooting
gh pr createfails withno default remote repository→ rungh repo set-default <owner>/<repo>once, or pass--repo <owner>/<repo>.gh: not authenticated→ the user must rungh auth loginthemselves (suggest they type! gh auth login). Don't authenticate for them.