code-yeongyu/senpi/merge-upstream
- community
Checking that the SKILL.md file is still in the repository.
Sync a fork branch with an upstream remote using a history-preserving merge. Use this whenever the user says /merge-upstream, merge upstream, sync upstream, sync fork, or wants upstream changes integrated without rebasing or force-pushing.
Install
npx vskill@latest install code-yeongyu/senpi/merge-upstreamSKILL.md
Merge Upstream
Sync the current fork branch with upstream/<branch> using a merge commit by default. Preserve local commit hashes, keep push non-destructive, and never rewrite history.
Usage
Treat these as equivalent triggers:
Options:
--base=<branch>: use that upstream branch instead of auto-detecting the upstream default branch.--ff-allow: allowgit merge --ff-onlywhen the current branch has no unique local commits. Without this, usegit merge --no-ffto leave an explicit sync commit.
Invariants
- Do not run
git rebase. - Do not run
git push --forceorgit push --force-with-lease. - Do not bypass hooks or signing with
--no-verifyor--no-gpg-sign. - Ask before pushing.
Workflow
- Validate the repository:
``bash git rev-parse --is-inside-work-tree git branch --show-current git remote get-url upstream git remote get-url origin ``
Abort on detached HEAD or missing upstream. If origin is missing, continue locally and skip push.
- Require a clean worktree:
``bash worktree_status=$(git status --porcelain) || exit 1 test -z "$worktree_status" ``
If dirty, stop and ask the user to clean or commit the changes, or use a clean task worktree.
- Detect the upstream target branch:
- If
--base=<branch>is provided, fetch and verifyupstream/<branch>. - Otherwise run
git remote set-head upstream -a, then readrefs/remotes/upstream/HEAD. - If detection fails, ask the user for
--base=<branch>.
- Fetch enough history for a reliable merge base:
``bash git rev-parse --is-shallow-repository git fetch --tags upstream "+refs/heads/${upstream_branch}:refs/remotes/upstream/${upstream_branch}" origin_branch_exists=false if git remote get-url origin >/dev/null 2>&1; then if ! origin_branch=$(git ls-remote --heads origin "refs/heads/${current_branch}"); then echo "failed to inspect origin/${current_branch}" >&2 exit 1 elif [ -n "$origin_branch" ]; then git fetch origin "+refs/heads/${current_branch}:refs/remotes/origin/${current_branch}" || exit 1 origin_branch_exists=true else echo "origin/${current_branch} does not exist; current branch is unpublished" fi fi git merge-base HEAD "upstream/${upstream_branch}" ``
If the repository is shallow, unshallow origin first when available, then upstream only if still shallow.
Always use the fetched remote-tracking ref as the target; do not decide from a previously cached upstream/<branch> tip.
- Record the exact refs and report divergence:
``bash current_head=$(git rev-parse HEAD) upstream_tip=$(git rev-parse "upstream/${upstream_branch}") git rev-list --count "upstream/${upstream_branch}..HEAD" git rev-list --count "HEAD..upstream/${upstream_branch}" GIT_PAGER=cat git log --oneline "HEAD..upstream/${upstream_branch}" GIT_PAGER=cat git log --first-parent --oneline "upstream/${upstream_branch}..HEAD" ``
Report HEAD and upstream/${upstream_branch} with their full SHAs.
- Merge:
- Behind
0means the fetchedupstream_tipis already an ancestor ofcurrent_head. Confirm that state with both checks:
``bash git merge-base --is-ancestor "$upstream_tip" "$current_head" upstream_range=$(git rev-list "$current_head..$upstream_tip") || exit 1 test -z "$upstream_range" ``
This completes upstream integration as a successful no-op. Report the exact refs, SHAs, ancestry result, and empty range; skip the merge, release, and other change-dependent gates. Do not create an empty commit or pull request, or publish a branch solely to represent the sync. If an independent request explicitly approves pushing existing local commits, use step 9's non-destructive push semantics.
- If behind is greater than
0and--ff-allowis set with ahead0, run:
``bash git merge --ff-only "upstream/${upstream_branch}" ``
- Otherwise capture
previous_headandupstream_tip, then run:
``bash git merge --no-ff "upstream/${upstream_branch}" -m "merge: sync ${current_branch} with upstream/${upstream_branch}" ``
- Resolve conflicts locally when they occur:
``bash git diff --name-only --diff-filter=U ``
Read each conflicted file. Auto-resolve only mechanically obvious conflicts such as non-overlapping additions, import unions, formatting-only differences, or generated lockfile refreshes. For semantic conflicts, present the specific conflict and ask whether to keep ours, keep theirs, manually edit, or abort. After resolution:
``bash git add <file> git -c core.editor=true merge --continue ``
- Verify:
``bash git rev-parse --git-path MERGE_HEAD git rev-parse --git-path rebase-merge git rev-parse --git-path rebase-apply git show -s --format=%P HEAD git rev-list --left-right --count "upstream/${upstream_branch}...HEAD" if [ "$origin_branch_exists" = true ]; then git merge-base --is-ancestor "origin/${current_branch}" HEAD fi ``
In default mode, verify HEAD has two parents: previous_head as first parent and upstream_tip as second parent. In --ff-allow fast-forward mode, verify HEAD equals upstream_tip.
- Push only with explicit approval:
``bash GIT_PAGER=cat git log --oneline --graph --decorate -10 git push origin "${current_branch}" ``
If the remote branch does not exist, use git push -u origin "${current_branch}". If push is rejected as non-fast-forward, re-fetch and offer only non-destructive options: merge origin/<branch> into HEAD and retry, or stop.
Final Report
Include:
- branch and upstream target, including their full SHAs
- whether merge, fast-forward, or no-op happened
- for a no-op, confirmed ancestry and the empty
HEAD..upstream/<branch>range - fork commits preserved
- upstream commits integrated
- push status
- any conflicts and how they were resolved
Security
- Security scanPassed, 91 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/agent/skills/merge-upstream/SKILL.md
Popularity
- Repository stars
- 461
- Repository forks
- 122
- 7-day trend score
- 31
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/code-yeongyu/senpi/merge-upstream)