sync-repos
Sweep a parent folder of sibling Git repos — switch each to its default branch, fast-forward pull, and report branch, stash and uncommitted state in one table.
Skill by hmdghoul
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hmdghoul-sync-repos
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: documents
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/sync-repos
What's inside
- Skill name
sync-repos- Description
- Sweep a parent folder of sibling Git repos — switch each to its default branch, fast-forward pull, and report branch, stash and uncommitted state in one table.
- License
- Apache-2.0
- Instructions
- 67 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- body: contains an absolute path from the author's machine
Files (1)
- SKILL.md
SKILL.md (first lines)
Switch every Git repo directly under a parent folder to its default branch (whatever `origin/HEAD` points at on the remote), fast-forward pull it, and report the results in one table. Invoking this skill approves checkout and pull without confirmation. It also approves the step 4 prune, but only to recover a pull blocked by a ref conflict; that deletes only remote-tracking pointers for branches the remote already deleted. The skill never commits, pushes, stashes, resets or merges. If a step fails in a way not covered here, stop and report. Do not improvise.
The argument is the parent folder (e.g. `/sync-repos C:\Users\Ahmad\source\repos\ananinja`). If it is missing, ask. Do not fall back to the working directory.
1. **Discover.** Each immediate child directory that contains `.git` is a repo. Do not recurse. If there are none, say so and stop.
2. **Survey each repo before touching it:**
```bash
git -C <repo> rev-parse --abbrev-ref HEAD
git -C <repo> diff --cached --name-only # staged
git -C <repo> diff --name-only # unstaged
git -C <repo> ls-files --others --exclude-standard # untracked
git -C <repo> stash list
git -C <repo> ls-remote --symref origin HEAD # default branch: "ref: refs/heads/<default> HEAD"
```
The default branch is the name after `refs/heads/` in the `ls-remote` output. Ask the remote, because the local `origin/HEAD` is set at clone time and goes stale if the default changes later. If `ls-remote` fails (offline, auth), fall back to `git -C <repo> symbolic-ref --short refs/remotes/origin/HEAD` and strip the `origin/` prefix. Never run `git remote set-head`; it writes a ref.
3. **Decide what each repo gets:**
- **Staged or unstaged changes:** skip the repo entirely (no checkout, pull or stash). Record `SKIPPED — dirty` and list the file names. Untracked files alone don't count as dirty; report their count and proceed.
- **Default branch not resolved by either command:** skip the repo. Record `FAILED — no default branch`.
- **Otherwise:** check out the default branch, then pull.
4. **Switch and pull.** Skip the checkout if the repo is already on its default branch:
```bash
git -C <repo> checkout <default>
git -C <repo> pull --ff-only
```
Always use `--ff-only`. Record each outcome and carry on; one repo's failure never stops the sweep.
- `Already up to date.` means up to date. `Fast-forward` means pulled.
- If it can't fast-forward, record `FAILED — diverged`. Never force, rebase or reset.
- If an untracked file blocks the checkout, record `FAILED — checkout blocked` and name the file.
- If fetch fails with `unable to update local ref`, `cannot lock ref`, or `'refs/remotes/origin/X' exists; cannot create 'refs/remotes/origin/X/Y'`, the cause is stale remote-tracking refs. The pull aborted at the fetch, so the repo is untouched and behind. Never call it up to date; check `rev-list --left-right --count '@{upstream}...HEAD'` instead. Prune and retry once:
```bash
git -C <repo> remote prune origin --dry-run # read what would go
git -C <repo> remote prune origin
git -C <repo> pull --ff-only
```
The prune can fail with `cannot lock ref` or `Unable to create '<name>.lock': File exists` while no git process runs and no `.lock` file exists. The cause is then two remote refs whose names differ only in case. On a case-insensitive filesystem their locks collide, so the whole prune aborts. Delete them one at a time instead:
```bash
git -C <repo> for-each-ref --format='%(refname)' refs/remotes/origin \
| tr 'A-Z' 'a-z' | sort | uniq -d
git -C <repo> ls-remote --heads origin '<name>' # empty = gone from remote
git -C <repo> update-ref -d refs/remotes/origin/<ExactCaseName>
```
Delete a ref only if `ls-remote` returns nothing for it. Then prune and pull again. If it still fails, record `FAILED — fetch blocked` with the git error verbatim. Never touch lock files or `packed-refs` by hand.
5. **Re-survey every repo and report** one row per repo:
| Repo | Default | Branch now | Result | Staged | Unstaged | Untracked | Stash |
`Result` is one of `up to date`, `pulled`, `pulled after prune`, `SKIPPED — dirty`, `FAILED — no default branch`, `FAILED — diverged`, `FAILED — checkout blocked` or `FAILED — fetch blocked`. Name the branch a repo was moved off if it didn't start on its default.
Under the table, list only what needs action. For each category, say "none" rather than omitting it:
- Skipped or failed repos: the files involved and the one next command to run.
- Existing stashes, per repo. `git status` doesn't show them.
- Repos whose default branch came from the local `origin/HEAD` fallback rather than the remote.
- Prunes: how many refs were removed, plus every ref deleted individually to break a case collision.From hmdghoul/claude-code-global-config, Apache-2.0.
More from hmdghoul/claude-code-global-config
- 0.570score
review-lessons
hmdghoul
Mine the review feedback on a repository's merged pull requests into a grouped, actionable "recurring mistakes" document, and create or update it at…
SkillAFreshness: AClaude Code +9 - 0.565score
investigate-ticket
hmdghoul
Investigate the Jira bug ticket linked to the current branch (or a ticket key you pass) WITHOUT implementing.
SkillAFreshness: AClaude Code +9 - 0.565score
feature-doc
hmdghoul
Generate a grounded, stakeholder-facing feature document (current + future implementation) for the CURRENT git branch by scanning its diff and the surrounding…
SkillAFreshness: AClaude Code +9 - 0.565score
slack-review-msg
hmdghoul
Generate a copy-pasteable Slack review request from the active git diff plus the PR link and Jira issue number the user provides.
SkillAFreshness: AClaude Code +9 - 0.565score
slack-ticket-msg
hmdghoul
Generate a copy-pasteable Slack message announcing a Jira ticket to a teammate or team lead (greeting, ticket link, plain-English summary, optional endpoint…
SkillAFreshness: AClaude Code +9 - 0.565score
split-task
hmdghoul
Split one Jira task into the fewest independently shippable subtasks (max 3), each drafted as a self-contained, AI-agent-ready ticket with outcome…
SkillAFreshness: AClaude Code +9 - 0.565score
review-lessons-reconcile
hmdghoul
Cross-check the CURRENT project's mined review lessons against the global rule tree (~/.claude/CLAUDE.md and the reference notes its routing table names in…
SkillAFreshness: AClaude Code +9 - 0.553score
rebase-staging
hmdghoul
Rebase the current Git branch onto the latest remote staging branch and safely force-push it.
SkillAFreshness: AClaude Code +9 - 0.553score
explain-changes
hmdghoul
Analyze git diff, create a beginner-friendly changelog, and trace code sources to their business impact.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 10, 2026 (18 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hmdghoul
- 0.570score
review-lessons
hmdghoul
Mine the review feedback on a repository's merged pull requests into a grouped, actionable "recurring mistakes" document, and create or update it at…
SkillAFreshness: AClaude Code +9 - 0.565score
investigate-ticket
hmdghoul
Investigate the Jira bug ticket linked to the current branch (or a ticket key you pass) WITHOUT implementing.
SkillAFreshness: AClaude Code +9 - 0.565score
feature-doc
hmdghoul
Generate a grounded, stakeholder-facing feature document (current + future implementation) for the CURRENT git branch by scanning its diff and the surrounding…
SkillAFreshness: AClaude Code +9 - 0.565score
slack-review-msg
hmdghoul
Generate a copy-pasteable Slack review request from the active git diff plus the PR link and Jira issue number the user provides.
SkillAFreshness: AClaude Code +9 - 0.565score
slack-ticket-msg
hmdghoul
Generate a copy-pasteable Slack message announcing a Jira ticket to a teammate or team lead (greeting, ticket link, plain-English summary, optional endpoint…
SkillAFreshness: AClaude Code +9 - 0.565score
split-task
hmdghoul
Split one Jira task into the fewest independently shippable subtasks (max 3), each drafted as a self-contained, AI-agent-ready ticket with outcome…
SkillAFreshness: AClaude Code +9
Cite this page
sync-repos skill. Agent Mart. https://agentmart.dev/skills/hmdghoul-sync-repos (last updated 2026-10-24)