Repository navigation
Org-aware account identity, removal, and rotation priority (#6, #7) - #28
Merged
Merged
Conversation
One Anthropic account (email/accountUuid) can hold multiple subscriptions across different organizations — e.g. a corporate Pro org and a personal Max org. The old identity model keyed only on accountUuid (with name as fallback), so adding the second org overwrote the first (#6) and --name couldn't help because the UUID check won (#7). Identity is now (accountUuid + organization). Re-implemented and reviewed against master rather than cherry-picking the closed fork PRs (#15/#17). - src/identity.js (new): orgKey / sameIdentity / matchAccounts / emailOf, the single source of truth for identity and lookups. sameIdentity treats an unknown org on either side as a match so a freshly-profiled login backfills a legacy entry instead of duplicating it. - fetchProfile: extract organization.uuid; accounts persist orgUuid/orgName. - All dedup/sync/find match sites switched to sameIdentity; syncAccountsFromDisk uses a greedy 1:1 claim so multiple same-person/different-org entries pair correctly. accounts command dedups by (accountUuid, org) and backfills org. - Name disambiguation: one org -> "email"; multiple -> "email (Org)", renaming the existing collider too. Names stay unique (they are the user-facing key). - Org-aware remove + api: resolve by name or email, --org <name|uuid> to disambiguate; lists candidates when ambiguous. - Per-account rotation priority: `priority` field (lower = preferred, default 0) as the primary sort key in _selectNext with the existing weekly heuristic as tiebreaker; new `teamclaude priority` command (--first/--last); session-reset switching won't demote to a worse priority. - Tests: identity/matchAccounts/emailOf and priority rotation (22 passing). - Docs: README, config.example.json, help text. Out of scope (future PRs from the #18 stack): #14 headless/reload API/prober, #16 usage-endpoint quota. #13 (429 account-failover) intentionally not taken — the throttle is IP-based, so the merged #25 back-off is the correct behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MagicalTux
added a commit
that referenced
this pull request
Jun 18, 2026
The `priority` field (added in #28) was only consulted when a switch was forced (current account exhausted/throttled). A healthy lower-priority current account was never preempted, so a recovered preferred account wouldn't be resumed until the in-use one ran low. getActiveAccount now switches to a strictly higher-priority (lower value) available account even from a healthy current one, while staying sticky within the same priority tier. The common case — all accounts at the default priority 0 — is unchanged and never thrashes, since no account is strictly higher than another. Exhaustion-switching and the soonest-weekly-reset heuristic are intact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6, closes #7.
Problem
One Anthropic account (same email /
accountUuid) can hold multiple subscriptions across different organizations — e.g. a corporate Pro org and a personal Max org. Identity was keyed only onaccountUuid(withnameas fallback), so connecting the second org overwrote the first (#6), and--namedidn't help because the UUID check won (#7).Approach
Identity is now
accountUuid+ organization. This was re-implemented and reviewed line-by-line againstmasterrather than cherry-picked from the closed fork PRs (#15/#17) — per maintainer policy, and because the repo has already been targeted by a malicious soft-fork (#9), external diffs are treated as untrusted.Changes
src/identity.js(new) —orgKey/sameIdentity/matchAccounts/emailOf.sameIdentitytreats an unknown org on either side as a match, so a freshly-profiled login backfills a legacy entry instead of duplicating it; once both orgs are known, a different org is a distinct account.fetchProfileextractsorganization.uuid; accounts persistorgUuid/orgName.sameIdentity.syncAccountsFromDiskuses a greedy 1:1 claim so multiple same-person/different-org entries pair correctly instead of all matching the first. Theaccountscommand dedups by(accountUuid, org)and backfills org identity from the profile.email; multiple →email (Org), renaming the existing collider too. Names stay unique because they're the user-facing key forremove/api/selection.remove+api— resolve by name or email;--org <name|uuid>disambiguates; ambiguous queries list the candidates.priorityfield (lower = preferred, default0) is the primary sort key in_selectNext, with the existing weekly-reset heuristic as the tiebreaker (default0everywhere ⇒ unchanged behavior). Newteamclaude priority <name> <n>command (--first/--last). Session-reset switching won't demote to a worse priority.Tests
npm test— 22 passing. Newtest/identity.test.js(sameIdentity incl. legacy-backfill + two-orgs migration; matchAccounts/email/--org routing) andtest/rotation-priority.test.js(priority ordering, tiebreak, default-0 parity). Lint clean (one pre-existing unrelated warning).Backward compatibility
Existing single-account configs (no
orgUuid) run unchanged; an entry is backfilled with its org after oneaccounts/profile fetch.Out of scope (future PRs, from the #18 stack)
🤖 Generated with Claude Code