Logo: Push To Forked Pr

Push To Forked Pr

CommunautéitBeléift
hoangsonww
push-to-forked-pr

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

Iwwersiicht

Editeurhoangsonww
RepositoryClaude-Code-Agent-Monitor
Skill-Nummpush-to-forked-pr
Stären
1.1K
Forks
260
Matgeliwwert Dateien
1
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    hoangsonww huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Push To Forked Pr an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/master/.agents/skills/push-to-forked-pr
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/hoangsonww/Claude-Code-Agent-Monitor.git /tmp/Claude-Code-Agent-Monitor
mkdir -p .claude/skills
cp -r /tmp/Claude-Code-Agent-Monitor/.agents/skills/push-to-forked-pr .claude/skills/push-to-forked-pr
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Push To Forked Pr an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Push To Forked Pr automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Push To Forked Pr net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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:

  1. You are the fork owner — straightforward, you own that branch.
  2. 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

bash
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 be true if you are not the fork owner.

If headRepository.nameWithOwner matches the upstream's nameWithOwner, this PR is internal:

bash
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.

2. Confirm you can actually push

bash
gh auth status                        # who am I?
git remote get-url origin             # fetch URL — confirm origin is the UPSTREAM, not the fork
git remote get-url --push origin      # push URL — can differ from the fetch URL if `pushurl` is configured

For the internal-PR path above, compare the push URL (not just the fetch URL) against the expected upstream nameWithOwner before relying on git push origin — a configured pushurl can silently redirect the push to a different destination than the fetch URL suggests.

You may push to the fork branch iff the active gh user is:

  • the fork owner, or
  • a writer on the upstream and maintainerCanModify == true.

Otherwise stop. Tell the user the PR doesn't allow maintainer edits.

3. Sanity-check the local branch

bash
git branch --show-current
git rev-parse HEAD
git merge-base --is-ancestor <headRefOid> HEAD && echo ok || echo NOT-DESCENDANT
  • If headRefName differs from the current local branch, that's fine — you'll push with an explicit refspec local:headRefName in step 6.
  • If local HEAD is not a descendant of headRefOid, stop. Either you're on the wrong branch, or someone else has pushed to the PR since you forked from it. Do not force-push without explicit user permission.

4. Verify commit author identity before committing

bash
git config user.email

If it is empty, hostname-shaped (user@host.local, *@*.tail*.ts.net, etc.), or otherwise not a real email tied to a GitHub account, the commit will appear "unverified" on GitHub and won't link to a profile. Override per-commit:

bash
git -c user.name="<Name>"  -c user.email="<email>"  commit -F /tmp/commit-msg.txt

To correct an already-made commit before push:

bash
git -c user.name="..." -c user.email="..." commit --amend --reset-author -C HEAD --no-edit

Prefer the user's documented identity (e.g. from CLAUDE.md or earlier in the session) over the local git config when the local config is clearly machine-generated.

5. Run the repo's full verification suite — before pushing

The user almost always asks for this explicitly. In this repo (see CLAUDE.md for the authoritative list):

bash
npm run format:check                        # tracked files only; local .worktrees/ noise is not yours to fix
npm run test:server                         # backend touched
npm run test:client                         # frontend, wiki i18n, screen snapshots
npm run mcp:typecheck && npm run mcp:build  # mcp/ touched
npm --prefix mcp test                       # mcp unit suite
npm run build                               # production client build
bash .claude/skills/file-headers/scripts/check-headers.sh

Per-package extras when those areas are touched:

bash
npm --prefix desktop run build && npm --prefix desktop test
node scripts/validate-agent-extensions.js

Stop on the first red. Report which check failed and do not push.

6. Stage, commit, push to the fork (not origin)

Exclude session-local noise (.claude/settings.local.json is harness state, not work) and never stage blindly:

bash
git status                          # review exactly what changed
git add <path1> <path2> ...         # stage only the files for this PR's change — never `git add -A`
git status                          # confirm the staged diff matches intent (and excludes .claude/settings.local.json) before committing

Commit with a real body (use -F for multi-paragraph messages), ending with the Co-Authored-By trailer your harness requires — copy it verbatim from the harness instructions rather than from this file, so the model name never goes stale.

Then push to the fork. Add a one-off remote so it's clear in git remote -v and the destination URL doesn't end up in the user's shell history:

bash
FORK_REPO=$(gh pr view "$PR_NUMBER" --json headRepository --jq '.headRepository.nameWithOwner')
HEAD_BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName   --jq .headRefName)
LOCAL_BRANCH=$(git branch --show-current)

if [ -z "$LOCAL_BRANCH" ]; then
  echo "Detached HEAD — refusing to push (source ref would be empty and delete ${HEAD_BRANCH} on the fork)." >&2
  exit 1
fi

git remote add "pr${PR_NUMBER}-fork" "https://github.com/${FORK_REPO}.git"
git push "pr${PR_NUMBER}-fork" "HEAD:${HEAD_BRANCH}"    # push HEAD itself, not "$LOCAL_BRANCH" — safe even if the local branch name differs

gh configures git's credential helper, so HTTPS pushes pick up the right token automatically. Don't rewrite to SSH unless asked.

7. Verify the push landed on the PR

bash
LOCAL_HEAD=$(git rev-parse HEAD)
PR_HEAD=$(gh pr view "$PR_NUMBER" --json headRefOid --jq .headRefOid)
[ "$LOCAL_HEAD" = "$PR_HEAD" ] && echo "PR updated ✓" || echo "MISMATCH — push went somewhere else"

Report the new HEAD SHA, the PR URL, and the diff stat back to the user.


Common failure modes

SymptomCauseFix
Permission denied on pushAuthenticated as the wrong user, or maintainerCanModify: false and you are not the fork ownerAbort. Only the fork owner can push to the branch.
! [rejected] non-fast-forwardSomeone else pushed to the PR since you startedgit fetch "pr${PR_NUMBER}-fork" "${HEAD_BRANCH}", then rebase or merge. Never force-push someone else's PR branch without explicit permission.
Push succeeds, but PR head SHA doesn't updateYou pushed to a branch with a different name on the forkRe-check headRefName and use explicit refspec LOCAL:HEAD_BRANCH.
Commit shows "unverified" on the PRAuthor email isn't tied to a verified GitHub accountAmend with the user's real identity (step 4) and push again (fast-forward, not force).
Could not resolve hostNetwork or proxy issueSurface the error. Don't blanket-retry.

Hard rules

  • Never push to origin when origin is the upstream and the PR head is a fork. Always verify with git remote -v and gh pr view.
  • Never create a new branch. The user pushed because they want this PR updated; a new branch defeats that.
  • Never force-push to a fork PR branch without explicit user permission. The fork owner will lose any commits they had locally.
  • Always run the repo's tests/builds first. A fork-PR push triggers CI on the fork and surfaces on the upstream's PR view — pushing red code is doubly visible.
  • Always exclude .claude/settings.local.json unless the user explicitly says to include it. It's harness session state, not the work.
  • Never stage with git add -A. Stage explicit paths for the requested change so unrelated files or local secrets can't ride along.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Push To Forked Pr?

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

Firwat Push To Forked Pr op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Push To Forked Pr besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Push To Forked Pr an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/hoangsonww/Claude-Code-Agent-Monitor/tree/master/.agents/skills/push-to-forked-pr an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Push To Forked Pr benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Push To Forked Pr benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Push To Forked Pr domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Push To Forked Pr gratis?

Jo. hoangsonww huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇