plugins/github/skills/github-auth/SKILL.md
Guide Claude through GitHub authentication methods including device code flow, personal access tokens, fine-grained tokens, and GitHub App authorization. Use when the user needs to authenticate with GitHub for CLI operations, API access, cross-repo work, or automated workflows. <example>authenticate with github</example> <example>I need to create a PR in another repo</example> <example>gh auth login</example> <example>set up a personal access token</example> <example>configure github app authentication</example>
npx skillsauth add nsheaps/ai-mktpl github-authInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill covers all GitHub authentication methods relevant to Claude Code sessions. It enables Claude to guide users through the appropriate auth flow for their use case.
| Method | Best For | Expires | Scope Control | | ------------------------------- | ------------------------ | --------------------------- | ------------------ | | Device Code Flow | Interactive CLI sessions | Session-based | Per-login | | Personal Access Token (classic) | Simple automation, CI | Configurable / never | Broad scopes | | Fine-Grained PAT | Targeted repo access | Configurable (max 1yr) | Per-repo, granular | | GitHub App (as app) | Automated systems, bots | 1 hour (installation token) | Per-installation | | GitHub App (as user) | User-to-server, OAuth | Session-based | Per-authorization |
Best for: Claude Code sessions where the user is present and can authorize in a browser.
BROWSER=false gh auth login
This outputs:
ABCD-1234)https://github.com/login/deviceThe user visits the URL, enters the code, and authorizes access.
# GitHub.com with HTTPS
BROWSER=false gh auth login --hostname github.com --git-protocol https
# With specific scopes
BROWSER=false gh auth login --scopes "repo,read:org,write:packages"
# GitHub Enterprise
BROWSER=false gh auth login --hostname github.mycompany.com
| Scope | Description |
| ------------------ | -------------------------------------- |
| repo | Full control of private repositories |
| read:org | Read organization membership |
| write:org | Read and write organization membership |
| read:packages | Download packages from GitHub Packages |
| write:packages | Upload packages to GitHub Packages |
| admin:public_key | Manage public keys |
| gist | Create gists |
| workflow | Update GitHub Action workflows |
# Check current status
gh auth status
# Refresh expired token
BROWSER=false gh auth refresh
# Switch accounts
gh auth switch --user username
# Logout
gh auth logout
Best for: Simple automation, CI pipelines, or when device code flow isn't available.
https://github.com/settings/tokens# Authenticate with token
echo "$GH_TOKEN" | gh auth login --with-token
# Or set as environment variable
export GH_TOKEN="ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export GITHUB_TOKEN="$GH_TOKEN" # Also recognized by git and many tools
# Via credential helper
git config --global credential.helper store
# Then use token as password when prompted
# Or via URL
git clone https://x-access-token:${GH_TOKEN}@github.com/owner/repo.git
repo grants access to ALL repos)Best for: Targeted access to specific repositories with minimal permissions.
https://github.com/settings/personal-access-tokens/newSame as classic PATs — set GH_TOKEN or GITHUB_TOKEN environment variable.
Best for: Automated systems, bot identities, long-running agent sessions.
GitHub Apps authenticate using a two-step process:
# Step 1: Generate JWT
NOW=$(date +%s)
IAT=$((NOW - 60))
EXP=$((NOW + 540))
HEADER=$(echo -n '{"alg":"RS256","typ":"JWT"}' | base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
PAYLOAD=$(echo -n "{\"iss\":\"${GITHUB_APP_ID}\",\"iat\":${IAT},\"exp\":${EXP}}" | base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
SIGNATURE=$(echo -n "${HEADER}.${PAYLOAD}" | openssl dgst -sha256 -sign "$GITHUB_APP_PRIVATE_KEY_PATH" | base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n')
JWT="${HEADER}.${PAYLOAD}.${SIGNATURE}"
# Step 2: Exchange for installation token
curl -s -X POST \
-H "Authorization: Bearer ${JWT}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/app/installations/${GITHUB_INSTALLATION_ID}/access_tokens"
| Variable | Description |
| ----------------------------- | ------------------------------------------ |
| GITHUB_APP_ID | The GitHub App's numeric ID |
| GITHUB_APP_PRIVATE_KEY_PATH | Path to PEM private key file |
| GITHUB_INSTALLATION_ID | Installation ID for the target account/org |
# With gh CLI
export GH_TOKEN="ghs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# With git
git config credential.https://github.com.helper \
'!f() { echo "protocol=https"; echo "host=github.com"; echo "username=x-access-token"; echo "password=${GH_TOKEN}"; }; f'
GitHub Apps can also act on behalf of a user via OAuth:
https://github.com/login/oauth/authorize?client_id=APP_CLIENT_IDThis is useful when the app needs to act as a specific user rather than as itself.
Is a user present and interactive?
Do you need access to specific repos only?
Is this for a long-running automated system?
Do you need a bot identity (not a user)?
chmod 600https://github.com/settings/applications| Error | Cause | Solution |
| ------------------------ | -------------------------------- | --------------------------------------- |
| HTTP 401 | Token expired or invalid | Re-authenticate or generate new token |
| HTTP 403 | Insufficient permissions | Check scopes; re-authenticate with more |
| HTTP 404 | Private repo, not authenticated | Authenticate to access private repos |
| SSO Required | Organization requires SSO | Authorize SSO in browser settings |
| Bad credentials | Token revoked or malformed | Re-authenticate from scratch |
| JWT expired | GitHub App JWT older than 10 min | Regenerate JWT and retry |
| Installation suspended | App installation was suspended | Contact org admin |
| Method | Storage Location |
| ---------------------- | ------------------------------------------- |
| gh auth login | ~/.config/gh/hosts.yml |
| GH_TOKEN env var | Process environment |
| GITHUB_TOKEN env var | Process environment |
| GitHub App token file | ~/.config/agent/github-token (convention) |
| Git credential helper | OS keychain or ~/.git-credentials |
For organizations requiring SAML SSO:
https://github.com/settings/applicationstools
Reference material for Claude Code internals — the on-disk layout under ~/.claude and project-scope .claude, the plugin cache, session-env propagation, and the full hook lifecycle. Auto-recall when working on Claude-Code-related tasks: writing or debugging hooks, authoring plugins, inspecting session state, troubleshooting why an env var is or isn't visible to a Bash tool call, or when paths under ~/.claude or ~/.claude/plugins/ come up.
development
Manage GitHub App installation tokens in Claude Code sessions. Use when tokens expire, auth errors occur in long-running sessions, or when setting up GitHub App credentials for agent teams. <example>my github token expired</example> <example>refresh the github app token</example> <example>check token status</example> <example>set up github app authentication for this session</example>
tools
Auto-detect project formatting tools and configure edit-utils settings
tools
Use this skill when the user asks about 1Password, secrets management, retrieving credentials, using op CLI, service accounts, secret references, vault operations, or any task involving the 1Password CLI (op). Also use when needing to inject secrets into environment variables, read passwords or API keys from 1Password, or manage 1Password items from the command line.