Get the FREE Ultimate OpenClaw Setup Guide →

sync-github-forks

Scanned
npx machina-cli add skill nainishshafi/developer-productivity-skills/sync-github-forks --openclaw
Files (1)
SKILL.md
2.2 KB

IMPORTANT: Both scripts are already bundled with this skill. Do NOT create new files. Detect the OS and run the appropriate existing script:

  • Windowsscripts/sync-forks.ps1
  • Linux / macOSscripts/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

  • gh CLI installed and authenticated (gh auth login)
  • git on PATH
  • Linux/macOS only: jq on PATH
  • 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

  1. Checks that gh, jq, and git are on PATH.
  2. Derives your GitHub username automatically via gh api user.
  3. Paginates GET /user/repos?type=forks&per_page=100&page=N via gh api until all forks are fetched.
  4. For each fork:
    • Local dir exists → git pull origin <current-branch> (fast-forward).
    • Local dir missing → git clone <ssh_url> $BASE_DIR/<name>.
  5. Prints a final summary: Done — cloned N, pulled N, failed N.

Key Decisions

  • gh CLI handles authentication — no GITHUB_TOKEN env 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

  1. Run gh auth status — confirm you are logged in.
  2. Run the appropriate script for your OS (see Usage above).
  3. Confirm repos are cloned or pulled in BASE_DIR.

Source

git clone https://github.com/nainishshafi/developer-productivity-skills/blob/master/.github/skills/sync-github-forks/SKILL.mdView on GitHub

Overview

This skill provides OS-aware scripts to clone all your GitHub forks and update existing ones. It uses the gh CLI to fetch forks and SSH URLs for cloning, enabling bulk syncing from Windows or Linux/macOS without creating new files.

How This Skill Works

The solution detects your OS and runs the matching bundled script: Windows → scripts/sync-forks.ps1; Linux/macOS → scripts/sync-forks.sh. The script uses gh to paginate forks (GET /user/repos?type=forks&per_page=100&page=N), then clones missing repos or pulls updates for existing ones, and prints a final summary.

When to Use It

  • Clone all your GitHub forks to a local directory.
  • Pull updates for forks you already cloned.
  • Use an OS-specific, ready-made solution without writing new files.
  • Avoid token handling since gh handles authentication.
  • Fetch all forks beyond the 100-repo API limit using pagination.

Quick Start

  1. Step 1: Install gh, git (and jq on Linux/macOS) and run gh auth login.
  2. Step 2: Optionally export BASE_DIR to your preferred clone location (for example, export BASE_DIR=~/code).
  3. Step 3: Run the appropriate script for your OS: Windows: pwsh scripts/sync-forks.ps1; Linux/macOS: bash scripts/sync-forks.sh.

Best Practices

  • Ensure gh is installed and authenticated (gh auth login) before running.
  • Make sure git is on PATH.
  • On Linux/macOS, install jq on PATH.
  • Add SSH keys to GitHub to enable SSH cloning.
  • Optionally set BASE_DIR to your preferred clone location and verify the final summary.

Example Use Cases

  • Clone all forks to ~/code on Linux/macOS using the bash script.
  • Pull updates for all local fork repos in ~/code.
  • Sync forks on Windows with the PowerShell script.
  • Run with SSH URLs to avoid embedding tokens in remote URLs.
  • Check the final 'Done — cloned N, pulled N, failed N' summary.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers