Automate the setup of a local development environment for contributing to or working on GitHub repositories. Handles the full fork → clone → branch → dependencies pipeline.
Use cases: Open-source contribution, multi-repo development, new project onboarding, codebase exploration.
bash
gh auth status # Must show "Logged in"
git --version # Git installed
If not configured, ask the user to provide:
gh auth login or set export GH_TOKEN=<token>Token is required for: forking repos, cloning private forks, pushing code. Without it, git push and gh repo fork will fail.
ParameterRequiredDefaultExampleRepository✅—owner/repoGitHub username✅—myusernameBranch name❌(stay on default)fix/bug-descriptionWorking directory❌~/prs/{repo}``~/dev/{repo}Auth method❌GH_TOKEN env varToken in URL, SSH
bash
gh repo fork {owner}/{repo} --clone=false
If fork already exists, this is a no-op. If the user already owns the repo, skip forking.
bash
WORKDIR="${WORK_BASE:-$HOME/prs}/{repo_name}"
if [ -d "$WORKDIR" ]; then
cd "$WORKDIR"
git fetch --all
else
mkdir -p "$(dirname "$WORKDIR")"
# With token auth
git clone "https://${GH_TOKEN}@github.com/${username}/${repo_name}.git" "$WORKDIR"
# Or with SSH
# git clone "git@github.com:${username}/${repo_name}.git" "$WORKDIR"
cd "$WORKDIR"
fi
bash
if ! git remote get-url upstream &>/dev/null; then
git remote add upstream "https://github.com/${owner}/${repo_name}.git"
fi
git fetch upstream
bash
# Detect default branch
DEFAULT_BRANCH=$(git remote show upstream 2>/dev/null | grep 'HEAD branch' | awk '{print $NF}')
DEFAULT_BRANCH="${DEFAULT_BRANCH:-main}"
# Create branch from latest upstream
git checkout -b {branch_name} upstream/$DEFAULT_BRANCH
TypePatternExampleBug fixfix/{short-description}``fix/null-pointer-on-empty-listFeaturefeat/{short-description}``feat/add-retry-logicRefactorrefactor/{short-description}``refactor/extract-auth-moduleReview iterationfix/{description}-v2``fix/tool-guards-v2
Detect the project type and install accordingly:
IndicatorLanguageInstall Commandpyproject.toml / setup.pyPythonpip install -e ".[dev]" or pip install -e .``requirements.txtPythonpip install -r requirements.txt``package.jsonNode.jsnpm install``go.modGogo mod download``Cargo.tomlRustcargo build``pom.xmlJavamvn install -DskipTests``build.gradleJava/Kotlin./gradlew build -x test
If full dev install fails (common with native dependencies):
bash
# Check setup
echo "Directory: $(pwd)"
echo "Branch: $(git branch --show-current)"
echo "Upstream: $(git remote get-url upstream)"
echo "Fork: $(git remote get-url origin)"
# Quick build/import test
# Python: python -c "import {package}"
# Node: npm run build (if applicable)
# Go: go build ./...
A helper script is available if this Skill is installed alongside oss-pr-campaign:
bash
# One-liner setup
scripts/setup_repo.sh owner/repo username fix/branch-name
Or implement the same logic step-by-step using the SOP above.
~/prs/{repo}/ (or custom directory) on feature branch~/prs/ for easy navigation.