Skip to content

feat(claude-accounts): choose the Claude account per project - #2

Draft
frattezi wants to merge 2 commits into
feat/claude-account-per-automationfrom
feat/claude-account-per-project
Draft

frattezi wants to merge 2 commits into
feat/claude-account-per-automationfrom
feat/claude-account-per-project

Conversation

@frattezi

@frattezi frattezi commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​341 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​340
Prod 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​329 $\color{#cf222e}{\Huge{\mathbf{−}}}$​27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​302

Review draft on my fork, stacked on #1 (Claude account per automation and per new tab). Base is PR 1's branch, so this diff is only the per-project change. Before opening upstream: attach screenshots and rebase onto current main after PR 1.

Relationship to stablyai#23228. stablyai#23228 solves the same problem with a larger design: "Ask every time", a first-launch prompt, and it's built on stablyai#22691. This PR is a deliberately smaller alternative: one optional repo field and one settings row, about 25 files on top of PR 1. If maintainers prefer stablyai#23228's scope, I'm happy to close this or help land that one instead. The goal is to get per-project accounts into Orca.

ELI5

If you use one Claude account for work and another for personal projects, you have to remember to switch accounts in Settings before working in each project. Switching moves every project at once.

With this PR, a project can remember its Claude account. Work repos always start Claude on the work account and personal repos on the personal one, side by side, whatever is selected in Settings. That includes claude you type yourself in that project's terminals.

What Changed

Before: every Claude session in every project uses the account selected in Settings.

After, for the user:

  • Settings → Repository → Claude Account (next to GitHub Account): Selected account (the default, today's behaviour) or any signed-in account on this computer. The row is hidden for projects on a remote host. CLI: orca repo set --claude-account <id>, where --claude-account= clears it.
  • Claude started by Orca in that project (new tab, workspace startup, automations that don't pin their own account) runs on the project's account. So does claude typed by hand in the project's terminals.
  • Precedence: a launch's own pinned account (from PR 1) wins over the project's account, which wins over the selection.
  • Fails open, on purpose: if the project's account is removed or signed out, the project's terminals follow the selection again, so shells always open. The settings row says Removed account. This differs from a pin in PR 1, which fails closed, because a project default is a preference while a pin is an explicit choice for one run.
  • Switching accounts in Settings leaves the project's sessions where they are.

Mechanism:

  • Saved data. Repo.claudeAccountId is a new optional field. It's sanitized and trimmed on write; null or blank clears it.
  • Spawn preflight. It reads the worktree's project account (projectClaudeAccountIdForWorktree) and, if no pin is present, resolves it through the same per-account folder routing PR 1 uses for pins. This also applies to plain shells, so a typed claude follows it.
  • Re-attached panes after a restart are left as they were. Only a newly started terminal is routed.
  • Folder workspaces (not git worktrees) have no project repo, so they follow the selection. WSL projects follow the selection too, for the same reason as PR 1.

Why

The account usually belongs to the project: a client repo bills the client's account. Making it a project setting means you choose once, with no prompts and no global switch.

Alternatives considered:

Linked Issue

Fixes stablyai#5203

Visual Proof

  • Settings → Repository: before / after (Claude Account row)
  • Removed-account state of the row

Testing

  • I manually tested these changes locally
  • Automated tests added/updated
  • Every added test fails without this change (checked by reverting each fix) and avoids the test anti-patterns

Platforms actually exercised: macOS (local). Not run on Windows or Linux.

Automated:

  • A Claude launch in the project uses its account while another one is selected.
  • A pinned launch wins over the project account.
  • A removed account, a WSL pane, or no router falls back to the selection; so does a signed-out account, and shells still open.
  • A plain shell is routed, so a typed claude uses the project account. A re-attached pane is left as it was.
  • Repo persistence: persist, clear with null or blank, and survive a reload. Also the CLI repo set --claude-account.
  • The settings row is absent for remote projects and makes no account fetch for them. Removed-account state.
  • The account switch leaves panes of a bound project alone.

Commands: pnpm tc ✅ · targeted pnpm test (claude-accounts, repository settings, automation field, account switch, PTY preflight: 75 files) ✅ · broad scoped run and check:code-quality:changed: pending re-run. src/cli/account-add-process.test.ts fails on unmodified main too; this PR doesn't touch it.

Risk

Level: Medium

  • Riskiest part: every local terminal spawn in a project with an account set now gets that account's routing. A project with no account set takes exactly the old path.
  • Saved data: one optional repo field. Old repos don't have it.
  • Remote projects: not affected (the row is hidden). The field is only read on this computer's spawn path.
  • Backing out: a plain revert. A stored claudeAccountId on repos is ignored by builds without this change.

AI Disclosure

Written with Claude Opus 5.5 through Claude Code, directed and reviewed by me.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Checked for: security (the account id is matched against known accounts before it reaches a path), cross-platform, Remote SSH (hidden, never read remotely), mobile (doesn't write the field), backwards compatibility, and performance (no extra await on spawns without an account).

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

frattezi and others added 2 commits November 10, 2026 12:17
A project can set the Claude account every terminal opened in it uses, so
`claude` started by Orca or typed by hand there runs on that account whatever
is selected in Settings. A pinned launch still wins over the project's
account, which wins over the selection. A removed or signed-out project
account falls back to the selection so the project's shells still open, and
an account switch leaves the project's sessions where they are. Set it in
Settings > Repository > Claude Account or with
`orca repo set --claude-account`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…panes

A typed `claude` in a project's new terminals follows the project's account
again: only a pin from a launch's env waits for a Claude launch, while the
project account applies to every fresh spawn and skips re-adopted panes. The
repository settings row reads accounts only for projects on this computer.

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