IMPORTANT: Both scripts are already bundled with this skill. Do NOT create new files. Detect the OS and run the appropriate existing script:
- Windows →
scripts/sync-forks.ps1- Linux / macOS →
scripts/sync-forks.sh
The bundled scripts sync all GitHub forks by cloning missing repos and pulling existing ones. They use the gh CLI for API calls — no token needed.
Prerequisites
ghCLI installed and authenticated (gh auth login)gitonPATH- Linux/macOS only:
jqonPATH - SSH key added to GitHub (for clone/pull via SSH)
Usage
Both scripts already exist — detect the OS and run the correct one. Do not create any new files.
Windows (PowerShell):
# Optional: override clone location (default: ~\git-repos)
$env:BASE_DIR = "$env:USERPROFILE\code"
pwsh scripts/sync-forks.ps1
Linux / macOS (bash):
# Optional: override clone location (default: ~/git-repos)
export BASE_DIR=~/code
bash scripts/sync-forks.sh
What the Script Does
- Checks that
gh,jq, andgitare onPATH. - Derives your GitHub username automatically via
gh api user. - Paginates
GET /user/repos?type=forks&per_page=100&page=Nviagh apiuntil all forks are fetched. - For each fork:
- Local dir exists →
git pull origin <current-branch>(fast-forward). - Local dir missing →
git clone <ssh_url> $BASE_DIR/<name>.
- Local dir exists →
- Prints a final summary:
Done — cloned N, pulled N, failed N.
Key Decisions
ghCLI handles authentication — noGITHUB_TOKENenv var required.- Username is derived at runtime from
gh api user— no hardcoded config. - SSH clone URLs are used so no token is embedded in the remote URL.
- Pagination ensures all forks are fetched beyond the 100-repo API limit.
Verification
- Run
gh auth status— confirm you are logged in. - Run the appropriate script for your OS (see Usage above).
- Confirm repos are cloned or pulled in
BASE_DIR.