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 Borg UI validation appropriate to the changed files before pushing.
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 origin/main, 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:
- If no PR exists, create one.
- If a PR exists and is open, update it.
- 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.
Validate the PR body has no template comments or unresolved placeholders.
Reply with the PR URL from gh pr view.
Commands
# Identify branch
branch=$(git branch --show-current)
# Minimal validation gate for Borg UI setup and docs changes.
git diff --check
# Backend validation for backend changes.
if git diff --name-only origin/main...HEAD | rg -q '^(app|tests|requirements.txt|pytest.ini|ruff.toml)(/|$)'; then
ruff check app tests
ruff format --check app tests
pytest tests/unit -v
fi
# Frontend validation for frontend changes.
if git diff --name-only origin/main...HEAD | rg -q '^frontend/'; then
(cd frontend && npm run check:locales && npm run typecheck && npm run lint && npm run build)
fi
# Initial push: respect the current origin remote.
git push -u origin HEAD
# If that failed because the remote moved, use the pull skill. After
# pull-skill resolution and re-validation, retry the normal push:
git push -u origin HEAD
# If the configured remote rejects the push for auth, permissions, or workflow
# restrictions, stop and surface the exact error.
# Only if history was rewritten locally:
git push --force-with-lease origin HEAD
# Ensure a PR exists (create only if missing)
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
# Write a clear, human-friendly title that summarizes the shipped change.
pr_title="<clear PR title written for this change>"
if [ -z "$pr_state" ]; then
gh pr create --title "$pr_title"
else
# Reconsider title on every branch update; edit if scope shifted.
gh pr edit --title "$pr_title"
fi
# Write/edit PR body to match .github/PULL_REQUEST_TEMPLATE.md before validation.
# Example workflow:
# 1) open the template and draft body content for this PR
# 2) gh pr edit --body-file /tmp/pr_body.md
# 3) for branch updates, re-check that title/body still match current diff
tmp_pr_body=$(mktemp)
gh pr view --json body -q .body > "$tmp_pr_body"
if rg -n '<!--|Fixes #$|TODO|TBD' "$tmp_pr_body"; then
echo "PR body still contains template comments or unresolved placeholders." >&2
exit 1
fi
rm -f "$tmp_pr_body"
# Show PR URL for the reply
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.
1---2name: push3description: 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.4---56# Push78## Prerequisites910- `gh` CLI is installed and available in `PATH`.11- `gh auth status` succeeds for GitHub operations in this repo.1213## Goals1415- Push current branch changes to `origin` safely.16- Create a PR if none exists for the branch, otherwise update the existing PR.17- Keep branch history clean when remote has moved.1819## Related Skills2021- `pull`: use this when push is rejected or sync is not clean (non-fast-forward,22 merge conflict risk, or stale branch).2324## Steps25261. Identify current branch and confirm remote state.272. Run Borg UI validation appropriate to the changed files before pushing.283. Push branch to `origin` with upstream tracking if needed, using whatever29 remote URL is already configured.304. If push is not clean/rejected:31 - If the failure is a non-fast-forward or sync problem, run the `pull`32 skill to merge `origin/main`, resolve conflicts, and rerun validation.33 - Push again; use `--force-with-lease` only when history was rewritten.34 - If the failure is due to auth, permissions, or workflow restrictions on35 the configured remote, stop and surface the exact error instead of36 rewriting remotes or switching protocols as a workaround.37385. Ensure a PR exists for the branch:39 - If no PR exists, create one.40 - If a PR exists and is open, update it.41 - If branch is tied to a closed/merged PR, create a new branch + PR.42 - Write a proper PR title that clearly describes the change outcome43 - For branch updates, explicitly reconsider whether current PR title still44 matches the latest scope; update it if it no longer does.456. Write/update PR body explicitly using `.github/PULL_REQUEST_TEMPLATE.md`:46 - Fill every section with concrete content for this change.47 - Replace all placeholder comments (`<!-- ... -->`).48 - Keep bullets/checkboxes where template expects them.49 - If PR already exists, refresh body content so it reflects the total PR50 scope (all intended work on the branch), not just the newest commits,51 including newly added work, removed work, or changed approach.52 - Do not reuse stale description text from earlier iterations.537. Validate the PR body has no template comments or unresolved placeholders.548. Reply with the PR URL from `gh pr view`.5556## Commands5758```sh59# Identify branch60branch=$(git branch --show-current)6162# Minimal validation gate for Borg UI setup and docs changes.63git diff --check6465# Backend validation for backend changes.66if git diff --name-only origin/main...HEAD | rg -q '^(app|tests|requirements.txt|pytest.ini|ruff.toml)(/|$)'; then67 ruff check app tests68 ruff format --check app tests69 pytest tests/unit -v70fi7172# Frontend validation for frontend changes.73if git diff --name-only origin/main...HEAD | rg -q '^frontend/'; then74 (cd frontend && npm run check:locales && npm run typecheck && npm run lint && npm run build)75fi7677# Initial push: respect the current origin remote.78git push -u origin HEAD7980# If that failed because the remote moved, use the pull skill. After81# pull-skill resolution and re-validation, retry the normal push:82git push -u origin HEAD8384# If the configured remote rejects the push for auth, permissions, or workflow85# restrictions, stop and surface the exact error.8687# Only if history was rewritten locally:88git push --force-with-lease origin HEAD8990# Ensure a PR exists (create only if missing)91pr_state=$(gh pr view --json state -q .state 2>/dev/null || true)92if [ "$pr_state" = "MERGED" ] || [ "$pr_state" = "CLOSED" ]; then93 echo "Current branch is tied to a closed PR; create a new branch + PR." >&294 exit 195fi9697# Write a clear, human-friendly title that summarizes the shipped change.98pr_title="<clear PR title written for this change>"99if [ -z "$pr_state" ]; then100 gh pr create --title "$pr_title"101else102 # Reconsider title on every branch update; edit if scope shifted.103 gh pr edit --title "$pr_title"104fi105106# Write/edit PR body to match .github/PULL_REQUEST_TEMPLATE.md before validation.107# Example workflow:108# 1) open the template and draft body content for this PR109# 2) gh pr edit --body-file /tmp/pr_body.md110# 3) for branch updates, re-check that title/body still match current diff111112tmp_pr_body=$(mktemp)113gh pr view --json body -q .body > "$tmp_pr_body"114if rg -n '<!--|Fixes #$|TODO|TBD' "$tmp_pr_body"; then115 echo "PR body still contains template comments or unresolved placeholders." >&2116 exit 1117fi118rm -f "$tmp_pr_body"119120# Show PR URL for the reply121gh pr view --json url -q .url122```123124## Notes125126- Do not use `--force`; only use `--force-with-lease` as the last resort.127- Distinguish sync problems from remote auth/permission problems:128 - Use the `pull` skill for non-fast-forward or stale-branch issues.129 - Surface auth, permissions, or workflow restrictions directly instead of130 changing remotes or protocols.