Repository navigation
Description
Feature request
Add an environment variable that tells GitHub CLI to ignore all configured credentials and act as an anonymous public user for the current process.
Example shape:
GH_AUTH_DISABLED=1 gh api repos/cli/cli/tagsor similar naming, e.g. GH_ANONYMOUS=1.
Motivation
Today, if a process wants gh to make an anonymous public request, it has to manually scrub every auth source it knows about:
env -u GH_TOKEN -u GITHUB_TOKEN \
-u GH_ENTERPRISE_TOKEN -u GITHUB_ENTERPRISE_TOKEN \
GH_CONFIG_DIR="$(mktemp -d)" \
gh api repos/cli/cli/tagsThat is brittle:
- callers have to remember every token environment variable
- stored credentials require a separate
GH_CONFIG_DIRworkaround - new auth-related variables would require every caller to update their scrub list
- scripts that intentionally want anonymous/public behavior can accidentally inherit CI tokens or enterprise tokens from the parent environment
A single opt-in env var would make this behavior explicit and easier to audit.
Use case
Tooling that shells out to GitHub-related commands sometimes needs to fetch public release metadata while running inside CI or a larger authenticated environment. In those cases, inherited tokens can be actively harmful: they may be for the wrong GitHub host, have insufficient scopes, be rate-limited, or trigger a 403 where anonymous public access would otherwise work.
The desired behavior is: for this process only, do not read token env vars, do not read stored hosts credentials, and do not prompt; just make the request anonymously.
Possible behavior
When set, the variable would make gh:
- ignore
GH_TOKEN,GITHUB_TOKEN,GH_ENTERPRISE_TOKEN, andGITHUB_ENTERPRISE_TOKEN - ignore stored host credentials from
GH_CONFIG_DIR/ default config - avoid interactive auth prompts
- continue to respect non-auth env vars such as
GH_HOST,GH_REPO,GH_DEBUG, etc.
I would be interested in contributing a PR if this is a direction the project would accept.
Activity
babakks commentedon May 12, 2026
Thanks for the detailed writeup, @junior-ricon! 🙏
This is an interesting idea, but I want to understand the real world use cases a bit more before we commit to a direction.
Most
ghcommands require authentication, even when the underlying action could technically work without it. An env var likeGH_AUTH_DISABLEDwould effectively disable the majority ofghcommands, which could lead to confusing failures, especially if the var leaks into child processes or persists in a shell session longer than intended.Could you share more about the specific commands you're using in these scenarios? For example, is this mostly
gh apicalls against public endpoints, or are there other commands involved? Knowing the concrete workflows would help us figure out whether a narrower solution (like a per-command flag) might be a better fit than a global env var.BronkHonkyTonk commentedon May 13, 2026
https://github.com/cli/cli/actions/runs/25777278999/job/75712433157#step:1:1
github-actions commentedon May 26, 2026
Thank you for your issue!
We haven't gotten a response to our questions above. With only the information that is currently in the issue, we don't have enough information to take action. We're going to close this but don't hesitate to reach out if you have or find the answers we need. If you answer our questions above, this issue will automatically reopen.
rusak47 commentedon Aug 13, 2026
Hello! A simple use case would be to allow the coding agent to check issues and similar information in read‑only mode — it can retrieve data, but it should not be allowed to write or commit any changes.
I'm new to the GitHub CLI tool, so maybe this functionality already exists. If so, could you please point me in the right direction on how to set that up?
david-a-wheeler commentedon Aug 31, 2026
Hi, same issue for me: AIs are the key driver.
Claude Code keeps wanting to use
gh, but I don't give Claude Code any working GitHub tokens and I'm working on publicly-visible repos.For the moment I'm creating an
anon_github [COMMANDS]to switch to anonymous github access, given the env sequence above, to the best I can. If[COMMANDS]is given they're run, else it'll spawn a shell. Not ideal though, since gh sometimes wants login access when it's not needed.Add GH_PUBLIC_TOKEN + NO_APPROVAL_SECRETS so gh works for a sandboxed…
david-a-wheeler commentedon Sep 1, 2026
All: if you ended up here, I have identified an obvious workaround: on GitHub, create a fine-grained token scoped to "public repos only" and give it no permissions. Hand that token to gh.
Then gh works just fine for reading public read-only information, while preventing changes.
jglick commentedon Sep 3, 2026
#2680 is older.
The suggested script in #13307 (comment) does not seem to work as of 2.99.0. The empty PAT suggested in #13307 (comment) does work, thank you!