gh-auth-isolation

Detect active GitHub identity and isolate gh auth with GH_CONFIG_DIR.

Updated Mar 18, 2022
One-click install
npx skills add https://github.com/mpaulosky/dotfiles --skill gh-auth-isolation-mpaulosky
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gh-auth-isolation
Source: https://github.com/mpaulosky/dotfiles/tree/main/.copilot/skills/gh-auth-isolation
Command: npx skills add https://github.com/mpaulosky/dotfiles --skill gh-auth-isolation-mpaulosky

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Agents and developer shells frequently inherit a single gh (GitHub CLI) authentication context, causing permission failures, accidental credential mixing, and potential token exposure when working across Enterprise Managed User (EMU) and personal accounts. This Skill provides actionable patterns to detect the active identity, perform one-off authenticated operations as a different user, and avoid global auth changes that impact parallel agents.

Core Features & Use Cases

  • Detect active identity: Use gh auth status to determine which account is currently authenticated and what token scopes are available.
  • One-off token extraction: Extract a specific user's token with gh auth token --user to perform single HTTPS operations without switching the global login.
  • Config directory isolation & aliases: Use GH_CONFIG_DIR to maintain separate gh configurations for personal and EMU accounts and add shell aliases for quick context switching.
  • Use Cases: Push to a personal fork while the default shell auth is EMU, create PRs from a personal fork to an upstream repo, or clone personal repos without changing enterprise credentials.

Quick Start

Use the gh-auth-isolation skill to check gh auth status, extract a personal token, and push a single commit to your personal repo without changing the global gh login.

Frequently Asked Questions about gh-auth-isolation

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

FAQPage Schema
How do I manage multiple GitHub accounts with gh CLI without switching the global login?

To manage multiple GitHub accounts without global switching, use gh-auth-isolation to extract per-user tokens for single HTTPS operations and set GH_CONFIG_DIR to maintain separate configurations for personal and EMU accounts.

How do I push to a personal fork when my default shell auth is an Enterprise Managed User?

Push to a personal fork while defaulting to an Enterprise Managed User by extracting your personal token with gh auth token --user to perform single HTTPS operations without changing the global gh login.

Why do my GitHub CLI operations fail when I use an EMU alongside personal accounts?

GitHub CLI operations fail with EMU and personal accounts due to a single inherited authentication context causing credential mixing. Detect the active identity and use config directory isolation to prevent these permission failures.

What is the best way to isolate GitHub credentials for parallel AI agents?

The best way to isolate GitHub credentials for parallel agents is using GH_CONFIG_DIR to maintain separate gh configurations and applying shell alias patterns to avoid global auth switching that impacts concurrent operations.

Can I check which GitHub identity is currently active in my shell?

You can check your active GitHub identity by running gh auth status to determine which account is currently authenticated and what token scopes are available for your operations.

Does using GH_CONFIG_DIR work for one-off authenticated git operations?

Yes, GH_CONFIG_DIR maintains separate gh configurations for personal and EMU accounts, while one-off token extraction allows single HTTPS operations like cloning or pushing without modifying the global authentication state.