gh-auth-isolation

Manage multiple GitHub identities in agent workflows using gh CLI token extraction and config isolation.

1|Updated Jul 7, 2026
One-click install
npx skills add https://github.com/seiggy/maf-copilot-studio-demo --skill gh-auth-isolation-seiggy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gh-auth-isolation
Source: https://github.com/seiggy/maf-copilot-studio-demo/tree/main/.squad/templates/skills/gh-auth-isolation
Command: npx skills add https://github.com/seiggy/maf-copilot-studio-demo --skill gh-auth-isolation-seiggy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents inherit the shell's default gh authentication, which is usually an Enterprise Managed User (EMU) account. This causes failures when agents push to personal repos, create PRs on forks, or access resources outside the enterprise org. ## Core Features & Use Cases - Identity Detection: Check the active GitHub account and token scopes with gh auth status before any operation. - Per-Account Token Extraction: Pull a specific account's token with gh auth token --user without switching the global default, then use it inline for pushes and PR creation. - Config Directory Isolation: Use GH_CONFIG_DIR to maintain fully separate gh configurations for EMU and personal accounts, with shell aliases for quick switching. - Use Case: An agent on a corporate machine needs to push a blog post to a personal GitHub Pages repo. It extracts the personal token at runtime, pushes via token-authenticated HTTPS, and resets the remote URL so no credential persists. ## Quick Start Ask the agent to check the current GitHub identity with gh auth status and push a branch to your personal repository using the correct account token.

Frequently Asked Questions about gh-auth-isolation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I push to a personal GitHub repo when gh is logged in with a work account?

Extract the personal account token with gh auth token --user yourname, then push using token-authenticated HTTPS like git push https://user:[email protected]/user/repo.git branch. Reset the remote URL afterward so the token is not persisted.

How do I check which GitHub account gh CLI is using?

Run gh auth status to see the active account, token scopes, and all logged-in identities. Each configured account appears as a separate entry showing its username and permissions.

Can I use two GitHub accounts with gh CLI at the same time?

Yes. Use GH_CONFIG_DIR to point gh at a separate config directory for the second account, or extract a specific account's token with gh auth token --user for single operations without changing the global default.

Why does git push fail with permission denied on my personal repo?

The failure happens because the shell's default gh authentication is an EMU corporate account that has no access to personal repositories. Verify with gh auth status, then authenticate the push with the personal account's token.

Is it safe to use gh auth switch in multi-agent sessions?

No. gh auth switch changes the global default for all processes sharing the shell, which can break parallel agents. Prefer per-command token extraction or GH_CONFIG_DIR isolation instead.