Skip to content

feat(account): resolve account from CSHIP_ACCOUNT env var - #201

Open
nh13 wants to merge 1 commit into
stephenleo:mainfrom
nh13:nh13/feat-account-env-var
Open

feat(account): resolve account from CSHIP_ACCOUNT env var#201
nh13 wants to merge 1 commit into
stephenleo:mainfrom
nh13:nh13/feat-account-env-var

Conversation

@nh13

@nh13 nh13 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Problem

cship.account resolves the authenticated Anthropic account from the OAuth profile endpoint using the token read from the OS keychain / credentials file — whatever the last interactive claude login wrote.

A launcher that runs Claude Code under multiple accounts by injecting a per-session token via CLAUDE_CODE_OAUTH_TOKEN breaks this: Claude Code strips that variable before spawning the statusline command, so cship can't see it and falls back to the keychain token — reporting the wrong account (and wrong plan tier) for any session not launched under the default login.

Change

Add a higher-priority account source: the CSHIP_ACCOUNT environment variable. Its value is compact JSON matching the account profile shape (organization_name, organization_tier, organization_type, account_display_name — all optional, non-secret; never a token). When set, the account module renders it directly and skips the keychain/OAuth path; when absent or malformed it falls back to the existing behavior, so a plain claude is unchanged.

This is a small, tool-agnostic contract: any launcher that has resolved the session's account (it holds the token at launch, where the statusline never does) can hand it to the statusline this way.

Testing

  • New unit tests for the CSHIP_ACCOUNT parse: valid JSON, empty, and malformed.
  • cargo fmt, cargo clippy --all-targets, and the full test suite pass.

The account module resolves the authenticated Anthropic account from the
OAuth profile endpoint using the macOS keychain / credentials-file token.
Under a multi-account launcher that injects a per-session OAuth token, that
token is stripped from the statusline subprocess, so the keychain path
reports the last interactive login — the wrong account.

Add a higher-priority source: the CSHIP_ACCOUNT environment variable, a
compact JSON payload matching the account profile shape. A launcher that has
resolved the session's account can pass it here and the module renders it
directly, falling back to the keychain/OAuth path when the variable is absent
or malformed. Non-secret identity only; never a token.
@nh13
nh13 force-pushed the nh13/feat-account-env-var branch from 714d271 to aac3620 Compare August 25, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant