Skip to content

fix(claude-as): --add keeps only the login it asked for, and --tidy repairs the homes retries left - #83

Open
gutyoh wants to merge 1 commit into
mainfrom
fix/claude-as-homes
Open

gutyoh wants to merge 1 commit into
mainfrom
fix/claude-as-homes

Conversation

@gutyoh

@gutyoh gutyoh commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Problem

claude-as --add signed in straight into ~/.claude-<email>. When the browser signed in another account, or the sign-in was left unfinished, that home stayed behind under the wrong name, and each retry created the next one: -2, -3, -4. On guty-arm64-rig the team account ended up in ~/.claude-hermann.g.rosch@tafitech.io-3. The base name and -2 held the personal account (one signed out), and -4 held nothing.

Change

  • --add signs in inside a staging folder and names the home only once the login is that email. A wrong account or an unfinished sign-in leaves nothing behind. A second organization of one email becomes ~/.claude-<email>-<org>, never a number.
  • --tidy [--dry-run]:
    • Archives signed-out and duplicate homes to ~/.local/state/claude-as/removed/. History is kept; credentials are deleted, not revoked.
    • Renames misnamed homes after their login, together with the macOS Keychain item named after the path.
    • Leaves a name without an email (~/.claude-work) alone.
    • Never archives a home a running process holds. Such a home is renamed only when its login is a .credentials.json; running sessions then follow a link at the old path, which a later --tidy drops. A Keychain login cannot be shared that way, so that home waits until its sessions end.
  • Session records follow a renamed or archived home, so -r resumes in the right place.
  • --check names a misnamed or duplicate home and the command that fixes it.

A cross-review from the devbox session found 8 points. All are applied, with one adapted: a home in use is renamed only for a file-based login.

Tests

  • Bats: tests/claude-as.bats now has 102 cases, 31 of them new or rewritten. All pass, including under macOS's stock bash 3.2. The new cases cover the wrong-browser, unfinished and retry paths, every --tidy path, the Keychain (moved via stdin, never on a command line; locked over SSH), ledger retargeting, and a replay of the four homes on guty-arm64-rig.
  • Lint: just lint and just format-check are clean.
  • Unrelated failures: just test also fails two tests (portability.bats "setup.sh --minimal completes under stock macOS bash 3.2" and statusline-forecast.bats "the mod's forecast wins..."). Both fail on main too.
  • Smoke test on guty-arm64-rig (real Claude Code 2.1.322):
    • --tidy archived the signed-out base home and the empty -4, and renamed -3 to ~/.claude-hermann.g.rosch@tafitech.io.
    • Six live sessions kept running through the link.
    • auth status there is signed in as the team account, and --where -r points at the new home.
    • --move --dry-run shows all six sessions already on the account.
    • -2, a duplicate of the personal login, was left alone because herdr and KDE Connect still carry it in their environment.

🤖 Generated with Claude Code

…epairs the homes retries left

--add signed in straight into ~/.claude-<email>. When the browser signed in
another account, or the sign-in was left unfinished, that home stayed behind
under the wrong name, and each retry made the next one: -2, -3, -4. One machine
ended up with its team account in -3, beside two homes holding the personal
account and one holding nothing.

- --add signs in in a staging folder and names the home only once the login is
  that email. Anything else leaves nothing behind. A second organization of one
  email is ~/.claude-<email>-<org>, never a number.
- --tidy [--dry-run] archives signed-out and duplicate homes (history kept,
  credentials deleted, not revoked) and renames misnamed ones after their login,
  with the macOS Keychain item named after the path. A name without an email
  (~/.claude-work) stays. A home a running process holds is never archived; it
  is renamed only when its login is a .credentials.json, and the running
  sessions follow a link at the old path, dropped by a later --tidy.
- Session records follow a renamed or archived home, so -r resumes in the right
  place.
- --check names a misnamed or duplicate home and the command that fixes it.

Tests: 31 new or rewritten bats cases (102 in claude-as.bats, all passing, also
under macOS bash 3.2). Smoke-tested on guty-arm64-rig: the four retries became
~/.claude (personal) and ~/.claude-hermann.g.rosch@tafitech.io (team), with six
live sessions running on through the link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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