Copilot Account Switcher
Switch between GitHub accounts for GitHub Copilot directly from VS Code — no browser, no settings JSON.

Features
|
|
| Status bar indicator |
Shows @username (your preferred Copilot account) at a glance. Blue when set, orange when no preference is saved. |
| Quick account switcher |
Command Palette or status bar click → QuickPick listing all connected GitHub accounts. The preferred account is marked with ✓. |
| Full preference write |
Targets every installed Copilot extension (GitHub.copilot, GitHub.copilot-chat, …) via VS Code's built-in account preference UI. |
| Session pre-warming |
Ensures the target account has valid sessions across all scope sets Copilot probes — prevents silent fall-back to the previous account. |
| Add a new account |
Triggers the GitHub OAuth flow without leaving VS Code. |
| Per-workspace preference |
The chosen account is remembered per workspace and reflected in the status bar on next open. |
| Accounts panel |
Webview listing all connected accounts with their GitHub avatars. |
| Live refresh |
Status bar updates automatically when GitHub sessions change. |
Quick Start
- Install the extension.
- Click
$(github) @username in the status bar (bottom-right), or open the Command Palette and run Copilot: Switch GitHub Account.
- Pick the account you want Copilot to use from the QuickPick.
- The "Manage Extension Account Preferences" picker opens — click the same account there (this is the VS Code step that actually writes the preference).
- Click Reload window when prompted.
Done — Copilot now uses the selected account.
Commands
| Command |
Description |
Copilot: Switch GitHub Account |
Open the account switcher QuickPick |
Copilot: Add GitHub Account |
Sign in with a new GitHub account |
Copilot: Show Active Account |
Show the preferred account for this workspace |
Copilot: Refresh Account List |
Force-refresh the status bar |
Copilot: Manage Account Preferences |
Open VS Code's native account preferences UI |
Copilot: Show Accounts Panel |
Open the Webview panel with avatars |
Configuration
| Setting |
Default |
Description |
copilotSwitcher.autoSwitchPerWorkspace |
false |
Show a prompt on startup when the workspace preference doesn't match the current Copilot account. |
// .vscode/settings.json
{
"copilotSwitcher.autoSwitchPerWorkspace": true
}
How It Works
VS Code 1.85+ supports multiple simultaneous GitHub accounts. This extension uses the vscode.authentication API to:
- List all connected accounts via
vscode.authentication.getAccounts('github').
- Pre-warm the chosen account's sessions across every scope set Copilot probes (canonical Copilot scopes, empty-scope,
read:user) — so VS Code's resolver never falls back to the old account.
- Persist the account ID in
workspaceState for status-bar display and per-workspace memory.
- Open the preference picker via the targeted internal command
_manageAccountPreferencesForExtension for each installed GitHub.copilot* extension. One click writes the preference; a window reload applies it immediately.
Why is one click in the VS Code picker required?
VS Code intentionally provides no public API to programmatically write another extension's account preference — it would let any extension hijack credentials. The _manageAccountPreferencesForExtension command is the closest supported path; it pre-fills the extension and provider so the user only needs a single click.
Reload behaviour
A Reload window prompt is shown after the preference is written. Copilot picks up the change on its next token request even without a reload, but reloading guarantees immediate effect.
Manual alternative
If the automatic picker doesn't open:
- Command Palette → Accounts: Manage Extension Account Preferences
- Select GitHub Copilot
- Choose the desired GitHub account
- Repeat for GitHub Copilot Chat if installed
- Run Developer: Reload Window
Known Limitations
- One click in the VS Code picker is unavoidable. The preference write must originate from VS Code's own UI — extension code cannot bypass this by design.
copilot OAuth scope may not be available on all GitHub account tiers (e.g. some enterprise configurations). The extension handles this gracefully.
- Session persistence is managed by VS Code's GitHub auth provider. Signing out of a GitHub account in VS Code will clear its sessions; the status bar automatically switches to the inactive (orange) state.
Development
Prerequisites
- Node.js ≥ 18
- VS Code ≥ 1.85
Setup
npm install
npm run build:dev # bundle with source maps
npm run build:watch # watch mode
Run
Press F5 in VS Code to launch the Extension Development Host.
Type check
npm run compile
Test
npm test
Lint
npm run lint
Publishing
# Install the VS Code extension CLI (once)
npm install -g @vscode/vsce
# Generate the icon (if resources/icon.png is still the placeholder)
node generate-icon.js
# Dry-run — inspect what goes into the .vsix
vsce package --dry-run
# Package
vsce package
# → copilot-account-switcher-0.1.0.vsix
# Log in (first time — requires a Marketplace PAT with Marketplace > Manage scope)
vsce login talscr
# Publish
vsce publish
# Or bump patch version and publish in one step
vsce publish patch
License
MIT