Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Safely manage multiple GitHub identities (EMU + personal) in agent workflows
.claude/skills/github-gh-auth-isolation/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 25% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 43% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 85% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 31% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 58% | 0% |
Many developers use GitHub through an Enterprise Managed User (EMU) account at work while maintaining a personal GitHub account for open-source contributions. AI agents spawned by Squad inherit the shell's default gh authentication — which is usually the EMU account. This causes failures when agents try to push to personal repos, create PRs on forks, or interact with resources outside the enterprise org.
This skill teaches agents how to detect the active identity, switch contexts safely, and avoid mixing credentials across operations.
Before any GitHub operation, check which account is active:
bashgh auth status
Look for:
Logged in to github.com as USERNAME — the active accountToken scopes: ... — what permissions are availableWhen you need to operate as a specific user (not the default):
bash# Get the personal account token (by username) gh auth token --user personaluser # Get the EMU account token gh auth token --user corpalias_enterprise
Use case: Push to a personal fork while the default gh auth is the EMU account.
The most common scenario: your shell defaults to the EMU account, but you need to push to a personal GitHub repo.
bash# 1. Extract the personal token $token = gh auth token --user personaluser # 2. Push using token-authenticated HTTPS git push https://personaluser:$token@github.com/personaluser/repo.git branch-name
Why this works: gh auth token --user reads from gh's credential store without switching the active account. The token is used inline for a single operation and never persisted.
When the default gh context is EMU but you need to create a PR from a personal fork:
bash# Option 1: Use --repo flag (works if token has access) gh pr create --repo upstream/repo --head personaluser:branch --title "..." --body "..." # Option 2: Temporarily set GH_TOKEN for one command $env:GH_TOKEN = $(gh auth token --user personaluser) gh pr create --repo upstream/repo --head personaluser:branch --title "..." Remove-Item Env:\GH_TOKEN
For complete isolation between accounts, use separate gh config directories:
bash# Personal account operations $env:GH_CONFIG_DIR = "$HOME/.config/gh-public" gh auth login # Login with personal account (one-time setup) gh repo clone personaluser/repo # EMU account operations (default) Remove-Item Env:\GH_CONFIG_DIR gh auth status # Back to EMU account
Setup (one-time):
bash# Create isolated config for personal account mkdir ~/.config/gh-public $env:GH_CONFIG_DIR = "$HOME/.config/gh-public" gh auth login --web --git-protocol https
Add to your shell profile for convenience:
powershell# PowerShell profile function ghp { $env:GH_CONFIG_DIR = "$HOME/.config/gh-public"; gh @args; Remove-Item Env:\GH_CONFIG_DIR } function ghe { gh @args } # Default EMU # Usage: # ghp repo clone personaluser/repo # Uses personal account # ghe issue list # Uses EMU account
bash# Bash/Zsh profile alias ghp='GH_CONFIG_DIR=~/.config/gh-public gh' alias ghe='gh' # Usage: # ghp repo clone personaluser/repo # ghe issue list
powershell# Agent needs to push to personaluser.github.io (personal repo) # Default gh auth is corpalias_enterprise (EMU) $token = gh auth token --user personaluser git remote set-url origin https://personaluser:$token@github.com/personaluser/personaluser.github.io.git git push origin main # Clean up — don't leave token in remote URL git remote set-url origin https://github.com/personaluser/personaluser.github.io.git
powershell# Fork: personaluser/squad, Upstream: bradygaster/squad # Agent is on branch contrib/fix-docs in the fork clone git push origin contrib/fix-docs # Pushes to fork (may need token auth) # Create PR targeting upstream gh pr create --repo bradygaster/squad --head personaluser:contrib/fix-docs ` --title "docs: fix installation guide" ` --body "Fixes #123"
bash# BAD: Agent assumes default gh auth works for personal repos git push origin main # ERROR: Permission denied — EMU account has no access to personal repo # BAD: Hardcoding tokens in scripts git push https://personaluser:ghp_xxxxxxxxxxxx@github.com/personaluser/repo.git main # SECURITY RISK: Token exposed in command history and process list
bash# Always verify which account has access before operations gh auth status # If wrong account, use token extraction: $token = gh auth token --user personaluser git push https://personaluser:$token@github.com/personaluser/repo.git main
gh auth token --user to extract at runtime.gh auth works for all repos. EMU accounts can't access personal repos and vice versa.gh auth login globally mid-session. This changes the default for ALL processes and can break parallel agents..env or .squad/ files. These get committed by Scribe. Use gh's credential store.gh auth switch in multi-agent sessions. One agent switching affects all others sharing the shell.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 18,685 | 13,741 | -26% | 1 | 1 | 0% | 3,212 | 4,004 | +25% | 0 | 0 | — |
case-02 | fail→pass | 11,730 | 6,184 | -47% | 1 | 1 | 0% | 1,713 | 2,448 | +43% | 0 | 0 | — |
case-03 | pass→pass | 17,411 | 11,871 | -32% | 1 | 1 | 0% | 2,747 | 3,612 | +31% | 0 | 0 | — |
case-04 | pass→pass | 8,262 | 6,088 | -26% | 1 | 1 | 0% | 1,250 | 1,972 | +58% | 0 | 0 | — |
case-05 | pass→pass | 8,967 | 10,207 | +14% | 1 | 1 | 0% | 1,445 | 1,976 | +37% | 0 | 0 | — |
case-06 | pass→pass | 17,582 | 8,997 | -49% | 1 | 1 | 0% | 2,227 | 3,029 | +36% | 0 | 0 | — |
case-07 | pass→pass | 10,086 | 7,555 | -25% | 1 | 1 | 0% | 1,518 | 2,868 | +89% | 0 | 0 | — |
case-08 | pass→pass | 16,177 | 9,051 | -44% | 1 | 1 | 0% | 2,268 | 3,019 | +33% | 0 | 0 | — |
case-09 | fail→pass | 11,198 | 9,064 | -19% | 1 | 1 | 0% | 1,697 | 3,145 | +85% | 0 | 0 | — |
case-10 | pass→pass | 6,260 | 4,801 | -23% | 1 | 1 | 0% | 855 | 2,215 | +159% | 0 | 0 | — |
case-11 | pass→pass | 10,545 | 7,149 | -32% | 1 | 1 | 0% | 1,623 | 2,634 | +62% | 0 | 0 | — |
case-12 | pass→pass | 6,890 | 5,335 | -23% | 1 | 1 | 0% | 1,209 | 2,293 | +90% | 0 | 0 | — |
case-13 | pass→pass | 8,519 | 4,781 | -44% | 1 | 1 | 0% | 1,339 | 2,204 | +65% | 0 | 0 | — |
case-14 | pass→pass | 23,512 | 7,850 | -67% | 1 | 1 | 0% | 1,794 | 2,717 | +51% | 0 | 0 | — |
case-15 | pass→pass | 13,662 | 9,593 | -30% | 1 | 1 | 0% | 2,008 | 2,975 | +48% | 0 | 0 | — |
case-16 | pass→pass | 5,604 | 3,555 | -37% | 1 | 1 | 0% | 804 | 1,968 | +145% | 0 | 0 | — |
case-17 | pass→pass | 7,327 | 5,752 | -21% | 1 | 1 | 0% | 1,241 | 2,254 | +82% | 0 | 0 | — |
case-18 | pass→pass | 7,760 | 125,953 | +1523% | 1 | 1 | 0% | 1,184 | 2,351 | +99% | 0 | 0 | — |
case-19 | pass→pass | 7,069 | 5,134 | -27% | 1 | 1 | 0% | 1,090 | 2,121 | +95% | 0 | 0 | — |
case-20 | pass→pass | 10,276 | 8,288 | -19% | 1 | 1 | 0% | 1,591 | 2,953 | +86% | 0 | 0 | — |
case-21 | pass→pass | 10,276 | 7,599 | -26% | 1 | 1 | 0% | 1,721 | 2,718 | +58% | 0 | 0 | — |
case-22 | pass→pass | 10,354 | 10,008 | -3% | 1 | 1 | 0% | 1,795 | 3,158 | +76% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.