Skip to content

About

Per-command GitHub CLI account routing for concurrent personal, work, and agent sessions.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

gh-context logo

gh-context

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.

Get started

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 init

2. 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 wrap

Put ~/.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.

Everyday use

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 explicitly

Selection 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.

More

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.

About

Per-command GitHub CLI account routing for concurrent personal, work, and agent sessions.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages