GitHub CLI (gh) auth — unset stale token env vars before API calls.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# GitHub CLI authentication
Before any `gh` command (`gh pr create`, `gh issue`, `gh run`, etc.), **unset stale token environment variables** that override the keyring login:
```bash
env -u GH_TOKEN -u GITHUB_TOKEN gh <subcommand> ...
```
## Why
An invalid or expired `GH_TOKEN` / `GITHUB_TOKEN` in the shell environment causes `HTTP 401: Bad credentials` even when `gh auth status` shows a valid keyring account (with "Active account: false" on the keyring entry).
## Checklist for PRs
1. Push branch: `git push -u origin HEAD` (SSH/git creds are separate from `gh`).
2. Create PR: `env -u GH_TOKEN -u GITHUB_TOKEN gh pr create ...`
3. If auth still fails: `gh auth status` then `gh auth login` if needed.
Do **not** export `GH_TOKEN` for local `gh` unless intentionally using that token for the session.
The line at the top of this page pins the label git:20260603.0f2037c, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
GET https://markdownregistry.com/api/v1/artifacts/art_oucos6jo4qkdzl75
GET https://markdownregistry.com/api/v1/resolve?ref=metagit-ai/metagit-cli/.cursor/rules/github-cli.mdc
GET https://markdownregistry.com/api/v1/blob/d249be7094e7cda8713a7a90a3c36adb1df3b10f5b11aee5f69e9aeabdfee661
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
metagit-ai/metagit-cli · .agents/skills/gitnexus-cli/SKILL.md · Use when the user needs to run GitNexus CLI commands like analyze/index a repo, check status, clean the index, generate…
metagit-ai/metagit-cli · .agents/skills/gitnexus-debugging/SKILL.md · Use when the user is debugging a bug, tracing an error, or asking why something fails. Examples: "Why is X failing?"…
metagit-ai/metagit-cli · .agents/skills/gitnexus-exploring/SKILL.md · Use when the user asks how code works, wants to understand architecture, trace execution flows, or explore unfamiliar…
metagit-ai/metagit-cli · .agents/skills/gitnexus-guide/SKILL.md · Use when the user asks about GitNexus itself — available tools, how to query the knowledge graph, MCP resources, graph…
metagit-ai/metagit-cli · .agents/skills/gitnexus-impact-analysis/SKILL.md · Use when the user wants to know what will break if they change something, or needs safety analysis before editing code…
metagit-ai/metagit-cli · .agents/skills/gitnexus-refactoring/SKILL.md · Use when the user wants to rename, extract, split, move, or restructure code safely. Examples: "Rename this function"…
metagit-ai/metagit-cli · .agents/skills/gitnexus/gitnexus-cli/SKILL.md · Use when the user needs to run GitNexus CLI commands like analyze/index a repo, check status, clean the index, generate…
metagit-ai/metagit-cli · .agents/skills/gitnexus/gitnexus-debugging/SKILL.md · Use when the user is debugging a bug, tracing an error, or asking why something fails. Examples: "Why is X failing?"…
metagit-ai/metagit-cli · .agents/skills/gitnexus/gitnexus-exploring/SKILL.md · Use when the user asks how code works, wants to understand architecture, trace execution flows, or explore unfamiliar…
metagit-ai/metagit-cli · .agents/skills/gitnexus/gitnexus-guide/SKILL.md · Use when the user asks about GitNexus itself — available tools, how to query the knowledge graph, MCP resources, graph…
metagit-ai/metagit-cli · .agents/skills/gitnexus/gitnexus-impact-analysis/SKILL.md · Use when the user wants to know what will break if they change something, or needs safety analysis before editing code…
metagit-ai/metagit-cli · .agents/skills/gitnexus/gitnexus-refactoring/SKILL.md · Use when the user wants to rename, extract, split, move, or restructure code safely. Examples: "Rename this function"…
melvynx/ai-maxxing-skills · skills/setup-vps/server-skills/github-cli/SKILL.md · Every GitHub job from this server through the gh CLI - list, create and clone repos, push code, pull requests, issues…
ethanyoq/skill-hub · archives/user-installed-skills/github-cli/e4ed8a3ab1d64cb6/github-cli/SKILL.md · MUST USE for GitHub-related operations, including a GitHub URL, repository or code search, Issues, pull requests…
anilcancakir/claude-code · opencode/ac/skills/github-cli/SKILL.md · Work with GitHub repositories, issues, PRs, releases and Actions runs through the gh CLI instead of web fetches. Use…
anilcancakir/claude-code · plugins/ac/skills/github-cli/SKILL.md · Work with GitHub repositories, issues, PRs, releases and Actions runs through the gh CLI instead of web fetches.
rogue-dev-studio/ai-agents-rogue · skills/github-cli/SKILL.md · GitHub CLI authentication and workflow configuration. Use when the project needs this capability or the user / team…