Switch every connected code repo to its default branch and fast-forward it, skipping local changes. Use when the user says "sync the repos", "switch all repos to the default branch", "pull latest on every repo", or "get the latest from the default branch".
3 stars
0 votes
0 copies
1 view
Added November 14, 2026
developmentgoshellgitbackend
Works with
cli
Security analysis
A92/100
mediumInstalls packages at runtime which could introduce malicious dependencies
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Yad Sync Repos?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/abdelrahmannasr-yad-sync-repos)
---
name: yad-sync-repos
description: 'Switch every connected code repo to its default branch and fast-forward it, skipping local changes. Use when the user says "sync the repos", "switch all repos to the default branch", "pull latest on every repo", or "get the latest from the default branch".'
---
# SDLC — Sync Connected Repos (one command, every repo on its default branch)
<!-- generated: yad-cli — from cli/skill-yad-cli.mjs by scripts/skill-yad-cli.mjs; do not edit by hand -->
**This skill needs the `yad` command.** Before its first `yad …` command, run `command -v yad` (in PowerShell, `(Get-Command yad -ErrorAction SilentlyContinue).Source`). When it prints nothing, the yadflow CLI is not installed on this machine: stop there, and tell the person:
- Install it with `npm install -g yadflow@latest`, or run each command as `npx -y yadflow@4 …` in place of `yad …`.
- It is needed because the CLI is what enforces the approvals. Without it, a step could only ask you to wait; it could not check that a person approved.
Go on only when that check prints a path, or when the person chooses `npx -y yadflow@4`. A command this skill already writes as `npx -y yadflow@4 …` runs without the install.
<!-- end: yad-cli -->
**Goal:** Before Shape/Build work starts, get every connected code repo onto its default branch at the
latest commit, so nobody implements on a stale or wrong branch. This is the deterministic counterpart to
the `sync-before-implementation` discipline: one command instead of N manual `git checkout && git pull`.
This is **setup/maintenance, not a gated state** — it never touches `.sdlc/state.json`, any epic's
approvals, or the contract lock. It reads the project-wide registry and only mutates each repo's working
tree (branch + fast-forward). It writes **nothing** back to the registry.
## Conventions
- `{project-root}` resolves from the project working directory (the **Product**).
- Registry: `{project-root}/.sdlc/repos.json` (project-wide; the same file `yad-connect-repos` writes).
Each repo entry supplies `path` (local path, relative to `{project-root}` or absolute) and
`default_branch` (the branch to land on).
- **Local-user auth only.** Fetch as the user running the command — their SSH key or git credential
helper. Store no tokens. Works for GitHub and GitLab alike. If a fetch fails on auth, the repo is
skipped (STOP and tell the user to authenticate); never embed a credential.
- The deterministic half is the **`yad repo sync` CLI command** — `yad repo sync` (all repos) or
`yad repo sync <name>` (one). This skill drives that command and explains the result.
## Inputs
- `action` — `sync` (this skill's only action).
- `repo` — optional short name (the registry `name`, e.g. `backend`) to sync a single repo; omit for all.
## On Activation
Run `yad repo sync [<repo>]`. For each target repo it performs, in order:
### Step 1 — Locate and validate the repo
Resolve the local path from the registry. The registry is **shared content** — anyone who can push to
the Product wrote it — so the path is judged before any git runs (E81), the same way `yad join` and
`yad repo clone` judge it. The repo is **skipped with the reason** when:
- the path is outside the workspace (the Product folder's parent), or runs through a `.git` folder;
- nothing is there yet — **not cloned on this machine**: run `yad repo clone` to clone it;
- a folder is there but is not a checkout (a folder the Product commits could be shaped like a bare
git repo, and git run inside it would read its `config`, which can run a command). A folder inside a
checkout with no `.git` of its own (`apps/web` in a monorepo) is not refused (unless a link inside a
repo's tree or a folder holding an entry named `HEAD` is on its way — git can take such a folder for
a bare repo), but sync still skips it: switching its branch would switch the whole checkout, so sync
that checkout instead;
- a folder on the way, **inside a repo's tree**, is a link — the Product's `evil -> ../../..`. A link of
your own directly in the workspace folder (`ws/backend -> /src/backend`) is followed.
If the path is a checkout but `HEAD` is unreadable, warn and skip — there is nothing to switch.
### Step 2 — Skip a dirty working tree (never overwrite local work)
If `git status --porcelain` is non-empty, the repo has uncommitted changes: **skip it and warn**
(`<name> dirty → SKIPPED (commit/stash first)`). The skill never stashes, resets, or force-checks-out —
preserving local work is a hard rule.
### Step 3 — Determine the default branch
Use the registry `default_branch`. If absent, fall back to the remote's `origin/HEAD`, else `main`.
A recorded name must be a valid `refs/heads/<name>` (`git check-ref-format`) and must not start with
`-` or `+`: the name is handed to `git fetch`, where `--upload-pack=<command>` would run a command.
Any other name skips the repo with the reason (fix it in `.sdlc/repos.json`).
### Step 4 — Fetch the latest
If the repo has an `origin` remote: `git fetch origin <default_branch> --prune`. A local-only repo
(no remote) skips the fetch and just switches branch.
### Step 5 — Switch to the default branch
If not already on it, `git checkout <default_branch>` (git creates the tracking branch from `origin/`
when needed).
### Step 6 — Fast-forward only
`git merge --ff-only origin/<default_branch>`. If the branch has diverged (a real merge would be
required), **do not pull** — warn (`<name> diverged → not fast-forwarded`) and leave it for the human.
Never create a merge commit, rebase, or force.
### Step 7 — Report
Per repo: `switched to <branch>, pulled (ff)` / `already current` / `SKIPPED (...)`. Pulling moves HEAD,
so any repo whose `HEAD` now differs from its registry `syncedHead` has a **stale code-context pack** —
the command ends by pointing the human at `yad repo refresh` to repack (that is a separate human
decision; this skill never repacks or writes the registry). After the repack + AI code-map
regeneration, `yad repo refresh --push` publishes the refreshed code-maps + registry to the Product's
default branch as a `chore(product): sync code-context … [skip ci]` audit commit. It pushes to the default
branch, so an AI agent asks the person first, every time (E158). The last step after that refresh is
`yad brain build` (`--repo <name>` for one repo): the project brain reads the registry and the
code-map, so it is `behind` after every refresh, and a build before the code-map is written again
leaves it `behind` once more. The agent that runs that refresh runs the build, without asking the
person. This skill never runs it, because it never refreshes.
## Hard rules
- **Dirty = skip.** Never stash, reset, or discard uncommitted changes.
- **Fast-forward only.** A diverged branch is reported and left alone — no merge/rebase/force.
- **Local-user auth; store no tokens.** Fetch as the user; an auth failure skips that repo.
- **Working-tree only; not a gate.** Never write `.sdlc/repos.json`, `.sdlc/state.json`, approvals, or
the contract lock. Refreshing the cached pack is the separate, human-invoked `yad repo refresh`.
## Reference
- Registry schema + the HEAD-sha freshness rule this reports against: `../yad-connect-repos/references/repos-registry.md`.
- Connecting / refreshing repos and the code-context cache: `../yad-connect-repos/SKILL.md`.