#16144

Key a Claude account by user and organization

Openmikjkdwants to merge intofrom

omarchy agent account add claude keyed a subscription by oauthAccount.accountUuid, which names the user, not the subscription. One claude.ai user in two organizations therefore looked like a duplicate: the second login was discarded, while both organizations would also have shared one limits cache and one entry in an account copy.

This makes the organization part of the identity:

  • identity() records organizationUuid as orgId; same_account() compares the user and organization, falling back to the user alone only for a registry entry written before orgId existed.
  • register() and recovery use that comparison, so a second organization is added while the same organization is still refused.
  • The limits cache key includes the organization. An account copy exports the organization, validates it, and reads it from the Claude account file for an export written before this change; a bundle whose top-level and embedded organization disagree is refused before anything is written.

Compatibility: an existing registry needs no migration. A home that now names an organization starts a new limits cache file, so it probes once after the upgrade instead of reusing the old per-user file. Copying two organizations to a machine still running an older Omarchy fails in that older receiver; update the destination first.

Verified in an Ubuntu 24.04 container with bash 5, jq, python3 and node: 81 assertions pass across test/shell.d/agent-account-test.sh, agent-account-copy-test.sh, agent-usage-accounts-test.sh and agent-usage-claude-limits-test.sh, with no failures. The new assertions include:

ok - a second Claude organization is a separate account
ok - two Claude organizations survive a copy
ok - Claude organizations keep separate limits caches

The full ./test/all was not run. ./test/cli stops at "theme template mix helper works" on untouched quattro in the same container, where fc-list is unavailable, and agent-usage-codex-scanner-test.sh fails at "--force reuses per-file records" on untouched quattro too; both are pre-existing in this environment, not from this change.

Written by an AI coding agent (pi) under human direction; the human author reviewed the diff and the test results.

Fixes #15981

Activity

5
greptile-apps[bot]12h ago

Confidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous account-copy issue is fixed.

Summary

Claude accounts now use both the user and organization to distinguish subscriptions.

  • Claude accounts can belong to different organizations for the same user.
  • Claude account copies keep each organization's subscription separate.
  • Claude usage caches are kept separate for each organization.

Review checks were based on code inspection; no tests were run during this review.

Reviews (2) · Last reviewed commit: "Keep account copies working with older r..." · Reviewed by Greptile

greptile-apps[bot]reviewed12h ago
mikjkdreviewed12h ago