| name | push |
| description | Push current branch changes to origin and create or update the corresponding pull request; use when asked to push, publish updates, or create pull request. |
Push
Prerequisites
gh CLI is installed and available in PATH.
gh auth status succeeds for GitHub operations in this repo.
Goals
- Push current branch changes to
origin safely.
- Create a PR if none exists for the branch, otherwise update the existing PR.
- Keep branch history clean when remote has moved.
Related Skills
pull: use this when push is rejected or sync is not clean (non-fast-forward,
merge conflict risk, or stale branch).
Steps
-
Identify current branch and confirm remote state.
-
Run local validation that matches the changed surface before pushing:
- Always run
git diff --check.
- For Rust changes, prefer the repo DuckDB aliases from
AGENTS.md
(cargo check-system-duckdb, focused cargo test-system-duckdb ..., or
fallback dev aliases if system DuckDB is unavailable).
- For frontend/TypeScript changes, run
npm run type-check plus focused
Jest/build commands for the touched packages.
- For docs-only changes, run the relevant docs parser/linter or explain why
git diff --check is sufficient.
-
Push branch to origin with upstream tracking if needed, using whatever
remote URL is already configured.
-
If push is not clean/rejected:
- If the failure is a non-fast-forward or sync problem, run the
pull
skill to merge the configured target branch, resolve conflicts, and rerun
validation.
- Push again; use
--force-with-lease only when history was rewritten.
- If the failure is due to auth, permissions, or workflow restrictions on
the configured remote, stop and surface the exact error instead of
rewriting remotes or switching protocols as a workaround.
-
Ensure a PR exists for the branch:
- Read
WORKFLOW.md Target branch: and use it as the PR base.
- If no PR exists, create one against the configured target branch.
- If a PR exists and is open, update it and correct the base if needed.
- If branch is tied to a closed/merged PR, create a new branch + PR.
- Write a proper PR title that clearly describes the change outcome
- For branch updates, explicitly reconsider whether current PR title still
matches the latest scope; update it if it no longer does.
-
Write/update PR body explicitly using .github/pull_request_template.md:
- Fill every section with concrete content for this change.
- Replace all placeholder comments (
<!-- ... -->).
- Keep bullets/checkboxes where template expects them.
- If PR already exists, refresh body content so it reflects the total PR
scope (all intended work on the branch), not just the newest commits,
including newly added work, removed work, or changed approach.
- Do not reuse stale description text from earlier iterations.
-
If the repo has a PR body checker, run it and fix all reported issues.
Otherwise, manually ensure the PR body has no placeholders and matches the
current diff.
-
Reply with the PR URL from gh pr view.
Commands
branch=$(git branch --show-current)
git diff --check
git push -u origin HEAD
git push -u origin HEAD
git push --force-with-lease origin HEAD
target_branch=$(awk -F': *' '/^Target branch:/ { branch=$2; gsub(/`/, "", branch); gsub(/\r/, "", branch); gsub(/^[ \t]+|[ \t]+$/, "", branch); print branch; exit }' WORKFLOW.md)
if [ -z "$target_branch" ]; then
echo "WORKFLOW.md is missing a Target branch marker; run opensymphony update --target-branch <branch> before creating or retargeting a PR." >&2
exit 1
fi
pr_state=$(gh pr view --json state -q .state 2>/dev/null || true)
if [ "$pr_state" = "MERGED" ] || [ "$pr_state" = "CLOSED" ]; then
echo "Current branch is tied to a closed PR; create a new branch + PR." >&2
exit 1
fi
pr_title="<clear PR title written for this change>"
if [ -z "$pr_state" ]; then
gh pr create --base "$target_branch" --title "$pr_title"
else
current_base=$(gh pr view --json baseRefName -q .baseRefName)
if [ "$current_base" != "$target_branch" ]; then
gh pr edit --base "$target_branch"
fi
gh pr edit --title "$pr_title"
fi
tmp_pr_body=$(mktemp)
gh pr view --json body -q .body > "$tmp_pr_body"
if [ -x scripts/check-pr-body ]; then
scripts/check-pr-body "$tmp_pr_body"
else
! rg -n "<!--|TODO|TBD" "$tmp_pr_body"
fi
rm -f "$tmp_pr_body"
gh pr view --json url -q .url
Notes
- Do not use
--force; only use --force-with-lease as the last resort.
- Distinguish sync problems from remote auth/permission problems:
- Use the
pull skill for non-fast-forward or stale-branch issues.
- Surface auth, permissions, or workflow restrictions directly instead of
changing remotes or protocols.