What I do
- Push new local commits on a feature branch to the remote
- Detect if an open PR exists for the current branch
- Update the PR's "Changes" section only when the push adds significant new functionality
- Update the existing PR-linked
CHANGELOG.mdentry only when the PR's high-level scope materially changes, using the PR URL in the changelog bullet, then commit that changelog change to the same branch before pushing - Skip PR updates for commits that fix bugs or mistakes from earlier commits in the same branch
- Preserve the existing PR Summary while appending new change entries
When to use me
Use this skill when the user asks to push commits and/or update the PR with the latest changes.
Prerequisites
- Must be on a feature branch (not master/main)
- Branch must have unpushed commits ahead of remote
- GitHub CLI (
gh) must be installed and authenticated - If
ghnot installed → error: "GitHub CLI not found. Install: https://cli.github.com/"
Validation Workflow
- Check current branch:
git branch --show-current - If on
masterormain→ error: "Error: Cannot push directly to master/main. Switch to a feature branch." - Check for unpushed commits:
git log origin/<branch>..HEAD --oneline - If no unpushed commits → inform user: "Nothing to push — branch is up-to-date with remote."
Push Workflow
- Check if branch exists on remote:
git ls-remote --heads origin <branch-name> - If the branch already exists on remote, treat the next push as the final push for this batch of local commits
- If the branch does not exist on remote yet, push it first:
git push -u origin <branch-name> - Only run pre-push PR detection, PR body updates, and changelog sync when the remote branch already exists and an open PR can already be associated with it
- If the branch was just published and a later changelog sync creates a dedicated
CHANGELOG.mdcommit, push a second time so that new changelog commit reaches the same branch - If the branch already existed on remote, finish with the normal push:
git push
PR Update Workflow
When the remote branch already exists, check for an open PR before the final push and update its description when needed.
If the branch was not yet on remote, do the initial git push -u first; only then try PR detection and any follow-up sync work.
Only update the PR description when the outgoing commits add something new. Do not update it for fixes to earlier work in the same branch.
Detect Open PR
pr_json="$(gh pr view --json number,url,body --jq '{number: .number, url: .url, body: .body}' 2>&1)"
status=$?
- If
statusis0→ PR found; proceed to analyzing the new commits - If
pr_jsonclearly indicates no open PR for this branch → skip PR update and just report the push - If
statusis non-zero for any other reason → surface thegherror instead of treating it like no PR exists
Analyze New Commits
- If the branch already exists on remote, get the commits that are about to be pushed using the existing remote range:
Note: Capture this before the final push to know which commits are new.git log origin/<branch>..HEAD --oneline - If the branch was not yet on remote, use the local commit batch that existed before the initial
git push -uas the basis for PR update analysis instead of relying onorigin/<branch>. - Get the diffs for those commits to understand what changed:
git diff <pre-push-sha>..HEAD --stat
Decide Whether to Update the PR
Look at the new commits and decide: do they add something new to the branch, or do they fix/correct earlier work in the same branch?
Update the PR Changes section when the new commits:
- Add a new feature, capability, or behavior
- Add new files, components, or modules
- Introduce a new integration or API
- Make a meaningful enhancement that changes what the PR delivers
Skip the PR Changes update when the new commits:
- Fix a bug introduced by an earlier commit in this same branch
- Fix typos, linting errors, or test failures from earlier branch work
- Refactor or clean up code that was added in this branch
- Address code review feedback on existing branch changes
The simple rule: if the commit makes the PR do something it didn't do before, update Changes. If it fixes or polishes what the PR already does, skip the update.
When skipping, just report the push: "Pushed to <branch>. PR not updated (commit fixes/polishes existing branch work)."
Update PR Description
Only reach this step if the new commits are significant (see above).
- Fetch the current PR body:
gh pr view <number> --json body --jq .body - Analyze the new commits and session context
- Generate new bullet points for the
## Changessection (same style asgit-prskill) - Append the new bullet points to the existing
## Changessection - Keep the
## Summarysection unchanged unless it no longer reflects the PR accurately — if so, update it - Write the updated body back:
gh pr edit <number> --body "<updated body>"
Updated Description Format
Preserve the existing structure from the git-pr skill:
## Summary
<existing or updated 2-3 sentence overview>
## Changes
- <existing change 1>
- <existing change 2>
- <new change from latest push>
- <new change from latest push>
Update CHANGELOG.md and Commit It
Only reach this step if an open PR exists for the current branch and the outgoing commits materially change what the PR delivers.
- Check whether root
CHANGELOG.mdexists and contains exactly one## [Unreleased]section - Within the
## [Unreleased]section, find the existing changelog bullet for that PR number, whether it uses(#<pr-number>)or([#<pr-number>](<pr-url>)) - Re-evaluate the PR's high-level purpose after the push
- Update that one-line bullet only if the old wording no longer reflects the PR's overall scope
- If the best matching changelog subsection changed, move the bullet to the better subsection
- If
CHANGELOG.mdchanged, stage only that file:git add CHANGELOG.md - Verify the staged set contains only
CHANGELOG.mdbefore committing:
If any staged path other thangit diff --cached --name-onlyCHANGELOG.mdappears, warn and skip the changelog commit rather than risking unrelated files in the commit. - Create a dedicated changelog commit before the branch push:
git commit -m "docs: update changelog entry for PR #<pr-number>"
Rules:
- Do not touch
CHANGELOG.mdif there is no open PR in the current agent context or no open PR for the branch - Do not create a new changelog bullet from
git-push; this skill only updates an existing PR-linked bullet - Reuse the same high-level classification rules as
git-pr:Added,Changed,Deprecated,Removed,Fixed,Security, thenMiscif none fit well - Only move the bullet if the newly selected subsection already exists under
## [Unreleased]; otherwise skip changelog editing - Keep the changelog entry in this format:
- <high-level PR summary> ([#<pr-number>](<pr-url>)) - When rewriting text, preserve the PR number and use the current PR URL in linked form
- If the push only fixes, polishes, refactors, or addresses review feedback on existing branch work, leave the changelog unchanged
- If no matching bullet for the PR number exists, skip changelog editing
- If multiple matching bullets for the PR number exist, treat the changelog as ambiguous and skip editing
- If an existing plain
(#<pr-number>)suffix is found, rewrite it to the linked([#<pr-number>](<pr-url>))form during the update - Only create the dedicated changelog commit when
CHANGELOG.mdactually changed - Stage only
CHANGELOG.md; never use broad staging likegit add . - Verify the staged set contains only
CHANGELOG.mdbeforegit commit; otherwise warn and skip the changelog commit - Keep the changelog commit dedicated to the changelog sync so it can be pushed with the same branch work cleanly
- If
CHANGELOG.mdalready has unrelated local edits that make the sync unsafe or ambiguous, skip changelog editing and warn the user instead of guessing - If the branch already exists on remote, include any changelog commit in that same final push
- If the branch was just published with
git push -u, do a second push only when a changelog commit was created afterward
Error Handling
- On master/main → "Error: Cannot push directly to master/main. Switch to a feature branch."
- No unpushed commits → "Nothing to push — branch is up-to-date with remote."
ghnot installed → "Error: GitHub CLI not found. Install: https://cli.github.com/"- No open PR → push succeeds, inform user: "Pushed to . No open PR found to update."
gh pr viewfails for any reason other than no open PR for the branch → surface thegherror and do not silently skip PR/changelog updatesgh pr editfails → warn user but do not fail the push: "Warning: Push succeeded but PR description update failed."CHANGELOG.mdmissing, malformed, ambiguous, or missing the needed unreleased subsection → skip changelog sync and continue- Staged set contains files other than
CHANGELOG.mdafter sync → warn and skip the changelog commit to avoid committing unrelated staged changes git commitforCHANGELOG.mdfails → warn user and continue with the branch push without the changelog update: "Warning: Changelog update was prepared but could not be committed."