Agent skill · luongnv89

fork-upstream-sync

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.

What it needs

About 4k tokens when loaded.

What this skill does

Fork Upstream Sync Integration main means fork main = upstream/main plus your unmerged commits in linear history (not a merge commit that duplicates feature work). Prerequisites Before selecting a path, validate all requirements: Tools: require Git 2.30+; require gh only for PR-state checks. Access: confirm authenticated fetch and push access to origin, plus fetch access to upstream. State: check that the working tree is clean or stashable and that the target branches are not checked out in another worktree. Recovery: record the current branch and SHA. If fetch, stash, rebase, reset, or push fails, stop at that command; never continue with stale assumptions. Branch selector 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). Repo sync before edits (mandatory) Before any rebase, reset, or force push: If the working tree is dirty: 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. Step completion reports 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. --- Path A — Bootstrap upstream remote 1. Confirm parent repo (for example gh repo view --json parent,isFork). 2. Add remote if absent: git remote add upstream git@github.com:ORG/REPO.git, then git fetch upstream. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills luongnv89/fork-upstream-sync

View the source on GitHub

Browse the @skills marketplace