Packs / github-ops-public
accounts-and-token-switching
Use several GitHub accounts from one machine safely: per-command tokens via `gh auth token -u <user>` passed through env (GH_TOKEN or a git credential helper), never `gh auth switch`, never tokens in argv or remote URLs.
Install
logicpacks pack use github-ops-public/accounts-and-token-switchingget_pack github-ops-public/accounts-and-token-switchingThe second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.
Keys it needs (names only)
- GITHUB_TOKEN
Playbooks included
- Spec:
spec/SPEC.md(goal, steps, edge cases, don’ts) - Routes:
gh-cli - Checks: 3 in
outcome/checks.yaml - Code:
gh_as.shgit_push_as.sh - Tools: gh, git, bash
Usage, last 8 weeks
New: no recorded use yet.
Purpose (from spec/SPEC.md)
Use several GitHub accounts from one machine safely: per-command tokens via gh auth token -u <user> passed through env (GH_TOKEN or a git credential helper), never gh auth switch, never tokens in argv or remote URLs.
Goal
Any agent can act as the right account for one command without changing global state other agents depend on.
Steps
- See who is logged in:
gh auth status(several accounts can sit in the keyring). - Run one gh command as a user:
bash code/gh_as.sh <user> gh repo list <owner> --limit 5(sets GH_TOKEN in the child env only). - Push as a user:
bash code/git_push_as.sh <user> origin main(token reaches git through a credential helper reading an env var). - Use the account that owns/has admin on the target org (check
gh api orgs/<org>/memberships/<user>). - For tokens stored in the LogicPacks vault:
lp run -- gh ...with GITHUB_TOKEN as a sealed placeholder.
Edge cases
gh auth switchchanges global state: parallel agents race and push as the wrong user.- A token in a remote URL (
https://x-access-token:TOKEN@github.com/...) lands in shell history, process lists and .git/config. - Different accounts have different scopes (some lack delete_repo); check
gh auth statusscopes before destructive calls. - GraphQL as the owner shows private counts; use another account's token to see what the public sees.
Don'ts
- Don't run
gh auth switchin shared sessions. - Don't paste tokens into chat or files; if one leaks, Waleed decides rotation.
- Don't write tokens into remote URLs or argv.