
Push To Forked PR
Push the current working tree directly to a GitHub PR whose head lives on a **fork**...
Install
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill push-to-forked-pr -g -a claude-code -y- Repository
- hoangsonww/Claude-Code-Agent-Monitor1.1k
- Category
- Git and review
- Updated
- 5d ago
- License
- MIT
- Context cost
- Mediumabout 2,115 tokens
- Runs scripts
- No, instructions only
What it does
Push the current working tree directly to a GitHub PR whose head lives on a **fork**, without creating a new branch and without pushing to `origin` (which is usually the upstream). Invoke when the user says things like "push straight to PR #N", "push to the forked PR", "update PR from fork", "push these changes to #N directly", "commit and push to the PR", *especially* when they emphasise not creating a new branch or not pushing into the upstream repo. Use this **instead of** plain `git push origin` whenever the PR head repo differs from the local `origin` repo.
push-to-forked-pr
The whole point of this skill: origin is usually the upstream, but the PR's head is on someone else's fork. Pushing to origin updates the upstream's branch, not the PR. You have to push to the fork.
GitHub allows this in two situations:
- You are the fork owner, straightforward, you own that branch.
- You are an upstream maintainer and the PR has
maintainerCanModify: true(the "Allow edits from maintainers" checkbox the PR author leaves on by default). GitHub then lets the upstream's auth push to the fork branch.
If neither holds, abort and tell the user only the fork owner can push.
Procedure
1. Read the PR's head metadata
PR_NUMBER=<N>
gh pr view "$PR_NUMBER" --json state,headRefName,headRefOid,headRepository,headRepositoryOwner,maintainerCanModify,url
Capture:
state, bail if not"OPEN".headRepository.nameWithOwner→ the fork (e.g.someone/Repo).headRepositoryOwner.login→ the fork owner.headRefName→ the branch on the fork (usually matches local).headRefOid→ the PR's current head SHA. Your local HEAD must be a descendant.maintainerCanModify→ must betrueif you are not the fork owner.
If headRepository.nameWithOwner matches the upstream's nameWithOwner, this PR is internal:
HEAD_BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName --jq .headRefName)
HEAD_REF_OID=$(gh pr view "$PR_NUMBER" --json headRefOid --jq .headRefOid)
git merge-base --is-ancestor "$HEAD_REF_OID" HEAD && echo ok || echo NOT-DESCENDANT # abort if NOT-DESCENDANT
git push origin "HEAD:${HEAD_BRANCH}"
Exit the skill once this push lands, do not continue to the fork-push steps below.

