Github Multi Accountのロゴ

Github Multi Account

コミュニティ
tamirdresher
github-multi-account

Transparent gh proxy that auto-routes commands to the correct GitHub account based on repo context. Uses GH_CONFIG_DIR isolation — no more account-switching chaos.

概要

公開者tamirdresher
リポジトリsquad-skills
スキル名github-multi-account
スター
44
フォーク
9
同梱ファイル
4
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    tamirdresherがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルGithub Multi AccountをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/tamirdresher/squad-skills/tree/main/plugins/github-multi-account
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/tamirdresher/squad-skills.git /tmp/squad-skills
mkdir -p .claude/skills
cp -r /tmp/squad-skills/plugins/github-multi-account .claude/skills/github-multi-account
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでGithub Multi Accountを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にGithub Multi Accountを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Github Multi Accountは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

GitHub Multi-Account Proxy

Confidence: medium — proxy architecture is proven in production via ghe/ghp wrappers; the transparent layer is new.

Problem

When you have two GitHub accounts (EMU work + personal), every gh command risks running against the wrong identity. The original approach used gh auth switch aliases (ghp/ghw), but three friction points remained:

  1. Cognitive load — users must remember ghe vs ghp for every command
  2. Token expiry — expired tokens in ~/.config/gh-emu or ~/.config/gh-public silently break automation (including Ralph)
  3. Git credential gap — git push/pull uses the global credential helper, ignoring GH_CONFIG_DIR isolation

Solution

A transparent gh PowerShell function that intercepts every gh call, detects which account to use from the git remote URL, sets GH_CONFIG_DIR, and delegates to the real gh.exe. Combined with a token health monitor and git credential helper integration.

Key insight: The existing GH_CONFIG_DIR isolation architecture is 90% there — the proxy just makes it transparent. No new dependencies, zero changes to Ralph.

How It Works (with the proxy)

User/script types: gh pr list
    │
    ├─ Is GH_CONFIG_DIR already set? ──YES──► delegate to gh.exe (respect explicit choice)
    │                                          ◄── Ralph sets this in Step -1
    │                                          ◄── ghe/ghp set this explicitly
    │
    └─ NO → detect from git remote URL
         │
         ├─ Remote matches "tamirdresher_microsoft"
         │  └─► GH_CONFIG_DIR = ~/.config/gh-emu
         │
         ├─ Remote matches "tamirdresher/"
         │  └─► GH_CONFIG_DIR = ~/.config/gh-public
         │
         └─ No remote / no match
            └─► GH_CONFIG_DIR = ~/.config/gh-emu (default = work)

Components

ComponentFilePurpose
Transparent proxygh-proxy.ps1Auto-routes gh → correct GH_CONFIG_DIR
Token healthgh-proxy.ps1Test-GhTokenHealth / Repair-GhToken functions
Setup scriptsetup.ps1One-time installation of proxy + credential helper
Routing tableConfigurable in gh-proxy.ps1Maps remote URL patterns → config dirs

Routing Table

The proxy uses a regex routing table to match git remote URLs:

powershell
$script:GH_ROUTING_TABLE = @(
    @{ Pattern = 'tamirdresher_microsoft'; ConfigDir = "$HOME\.config\gh-emu";    Label = 'EMU' }
    @{ Pattern = 'tamirdresher/';          ConfigDir = "$HOME\.config\gh-public"; Label = 'Personal' }
)
$script:GH_DEFAULT_CONFIG = "$HOME\.config\gh-emu"  # Default to EMU (work context)

Token Health Monitor

Proactively check if tokens are valid before they break automation:

powershell
# Check all profiles
Test-GhTokenHealth

# Check specific profile
Test-GhTokenHealth -Profile emu

# Repair expired token (opens browser)
Repair-GhToken -Profile public

Git Credential Integration

After setup, git push/pull also respects GH_CONFIG_DIR:

powershell
git config --global credential.helper '!gh auth git-credential'

Setup

Quick Install

powershell
# From the plugin directory:
.\setup.ps1

# Or manually: dot-source the proxy in your $PROFILE
. "path\to\gh-proxy.ps1"
git config --global credential.helper '!gh auth git-credential'

Prerequisites

  • GitHub CLI (gh) installed and authenticated for both accounts
  • Isolated config dirs already created:
    • ~/.config/gh-emu/ — EMU/work account
    • ~/.config/gh-public/ — personal account
  • If not set up yet, run setup-gh-isolated-auth.ps1 first (from the team scripts)

Verify

powershell
# Token health check
Test-GhTokenHealth

# Should show both profiles healthy:
#   Name    Account                  Healthy Error
#   ----    -------                  ------- -----
#   emu     tamirdresher_microsoft   True
#   public  tamirdresher             True

# Test auto-routing (run from a personal repo)
cd ~/repos/some-personal-repo
gh api user --jq '.login'   # → tamirdresher

# Run from a work repo
cd ~/repos/some-emu-repo
gh api user --jq '.login'   # → tamirdresher_microsoft

Files

FileDescription
SKILL.mdThis skill document (AI reads this to understand the setup)
README.mdHuman-readable overview and install instructions
gh-proxy.ps1Transparent proxy function + token health monitor
setup.ps1One-time setup: installs proxy to $PROFILE, configures git credential helper
manifest.jsonPlugin metadata and version

Integration with Ralph

Ralph needs zero changes. Here's why:

  1. Ralph already sets GH_CONFIG_DIR in Step -1 (ralph-watch.ps1 lines 1086-1098)
  2. The proxy's FIRST check is "Is GH_CONFIG_DIR already set?" — if yes, it delegates immediately without overriding
  3. The proxy is a complete no-op when Ralph is running

Token Expiry Alerting

Add to Ralph's Step -1 for proactive monitoring:

powershell
$health = Test-GhTokenHealth -Profile $(if ($remoteUrl -match 'tamirdresher_microsoft') { 'emu' } else { 'public' })
if (-not $health.Healthy) {
    Write-Host "Token expired for $($health.Name). Manual re-auth needed." -ForegroundColor Red
}

Backward Compatibility

  • ghe / ghp explicit wrappers continue to work (they set GH_CONFIG_DIR, proxy respects it)
  • gh-auto-context.ps1 prompt hook becomes OPTIONAL (proxy handles auto-detection)
  • CMD wrappers (gh-emu.cmd, gh-personal.cmd) unchanged
  • Agents can gradually switch from ghe/ghp to bare gh for in-repo commands

For Squad Agents

You no longer need to use ghe/ghp for in-repo commands. The transparent proxy auto-detects the correct account. Use bare gh freely:

powershell
# These all auto-route correctly based on repo context:
gh pr list
gh issue create --title "Fix bug"
gh api user --jq '.login'

Still use ghe/ghp when:

  • Running commands outside a git repo (e.g., ghe repo list)
  • Explicitly targeting a specific account regardless of repo context

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Github Multi Account」では何ができますか?

Transparent gh proxy that auto-routes commands to the correct GitHub account based on repo context. Uses GH_CONFIG_DIR isolation — no more account-switching chaos.

TypingMindでGithub Multi Accountを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Github Multi Accountはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにGithub Multi Accountをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/tamirdresher/squad-skills/tree/main/plugins/github-multi-accountを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Github Multi Accountを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Github Multi Accountは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもGithub Multi Accountを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Github Multi Account」は無料ですか?

はい。tamirdresherがGitHubでMITライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇