Sync local git fork with upstream by detecting and adapting to divergent branch topologies.
Install
mkdir -p .claude/skills/sync-upstream-vmafx && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/12107" && unzip -o skill.zip -d .claude/skills/sync-upstream-vmafx && rm skill.zipInstalls to .claude/skills/sync-upstream-vmafx
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Reconcile fork master with Netflix/vmaf master. Detects the fork's port-only topology (no shared merge-base) and emits a coverage report; falls back to merge-based sync when the histories are actually connected.Key capabilities
- →Detect port-only topology in a Git fork
- →Detect merge-based topology in a Git fork
- →Perform coverage checks for port-only topology
- →Identify silently ported changes via content-hash similarity
- →Perform merge-based synchronization
- →Open a pull request after a clean merge
How it works
The skill first detects the Git topology (port-only or merge-based) between a fork and its upstream. For port-only, it performs coverage checks; for merge-based, it executes a merge and handles conflicts.
Inputs & outputs
When to use sync-upstream
- →Sync fork with upstream
- →Check merge-base compatibility
- →Reconcile VMAF fork
About this skill
/sync-upstream
Invocation
/sync-upstream [--open-pr]
Background — why pre-flight matters
Fork maintained with port-only strategy: upstream commits cherry-picked,
rebranded (feat: port upstream X, subject preserved), squash-merged.
Fork master commit SHAs do not descend from upstream-master SHAs ->
git merge-base master upstream/master returns empty (histories formally
unrelated).
Bare git merge upstream/master --no-ff requires
--allow-unrelated-histories, produces thousands of spurious conflicts
(every fork-local file collides with upstream counterpart by path,
regardless of content). Skill must detect topology before merge attempt.
Steps
-
Pre-flight: topology detection.
git fetch upstream mb=$(git merge-base master upstream/master 2>/dev/null) || true- If
mbis empty -> port-only topology. Go to step 2a (coverage check). - If
mbis non-empty -> merge-based topology. Go to step 2b (classic merge).
- If
2a. Port-only coverage check. Upstream commits reachable from
upstream/master since last fork-side port anchor:
```bash
# Derive a reasonable upper bound: the last 50 upstream commits.
# Expand as needed; subjects are the match key.
git log upstream/master --pretty=format:'%H%x09%s' -50 > /tmp/sync-upstream-candidates.tsv
```
**Pass 1 — subject-line match (catches PRs citing upstream SHA in
subject):**
```bash
while IFS=$'\t' read -r sha subj; do
if git log master --pretty=format:'%s' \
| grep -Fxq "$subj"; then
echo "PORTED $sha $subj"
else
echo "UNPORTED $sha $subj"
fi
done < /tmp/sync-upstream-candidates.tsv
```
**Pass 2 — content-hash similarity for `UNPORTED` rows (catches silent
ports without upstream citation).** PR #295 2026-05-02 sync report
missed 4 of 6 candidates already on fork -> Pass 2 catches class:
```bash
# For each UNPORTED upstream commit, extract added/changed identifiers
# and check if they exist in fork master's HEAD. If yes, it's silently
# ported (the change shipped without an SHA citation in the commit subject).
for sha in $(awk '/^UNPORTED/ {print $2}' /tmp/sync-upstream-pass1.tsv); do
# Extract added/changed identifiers from the upstream commit
# (function names, variable names, string literals it INTRODUCES).
idents=$(git show "$sha" --no-color --pretty=format:'' \
| grep -E '^\+[^+]' \
| grep -oE '[a-zA-Z_][a-zA-Z0-9_]{4,}' \
| sort -u)
# Skip if no useful identifiers (e.g. doc-only or formatting commit).
[ -z "$idents" ] && continue
# Probe fork master for at least 80% of the identifiers.
n_total=$(echo "$idents" | wc -l)
n_present=$(echo "$idents" | xargs -I{} sh -c \
'git grep -lq "{}" -- master 2>/dev/null && echo present' | wc -l)
ratio=$((n_present * 100 / n_total))
if [ "$ratio" -ge 80 ]; then
echo "PORTED-SILENTLY $sha ratio=$ratio% n_total=$n_total"
else
echo "UNPORTED $sha ratio=$ratio%"
fi
done
```
80% threshold empirical:
- `ratio=80%+` -> upstream semantic content in fork master.
- `<50%` -> commit genuinely missing.
- 50–80% band fuzzy -> eyeball commit substance vs fork tree.
**Categorise final output:**
- `PORTED` (Pass 1 hit) -> fork commit cites SHA in subject.
- `PORTED-SILENTLY` (Pass 2 hit) -> semantic content present, no SHA
citation. Surface in report for maintainer citation backfill decision.
NOT `/port-upstream-commit` candidate.
- `UNPORTED` (neither pass hit) -> genuinely missing. Recommend
`/port-upstream-commit <sha>`.
- All commits `PORTED` or `PORTED-SILENTLY` -> exit with:
`sync-upstream: no action — fork at parity with upstream/master @ <tip-sha>`
- Any `UNPORTED` -> list, recommend `/port-upstream-commit <sha>` each.
Do NOT attempt merge. Expected outcome in port-only mode.
2b. Merge-based sync. Reached only when mb non-empty:
```bash
git switch -c sync/upstream-$(date +%Y%m%d) master
git merge upstream/master --no-ff
```
Conflict policy (matches D16):
- Fork wins: `.github/`, `README.md`, `CLAUDE.md`, `AGENTS.md`, `.claude/`,
`Dockerfile*`, `core/meson_options.txt`, under `core/src/cuda/`,
`core/src/sycl/`, `core/src/feature/{cuda,sycl}/`,
`core/src/feature/x86/`, `core/src/feature/arm64/`.
- Upstream wins: feature metric code not touched by fork (check
`git log --follow origin/master -- <path>` for fork commits).
- Manual resolution required: `core/include/libvmaf/libvmaf.h`,
`core/src/libvmaf.c`, `core/meson.build`, `core/tools/cli_parse.cpp`,
`core/tools/vmaf.cpp`.
- Manual conflicts: STOP, surface with `file:line` context. Do NOT resolve.
3. On clean merge (step 2b only): /build-vmaf --backend=cpu, the
repository runner against -C build, then /cross-backend-diff on the
normal Netflix pair.
- If
--open-pr(step 2b only):gh pr createwith titlechore(upstream): sync to upstream/master @ <sha>, body including upstream commit count, conflict summary, test results.- Port-only mode (step 2a):
--open-pr= no-op when coverage complete; gaps exist -> recommend 1 PR per/port-upstream-commit <sha>invocation, not single sync PR.
- Port-only mode (step 2a):
Guardrails
- Refuses run if working tree dirty.
- Refuses PR open if Netflix CPU golden tests fail after merge.
- Never
git push --force. - Pre-flight short-circuit mandatory: classic merge step MUST NOT be reached
when no merge-base exists, even under operator override
(
--allow-unrelated-historiesfallback corrupts hand-curated port history; see ADR-0028, post-mortem thread in docs/rebase-notes.md).
When not to use it
- →When the working tree is dirty
- →When Netflix CPU golden tests fail after a merge
- →When needing to `git push --force`
Limitations
- →Refuses to run if working tree is dirty
- →Refuses to open a PR if the Netflix CPU golden tests fail after merge
- →Never `git push --force`
How it compares
This skill specifically handles two distinct Git topologies (port-only and merge-based) for syncing a fork, including advanced detection of silently ported changes, unlike a standard `git merge` command.
Compared to similar skills
sync-upstream side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| sync-upstream (this skill) | 0 | 3mo | Review | Advanced |
| github-workflow-automation | 11 | 4mo | Review | Advanced |
| testing-workflow | 16 | 11mo | Review | Intermediate |
| github-actions-templates | 7 | 5mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
github-workflow-automation
ruvnet
Advanced GitHub Actions workflow automation with AI swarm coordination, intelligent CI/CD pipelines, and comprehensive repository management
testing-workflow
amo-tech-ai
Comprehensive testing workflow for E2E, integration, and unit tests. Use when testing applications layer-by-layer, validating user journeys, or running test suites.
github-actions-templates
wshobson
Create production-ready GitHub Actions workflows for automated testing, building, and deploying applications. Use when setting up CI/CD with GitHub Actions, automating development workflows, or creating reusable workflow templates.
glab
NikiforovAll
Expert guidance for using the GitLab CLI (glab) to manage GitLab issues, merge requests, CI/CD pipelines, repositories, and other GitLab operations from the command line. Use this skill when the user needs to interact with GitLab resources or perform GitLab workflows.
create-pr
n8n-io
Creates GitHub pull requests with properly formatted titles that pass the check-pr-title CI validation. Use when creating PRs, submitting changes for review, or when the user says /pr or asks to create a pull request.
gh-fix-ci
openai
Use when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions; use `gh` to inspect checks and logs, summarize failure context, draft a fix plan, and implement only after explicit approval. Treat external providers (for example Buildkite) as out of scope and report only the details URL.