agentleFS
bordenetbordenet/superpowers-plus/skills/engineering/branch-sync-gate/skill.md

branch-sync-gate

Skill8 starsChanged 6 months agoMITView on GitHub

Pull gate — MANDATORY before any work on an existing shared branch. git fetch + status check before touching code, running tests, or making changes. Fires whenever resuming, continuing, or reviewing work on a branch that exists on a remote.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run tests on an existing branch

    line 58
  2. Distinctive:

    Write code on an existing branch

    line 59
  3. Distinctive:

    Add commits to a branch shared with other developers

    line 61
  4. Distinctive:

    If you find yourself already mid-work and realize you haven't pulled — stop, pull, verify the state hasn't changed under you, then continue.

    line 94
  5. Very specific:

    Root cause: No skill enforced sync at session start.

    line 100
  6. Distinctive:

    git-branch-conventions: Use when creating a brand-new branch

    line 122

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
skill.md

Wrong skill? Starting a brand-new branch → using-git-worktrees. About to commit → unified-commit-gate. Branch work is done → finishing-a-development-branch.

Branch Sync Gate

The Rule

Before touching any existing shared branch — pull first.

This is not optional. It is not skippable. It applies even if you were just working on the branch 5 minutes ago.

When to Use

Any time you are about to:

  • Resume or continue work on a branch that exists on a remote
  • Run tests on an existing branch
  • Write code on an existing branch
  • Review a PR branch locally
  • Add commits to a branch shared with other developers

The Gate (Run This First — Before Anything Else)

# Step 1: Where are we?
git branch --show-current
git remote -v

# Step 2: Fetch and check for remote changes
git fetch origin
git log HEAD..origin/$(git branch --show-current) --oneline 2>/dev/null
Remote has commits not in local?Action
Yesgit pull --rebase origin $(git branch --show-current) — then verify
NoProceed — you are in sync
UnsureFetch and check. Never assume.
# Step 3: Pull if behind
git pull --rebase origin $(git branch --show-current)

# Step 4: Confirm baseline
git log --oneline -5
git status

Non-Negotiable

Do not start work, run tests, or write a single line of code until this gate passes.

If you find yourself already mid-work and realize you haven't pulled — stop, pull, verify the state hasn't changed under you, then continue.

Why This Exists

Incident 2026-04-23: Agent began writing tests on an active PR branch without pulling first. A teammate had pushed two commits in the interim. The agent iterated tests against stale code, created a merge conflict on push, resolved it by discarding its own changes, then pushed a broken build (failing assertion + TypeScript error). Required multiple extra fix commits on a PR that was otherwise ready to merge.

Root cause: No skill enforced sync at session start. Every existing gate (sp-commit, sp-finish, pre-commit-gate) fires at commit time or later — zero enforcement at the moment work begins.

Anti-Patterns

WrongRight
Assume local is up to date because you just worked on itgit fetch and check
Pull after writing codePull before writing code
Merge conflicts on pushPrevented by pulling first
Re-fixing what a teammate already fixedPrevented by pulling first

Failure Modes

SymptomFix
git fetch hangsCheck network / VPN; run git remote -v to verify remote URL
Merge conflict after pullgit status to identify conflicts; resolve, then git rebase --continue
Branch doesn't exist on remoteVerify with git branch -r; may be a new local-only branch
Remote HEAD diverged too farConsider git fetch origin && git log --oneline origin/branch before rebasing

Companion Skills

  • git-branch-conventions: Use when creating a brand-new branch
  • unified-commit-gate: Fires at commit time (this fires at session start)
  • finishing-a-development-branch: Fires when branch work is complete

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.