The right GitHub account, for every command.
Use personal and work accounts in different terminals, projects, or coding agents
at the same time. gh-context chooses credentials for each command without changing
the globally active account.
Requires Python 3.11+, Git, and GitHub CLI on macOS or Linux.
1. Install with uv and create your config:
uv tool install git+https://github.com/filipbodor/gh-context.git
gh-context init2. Configure ~/.config/gh-context/config.json with your account names and rules:
{
"profiles": {
"personal": {"host": "github.com", "account": "your-personal-login"},
"work": {"host": "github.com", "account": "your-work-login"}
},
"defaults": {"github.com": "personal"},
"owners": {"github.com/example-company": "work"},
"directories": {"~/Developer/work": "work"}
}Log in to each account with gh auth login if needed. Your config contains names
and rules; tokens stay in GitHub CLI's credential store.
3. Keep using gh by installing the optional wrapper:
gh-context wrapPut ~/.local/bin before native gh in your PATH. Existing shells may need
rehash (zsh) or hash -r (bash). Without the wrapper, use gh-context instead of gh.
gh pr list # Use the current project's account
gh pr list --repo example-company/app # Use the target repository's account
gh context # See which account was selected
gh context --check # Verify identity and repository access
GH_CONTEXT=work gh pr list # Select a profile explicitlySelection uses your repository, Git configuration, directory rules, and host defaults.
Each command is independent, so concurrent sessions can use different accounts.
gh auth status still shows native gh's global account; use gh context for routing.
- Configuration, routing rules, and enterprise hosts
- Optional skill for coding agents
- Development and tests
To uninstall, run gh-context unwrap, then uv tool uninstall gh-context.
Your configuration and stored credentials are preserved.
MIT licensed. Independent of GitHub; works with or without AI agents.
