ghsync
Automatically mirrors and syncs all GitHub repositories you have access to.
Install
mkdir -p .claude/skills/ghsync && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16370" && unzip -o skill.zip -d .claude/skills/ghsync && rm skill.zipInstalls to .claude/skills/ghsync
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.
Bulk clone and keep in sync every GitHub repo you can access across an org or personal account. For an org it unions the repos reachable through the teams you belong to with the org's repo list (so direct-collaborator and public repos count even with no team membership); for a personal account it uses the account's repo list. Deduplicates them, then clones new ones and fast-forward syncs existing ones (and their worktrees) into a consistent <repo>/<repo>-main + <repo>/worktree layout. The org defaults to the directory you run from, so dropping into ~/dev/github.com/<org> mirrors that org. TRIGGER when the user types /ghsync, wants to clone or sync all org repos or their own personal repos, asks to mirror everything they have access to, is onboarding into a new enterprise/org, or wants to refresh their local checkouts to latest.Key capabilities
- →Discover all accessible GitHub repositories for an organization or personal account.
- →Clone new repositories into a worktree-friendly layout.
- →Fast-forward update existing repositories on their default branch.
- →Synchronize worktrees for updated repositories.
- →Report repositories with uncommitted changes or not on their default branch.
- →Skip archived repositories and those without a default branch.
How it works
The script identifies all accessible GitHub repositories, clones new ones, and fast-forward updates existing ones, including their worktrees, into a consistent local directory structure.
Inputs & outputs
When to use ghsync
- →Onboarding to a new company repo
- →Mirroring an entire GitHub organization locally
- →Keeping local dev environments synced
About this skill
ghsync: mirror and sync every repo you can access on GitHub or GitLab
Onboarding into a new enterprise means finding and cloning dozens of repos by hand, then drifting out of date. This skill does both halves: it discovers everything you can reach and keeps it in sync.
- First run — clones every accessible repo into a worktree-friendly layout.
- Every run after — fast-forward updates repos already on their default branch, updates their worktrees, and clones anything new. It never clobbers local work: repos with uncommitted changes or on a non-default branch are fetched but not pulled, and reported in the summary.
It is org-agnostic: point it at any GitHub org, GitHub Enterprise host,
personal account, or a GitLab host (gitlab.com or self-managed) with
--provider gitlab; see GitLab below. On GitHub: the script detects the account type itself. For an
organization it unions the teams you belong to with the org's repo list (so
direct-collaborator and public repos are included even with no team
membership); for a personal account it uses the account's repo list (private
repos included when it's your own account).
How to run it
The script lives next to this file. Claude Code writes this skill's directory into the script paths below when it loads the skill, so each path is already absolute:
# Org is derived from the directory you run in. To mirror the "meridianhub"
# org, run from a directory named meridianhub:
cd ~/dev/github.com/meridianhub
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh"
The org defaults to the basename of the directory you launch from. So
running inside ~/dev/github.com/meridianhub syncs the meridianhub org into
that directory. Override the org name or target directory explicitly when they
differ:
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --org meridianhub --root ~/dev/github.com/meridianhub
What to do when invoked
- Confirm the target. Run with
--list-reposfirst (or--list-teamsfor an org) so the user sees which account and how many repos before any cloning. This doubles as a check that the derived account name is correct. - Dry run on first use against a new org (
--dry-run) to preview clones and updates without touching disk. - Run the real sync. Stream the output; the run ends with a summary (up-to-date / updated / failed / uncommitted / branch issues / worktrees).
- Surface the exceptions. Call out anything under Failed, Uncommitted changes, or Not on default branch — these are the repos the user may need to deal with manually.
Flags
| Flag | Effect |
|---|---|
--provider github|gitlab | Which host type to sync (default: github) |
--root DIR | Directory to clone into; an explicit --root must already exist, in every mode (GitHub default: current directory; GitLab default: ~/dev/<host> with any :port dropped, created on the first real sync) |
--list-repos | List the deduplicated accessible repos and exit |
--porcelain | Machine-readable repo list: one path per line to stdout (GitHub: the repo name; GitLab: path_with_namespace), all chatter to stderr; implies --list-repos. Consumed by /ghreport and by --from-list. |
--dry-run | Show what would be cloned/updated without making changes. On GitLab it creates no directory and writes no .gh_archived_repos; on GitHub it still refreshes .gh_archived_repos in the root |
--limit N | Process only the first N repos (useful for a quick test) |
--quiet | Suppress per-repository chatter, including the Cloning / Cloned lines; keep failures and the final summary |
--porcelain-json | Like --porcelain, but one JSON object per line: path, default_branch, last_activity_at, head_committed_at, archived, forked_from (path or null), mirror and head_sha. Reads each default-branch head (one API call per repository). See Active repositories and metadata |
--active-since DURATION | Keep only repositories with a default-branch commit inside the window (90d, 2w, 6mo, 1y). With --dry-run, prints qualifying and total counts per group. See Active repositories and metadata |
--partial | Shorthand for --filter blob:none |
--filter SPEC | New clones only: pass --filter=SPEC to git clone (after -- on gh repo clone). blob:none keeps full history and fetches file contents only for the checkout. See Analysis-only mirrors |
--shallow-since DATE | New clones only: pass --shallow-since=DATE to git clone, cutting history before DATE (single-branch). See Analysis-only mirrors |
--org NAME | GitHub only. Org or personal account to sync (default: basename of --root / cwd) |
--list-teams | GitHub only. List your teams in the org (with repo counts) and exit; orgs only |
--host HOST | GitLab only. Host to sync (default: gitlab.com); https:// and a trailing / are accepted, and so is a web port (host:8443) |
--group PATH | GitLab only. Sync one group and its subgroups instead of every group you belong to. Covers every project the group shows you, including when you belong only to a subgroup of it (projects directly in the group and in sibling subgroups count). If the group itself cannot be read, the run syncs your subgroups under it and prints one stderr warning naming them and what was skipped; it fails only when nothing under the group is reachable |
--from-list FILE | GitLab only. Sync the paths in FILE (the --porcelain format; blank lines and # comments ignored) with no discovery and no glab |
A flag that belongs to the other provider is rejected with an error, not ignored.
GitLab
# Every project in every group you belong to on gitlab.com, into ~/dev/gitlab.com/
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --provider gitlab --list-repos
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --provider gitlab
# One group subtree on a self-managed host, into ~/dev/gitlab.example.com/
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --provider gitlab --host gitlab.example.com --group platform/infra
- Discovery runs through
glab api --paginate: the groups you belong to (groups?min_access_level=10), each group'sdescendant_groups, and each group'sprojectsandprojects/shared. Dedupe is onpath_with_namespace, so a project reachable directly and through sharing, or shared into two groups, is cloned once. - Layout: each project lands under its own
path_with_namespace, so nested subgroups become nested directories and a shared project from another namespace sits under that namespace, not under the group it was shared into:~/dev/<host>/<group>/<subgroup>/<repo>/<repo>-mainplus a siblingworktree/. - Archived and empty projects are skipped, as on GitHub.
- Clone URLs are built from the host:
https://<host>/<path>.git, orgit@<host>:<path>.gitwithGHSYNC_GIT_PROTOCOL=ssh. For HTTPS on a private project, letglab auth loginset up git credentials. A port on--hostis the web and API port: it stays in the HTTPS URL and is dropped from the SSH URL. Set a non-standard SSH port for the host in~/.ssh/config. - Default root:
~/dev/<host>, with any port dropped, so--host gitlab.example.com:8443syncs into~/dev/gitlab.example.com/. Two instances on one host name but different ports would share that root: give one an explicit--root. - Preview runs (
--list-repos,--porcelain,--dry-run) create no directory and write no.gh_archived_repos, so the list can be produced on a machine that will never hold the checkouts. An explicit--rootmust still exist. - Path rules follow GitLab's (
lib/gitlab/path_regex.rb): a segment starts with a letter, digit,_or.(sogrp/.dotfilessyncs), then letters, digits,_,-and.. Segments.and.., any segment ending in.gitor.atom, and.gitin any case are skipped with a warning. So is a first segment, in any case, that names one of ghsync's own root entries (.gh_archived_repos, or.gh_sync_tmp, which older versions delete on every run); deeper segments may use those names. - Fail fast: before any discovery call, the script checks that
glabandjqare installed and thatglab auth status --hostname <host>passes. A failure prints one line naming the host and the check (installed, authentication or reachability) and exits non-zero. It does not retry, and it never tunnels or works around network controls.
Hosts reachable only from another network
Discovery needs the GitLab API; cloning needs only git. When the two are reachable from different places, split the run:
# 1. Where the API answers: save the project list.
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --provider gitlab --host gitlab.example.com --porcelain > projects.txt
# 2. Where git reaches the host: clone and sync from the list. No glab needed.
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --provider gitlab --host gitlab.example.com --from-list projects.txt
Step 2 builds the same layout as a discovery run and makes no API call.
Edit the list to drop projects; --limit applies to it too.
Active repositories and metadata
For a fleet measurement across hundreds of repositories, --active-since
drops the dormant ones and --porcelain-json hands each repository's
metadata to the next tool, so it does not have to call the API again:
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --provider gitlab --host gitlab.example.com --porcelain-json --active-since 6mo > projects.jsonl
bash "${CLAUDE_SKILL_DIR}/scripts/ghsync.sh" --org my-org --dry-run --active-since 90d
- Active means a commit on the default branch. Discovery's own activity date is only a prefilter: GitHub
Content truncated.
When not to use it
- →When a user wants to manually manage individual repository clones.
- →When a user needs to perform complex Git operations beyond fast-forward updates.
- →When the target is not a GitHub organization or personal account.
Prerequisites
Limitations
- →Repositories with uncommitted changes are fetched but not pulled.
- →Repositories not on their default branch are fetched but not pulled.
- →Updates are fast-forward only, preventing merge commits or rebases.
How it compares
This skill automates the discovery and synchronization of all accessible GitHub repositories, providing a consistent local setup and keeping it updated, unlike manual cloning and individual repository management.
Compared to similar skills
ghsync side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| ghsync (this skill) | 0 | 4mo | Review | Intermediate |
| resolve-conflicts | 81 | 12mo | Review | Intermediate |
| openspec-onboard | 10 | 9mo | Review | Beginner |
| codex-cli-bridge | 9 | 1y | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
resolve-conflicts
antinomyhq
Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
openspec-onboard
studyzy
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
codex-cli-bridge
alirezarezvani
Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools
skill-sync
KyleKing
Syncs Claude Skills with other AI coding tools like Cursor, Copilot, and Codeium by creating cross-references and shared knowledge bases. Invoke when user wants to leverage skills across multiple tools or create unified AI context.
github-workflow-automation
ruvnet
Advanced GitHub Actions workflow automation with AI swarm coordination, intelligent CI/CD pipelines, and comprehensive repository management
git-advanced-workflows
wshobson
Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.