github-multi-account

GitHub

自动检测GitHub多账号并配置别名,实现个人与工作账号的无缝切换,提升多账户管理效率。

.squad/templates/skills/github-multi-account/SKILL.md microsoft/Generative-AI-for-beginners-dotnet

Trigger Scenarios

用户拥有多个GitHub账号 需要区分个人与工作账号操作

Install

npx skills add microsoft/Generative-AI-for-beginners-dotnet --skill github-multi-account -g -y
More Options

Non-standard path

npx skills add https://github.com/microsoft/Generative-AI-for-beginners-dotnet/tree/main/.squad/templates/skills/github-multi-account -g -y

Use without installing

npx skills use microsoft/Generative-AI-for-beginners-dotnet@github-multi-account

指定 Agent (Claude Code)

npx skills add microsoft/Generative-AI-for-beginners-dotnet --skill github-multi-account -a claude-code -g -y

安装 repo 全部 skill

npx skills add microsoft/Generative-AI-for-beginners-dotnet --all -g -y

预览 repo 内 skill

npx skills add microsoft/Generative-AI-for-beginners-dotnet --list

SKILL.md

Frontmatter
{
    "name": "github-multi-account",
    "author": "tamirdresher",
    "source": "https:\/\/github.com\/tamirdresher\/squad-skills\/tree\/main\/plugins\/github-multi-account",
    "confidence": "high",
    "description": "Detect and set up account-locked gh aliases for multi-account GitHub. The AI reads this skill, detects accounts, asks the user which is personal\/work, and runs the setup automatically."
}

GitHub Multi-Account — AI-Driven Setup

When to Activate

When the user has multiple GitHub accounts (check with gh auth status). If you see 2+ accounts listed, this skill applies.

What to Do (as the AI agent)

Step 1: Detect accounts

Run: gh auth status Look for multiple accounts. Note which usernames are listed.

Step 2: Ask the user

Ask: "I see you have multiple GitHub accounts: {list them}. Which one is your personal account and which is your work/EMU account?"

Step 3: Run the setup automatically

Once the user confirms, do ALL of this for them:

# 1. Define the functions
$personal = "THEIR_PERSONAL_USERNAME"
$work = "THEIR_WORK_USERNAME"

# 2. Add to PowerShell profile
$profilePath = $PROFILE.CurrentUserAllHosts
if (!(Test-Path $profilePath)) { New-Item -Path $profilePath -Force | Out-Null }
$existing = Get-Content $profilePath -Raw -ErrorAction SilentlyContinue
if ($existing -notmatch "gh-personal") {
    $block = @"

# === GitHub Multi-Account Aliases ===
function gh-personal { gh auth switch --user $personal 2>`$null | Out-Null; gh @args }
function gh-work { gh auth switch --user $work 2>`$null | Out-Null; gh @args }
Set-Alias ghp gh-personal
Set-Alias ghw gh-work
"@
    Add-Content -Path $profilePath -Value $block
}

# 3. Create CMD wrappers
$binDir = Join-Path $env:USERPROFILE ".squad\bin"
if (!(Test-Path $binDir)) { New-Item -ItemType Directory -Path $binDir -Force | Out-Null }
"@echo off`ngh auth switch --user $personal >nul 2>&1`ngh %*" | Out-File "$binDir\ghp.cmd" -Encoding ascii
"@echo off`ngh auth switch --user $work >nul 2>&1`ngh %*" | Out-File "$binDir\ghw.cmd" -Encoding ascii

# 4. Add to PATH
$userPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($userPath -notmatch [regex]::Escape($binDir)) {
    [Environment]::SetEnvironmentVariable("PATH", "$binDir;$userPath", "User")
    $env:PATH = "$binDir;$env:PATH"
}

# 5. Load in current session
function gh-personal { gh auth switch --user $personal 2>$null | Out-Null; gh @args }
function gh-work { gh auth switch --user $work 2>$null | Out-Null; gh @args }
Set-Alias ghp gh-personal
Set-Alias ghw gh-work

Step 4: Verify for the user

Run these and show the results:

ghp api user --jq '.login'   # should show personal username
ghw api user --jq '.login'   # should show work username

Step 5: Tell the user

"All set! From now on use ghp for personal repos and ghw for work repos. I'll use them too."

After Setup — Usage Rules

  1. NEVER use bare gh for repo operations — always ghp or ghw
  2. NEVER manually gh auth switch — the aliases handle it
  3. Determine alias by repo owner:
    • Personal account repos → ghp / gh-personal
    • Work/EMU account repos → ghw / gh-work

Repo-Specific Account Binding

This repo (bradygaster/squad) is bound to the bradygaster (personal) account. All gh operations in this repo MUST use ghp / gh-personal.

For Squad Agents

At the TOP of any script touching GitHub, define:

function gh-personal { gh auth switch --user bradygaster 2>$null | Out-Null; gh @args }
function gh-work { gh auth switch --user bradyg_microsoft 2>$null | Out-Null; gh @args }

Version History

  • bd4e082 Current 2026-08-20 14:06

Same Skill Collection

.github/skills/agent-collaboration/SKILL.md
.github/skills/coordinator-init-mode/SKILL.md
.github/skills/coordinator-response-mode/SKILL.md
.github/skills/coordinator-source-of-truth/SKILL.md
.github/skills/cross-squad-communication/SKILL.md
.github/skills/cross-squad/SKILL.md
.github/skills/error-recovery/SKILL.md
.github/skills/git-workflow/SKILL.md
.github/skills/iterative-retrieval/SKILL.md
.github/skills/reflect/SKILL.md
.github/skills/reviewer-protocol/SKILL.md
.github/skills/secret-handling/SKILL.md
.github/skills/session-recovery/SKILL.md
.github/skills/squad-conventions/SKILL.md
.github/skills/squad-help/SKILL.md
.github/skills/squad-version-check/SKILL.md
.github/skills/squad/SKILL.md
.github/skills/tiered-memory/SKILL.md
.squad/templates/skills/agent-collaboration/SKILL.md
.squad/templates/skills/agent-conduct/SKILL.md
.squad/templates/skills/architectural-proposals/SKILL.md
.squad/templates/skills/ci-validation-gates/SKILL.md
.squad/templates/skills/client-compatibility/SKILL.md
.squad/templates/skills/coordinator-init-mode/SKILL.md
.squad/templates/skills/coordinator-response-mode/SKILL.md
.squad/templates/skills/coordinator-source-of-truth/SKILL.md
.squad/templates/skills/cross-machine-coordination/SKILL.md
.squad/templates/skills/cross-squad-communication/SKILL.md
.squad/templates/skills/cross-squad/SKILL.md
.squad/templates/skills/distributed-mesh/SKILL.md
.squad/templates/skills/docs-standards/SKILL.md
.squad/templates/skills/e2e-template-testing/SKILL.md
.squad/templates/skills/economy-mode/SKILL.md
.squad/templates/skills/error-recovery/SKILL.md
.squad/templates/skills/external-comms/SKILL.md
.squad/templates/skills/fact-checking/SKILL.md
.squad/templates/skills/gh-auth-isolation/SKILL.md
.squad/templates/skills/git-workflow/SKILL.md
.squad/templates/skills/history-hygiene/SKILL.md
.squad/templates/skills/humanizer/SKILL.md
.squad/templates/skills/init-mode/SKILL.md
.squad/templates/skills/iterative-retrieval/SKILL.md
.squad/templates/skills/model-selection/SKILL.md
.squad/templates/skills/nap/SKILL.md
.squad/templates/skills/notification-routing/SKILL.md
.squad/templates/skills/personal-squad/SKILL.md
.squad/templates/skills/pr-review-response/SKILL.md
.squad/templates/skills/pr-screenshots/SKILL.md
.squad/templates/skills/ralph-two-pass-scan/SKILL.md

Metadata

Files
0
Version
bd4e082
Hash
8cdd19d1
Indexed
2026-08-20 14:06

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 09:52
浙ICP备14020137号-1 $방문자$