Loading...
Loading...
Enable the GitHub CLI (`gh`) in Claude Code cloud sessions and GitHub Copilot coding agent environments. Use this skill when: (1) setting up a project so cloud AI agents can use `gh` for PRs, issues, and releases, (2) configuring setup scripts or SessionStart hooks for `gh` installation, (3) adding `copilot-setup-steps.yml` for GitHub Copilot agents, (4) troubleshooting `gh` auth failures in cloud sessions, or (5) configuring `GH_TOKEN` for headless environments. Triggers on: "enable gh", "github integration", "Claude Code cloud setup", "copilot setup steps", "gh auth in cloud", "gh not working in cloud", "setup script", or any request involving GitHub CLI access from cloud-based AI coding agents.
npx skill4agent add onsager-ai/dev-skills github-integrationghghghcopilot-setup-steps.ymlghWhich cloud environment?
Claude Code cloud (claude.ai/code)?
→ gh is NOT pre-installed in the default image
→ Install via setup script: apt update && apt install -y gh
→ Set GH_TOKEN as environment variable in environment settings
→ For repo-portable setup, use SessionStart hook instead
→ Use -R owner/repo flag with gh due to sandbox proxy
GitHub Copilot coding agent?
→ Add .github/copilot-setup-steps.yml to the repo
→ gh IS pre-installed; just configure GH_TOKEN
→ Commit and push — agent sessions pick it up automatically
gh commands failing?
→ "command not found" → gh not installed; add to setup script
→ HTTP 401 → GH_TOKEN not set; add to environment variables
→ HTTP 403 → Token lacks required scope; check permissions
→ "could not determine repo" → Use -R owner/repo flag
→ See references/cloud-auth.md for more
Need gh in local dev too?
→ Run: gh auth login (interactive, browser-based)
→ Or set GH_TOKEN env var for headless/CI useghghGH_TOKENgh#!/bin/bash
apt update && apt install -y ghGH_TOKENrepo.claude/settings.json{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "if [ \"$CLAUDE_CODE_REMOTE\" = \"true\" ]; then apt update && apt install -y gh; fi",
"timeout": 120
}
]
}
]
}
}CLAUDE_CODE_REMOTE-Rgh-R owner/repogh pr create -R codervisor/myrepo --title "..." --body "..."
gh issue list -R codervisor/myrepo.github/copilot-setup-steps.ymlgh.github/copilot-setup-steps.ymlname: "Copilot Setup Steps"
on: repository_dispatch
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Authenticate gh CLI
run: gh auth status
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}templates/copilot-setup-steps.yml| Setup scripts | SessionStart hooks | copilot-setup-steps.yml | |
|---|---|---|---|
| Platform | Claude Code cloud only | Claude Code (local + cloud) | GitHub Copilot agents only |
| Configured in | Environment settings UI | | |
| Runs | Before Claude launches | After Claude launches | Before Copilot agent launches |
| Runs on resume | No (new sessions only) | Yes (every session) | Yes |
| Network | Needs registry access | Needs registry access | Full GitHub Actions network |
# PRs (use -R in Claude Code cloud)
gh pr create -R owner/repo --title "..." --body "..."
gh pr list -R owner/repo
gh pr view -R owner/repo
gh pr merge -R owner/repo --squash --delete-branch
# Issues
gh issue list -R owner/repo
gh issue view 42 -R owner/repo
gh issue create -R owner/repo --title "..." --body "..."
# API (for anything not covered by subcommands)
gh api repos/owner/repo/actions/runs| Symptom | Cause | Fix |
|---|---|---|
| Not installed (Claude Code cloud) | Add |
| | Add to environment variables in settings UI |
| Token lacks | Regenerate PAT with |
| Sandbox proxy hides git remote | Use |
| No upstream branch | Push with |
| Setup script fails | No network access | Set network to "Limited" (default) or "Full" |
references/cloud-auth.mdreferences/copilot-setup-steps.mdnpx skills add -g onsager-ai/dev-skills --skill github-integration -a claude-code -ygh