skills/fork-upstream-sync/SKILL.md
Sync a GitHub fork with upstream while keeping unmerged feature branches and open PRs mergeable. Use for rebase on upstream, PR conflicts, integration main. Don't use for git init, releases, or non-fork repos.
npx skillsauth add luongnv89/skills fork-upstream-syncInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Integration main means fork main = upstream/main plus your unmerged commits in linear history (not a merge commit that duplicates feature work).
Before selecting a path, validate all requirements:
gh only for PR-state checks.origin, plus fetch access to upstream.Pick one path per user request:
| Path | When |
|------|------|
| A — Bootstrap | No upstream remote yet, or first-time fork sync |
| B — PR branch | Open PR is CONFLICTING or DIRTY; rebase feature branch on upstream/main |
| C — Integration main | Fork main should match upstream plus same tip as feature branch |
| D — Post-merge | Upstream merged your PR; drop duplicate commits on fork main |
Paths B then C is the usual full sync (PR mergeable, fork main carries your WIP).
Before any rebase, reset, or force push:
git fetch upstream
git fetch origin
If the working tree is dirty:
git stash push -u -m "pre-sync: $(git rev-parse --abbrev-ref HEAD)"
# ...run the fetch/rebase/reset steps for the chosen path...
git stash pop
On git stash pop conflict, stop — the stash is preserved (git stash list); resolve manually before continuing.
If upstream is missing, origin is missing, or the user has not said which upstream org/repo to use, stop and ask. Never force-push main without --force-with-lease.
After each major phase, emit a short report with checks for upstream remote, commits behind upstream, PR mergeable status, conflicts resolved, and whether integration main matches the feature branch tip. End with Result PASS, FAIL, or PARTIAL.
gh repo view --json parent,isFork).git remote add upstream [email protected]:ORG/REPO.git, then git fetch upstream.Done when: git rev-parse upstream/main succeeds and git remote -v lists upstream.
main).git checkout <feature-branch> then git rebase upstream/main.git rebase --abort and stop to ask the user rather than guessing.git add resolved files, then GIT_EDITOR=true git rebase --continue.pnpm run sync:localization-catalog --fix).git push origin <feature-branch> --force-with-lease.gh pr view <n> --repo ORG/REPO --json mergeable,mergeStateStatus (expect MERGEABLE; CI may lag).Done when: rebase completes, no conflict markers in tree, PR is MERGEABLE or user accepts waiting on CI.
After Path B:
git checkout main
git reset --hard upstream/main
git merge --ff-only <feature-branch> && git push origin main --force-with-lease
If --ff-only fails, main is already reset to bare upstream/main — do not push. The feature branch is behind the new upstream/main; re-run Path B to rebase it, then retry this merge. Pushing here without the fast-forward would force-publish plain upstream/main, silently dropping your integration WIP from origin/main.
Done when: upstream/main is ancestor of main, main SHA equals feature branch SHA, and ahead count matches your feature commits.
When upstream main already contains your merged PR:
git fetch upstream
git checkout main
git reset --hard upstream/main
git push origin main --force-with-lease
Done when: main SHA equals upstream/main SHA.
Protect the context budget: read references/command-checks.md only when executing or diagnosing a path. See that reference for the routine command sequence and exact SHA, ancestry, ahead-count, and clean-tree checks.
upstream/main into fork main with a merge commit while also keeping a parallel rebased feature branch.--force-with-lease.origin as upstream; origin is your fork, upstream is the parent.Verify the selected path before reporting success:
--force-with-lease; no destructive push targeted the wrong branch.MERGEABLE, or CI delay is explicitly reported as partial.Run:
git log --oneline -1 upstream/main main <feature-branch>
git rev-list --count upstream/main..main
git merge-base --is-ancestor upstream/main main
Expected output: the log identifies the intended tips, the ahead count equals the retained feature commits, and the ancestry command exits 0. For Paths C and D, also assert the exact SHA equality required by that path.
gh repo view --json defaultBranchRef; do not assume main.tools
Run Herdr loops for one open GitHub issue (resolve→review→fix) or an existing PR (review→lazy fixer) until CLEAN. Don't use for plain resolution without review, review-only/no-fix requests, backlog automation, or merging.
tools
Manage AI agent fleets in Herdr: split root + sub-agents into one tab as a tiled grid, message/wait/read via herdr CLI, steer any pane. Use for Herdr multi-agent fleets. Don't use for tmux, screen, or non-Herdr terminals.
development
Generate or update docs to match the code, citing each claim to path:line and asking on ambiguity; runbook docs also get a check-only validation script. Don't use for API-reference autogen (JSDoc/Sphinx), landing pages, or CLAUDE.md/AGENTS.md.
testing
Generate a diagram and route to the right engine — draw.io XML (precise, editable, C4, swimlanes) or Excalidraw JSON (hand-drawn, sketch, wireframes). One entry for flowcharts, architecture, ER, sequence, mind maps. Don't use for Mermaid or slides.