Use when working in a git repository hosted on GitHub and handling branch creation, commits, pushes, pull requests, reviews, or merges with gh CLI available.
Use a hybrid workflow: prefer gh for GitHub-aware tasks, and use git for local history editing, staging, and branch mechanics.
Opinionated defaults:
Run these before branching or opening a PR:
gh auth status
git remote -v
gh repo view --json nameWithOwner,defaultBranchRef
Confirm:
gh is authenticatedmain or masterIf fails because the current repo is not connected to GitHub, fall back to plain and ask before attempting GitHub-specific actions.
gh repo viewgitUse gh for | Use git for |
|---|---|
| auth and repo checks | staging files |
| PR create/view/checkout/review/merge | commit creation/amend/rebase |
| PR status and checks | switching branches |
| opening web pages for repo or PR context | inspecting local diffs and history |
Fallback rule: if gh has a clean command for the task, prefer it. If the task is fundamentally local source control, use git.
Example:
git switch main
git pull --ff-only
git switch -c feat/add-github-workflow-skill
Recommended prefixes:
feat/fix/docs/chore/refactor/test/Avoid vague names like updates, stuff, or misc-fixes.
Use git for staging and committing. Keep commits small and readable.
git status
git add <paths>
git commit -m "feat: add github workflow skill"
Prefer conventional-commit-style summaries:
feat: add github workflow skillfix: correct PR base branch detectiondocs: document packaged skillschore: clean up release notesBefore pushing, review what changed:
git diff --staged
If a commit needs cleanup, use git commit --amend or interactive rebase deliberately. Do not use gh for local history surgery.
Push with git, then use gh to work with the PR.
git push -u origin HEAD
gh pr create --fill --base main
Useful gh commands:
gh pr status
gh pr view --web
gh pr checks
gh pr create --fill --base <default-branch>
gh pr checkout <number>
PR hygiene:
If --fill produces a weak title/body, replace it instead of accepting low-quality PR text.
Use gh to inspect and respond to review state.
gh pr view <number>
gh pr diff <number>
gh pr checks <number>
gh pr review <number> --comment -b "Looks good overall; left one suggestion."
gh pr review <number> --approve
gh pr review <number> --request-changes -b "Please address the failing tests and rename the branch."
When reviewing your own work, check:
Prefer gh pr merge so the merge action is tied to GitHub PR state.
gh pr merge <number> --squash --delete-branch
Common variants:
--squash for small or iterative branches--merge when the repo prefers merge commits--rebase when the repo explicitly prefers rebased historyBefore merging, confirm:
After merge, sync local state:
git switch main
git pull --ff-only
gh for tasks that are really local git operations-u and then losing the upstream linkStop and re-check before acting if you see any of these:
gh auth status is not healthyWhen unsure, inspect first, then act.