Repository navigation
feat: let each firstmate home choose its own Claude account - #3
Merged
Merged
Conversation
A claude launch now resolves its login folder (CLAUDE_CONFIG_DIR) from, in order: an explicit per-worker --claude-config-dir, the folder recorded by the task's previous launch on a relaunch or secondmate respawn, the target home's config/claude-config-dir (the secondmate's own home for --secondmate), the launching firstmate's own CLAUDE_CONFIG_DIR, then Claude's default store. Every source is validated as `default` or an existing absolute directory before any endpoint exists, and the resolved value is recorded as claude_config_dir= among the launch-time keys, ahead of the PR identity block, so relaunch and automatic recovery never silently move a worker to another account. fm-control relaunch accepts the same override and checks it before stopping the running agent. The setting is home-local and is not inherited by secondmate homes.
…bin/ script inventory
This was referenced Sep 25, 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.
Summary
Lets each firstmate home choose which Claude account (the
CLAUDE_CONFIG_DIRlogin folder) its Claude agents run on, with a per-worker override, and makes that choice survive every relaunch and automatic recovery.Previously
fm-spawn.shonly forwarded firstmate's ownCLAUDE_CONFIG_DIR, andfm-control.sh relaunchre-ran the launch in the caller's environment, so an automatic restart (bootstrap liveness sweep, stuck-worker recovery) could silently move a worker or secondmate to a different account.What changed
config/claude-config-dir(home-local, gitignored, not inherited by secondmate homes): one absolute folder path, ordefaultfor Claude's own default store.--claude-config-dir <folder|default>onfm-spawn.shorfm-control.sh <id> relaunchconfig/claude-config-dir(the secondmate's own home for--secondmate)CLAUDE_CONFIG_DIRdefaultor an existing absolute directory; otherwise the launch refuses before any endpoint exists.fm-control relaunchchecks an explicit override before stopping the running agent.claude_config_dir=among the launch-time keys (aftermodel=/effort=), is owned by the relaunch rewrite so it is never duplicated, and stays ahead of the terminal PR identity block. Switching a worker off claude drops it.defaultis distinct from naming~/.claude: Claude (2.1.278) keeps a separate.claude.jsoninside any explicitly named folder.bin/fm-claude-account-lib.sh; docs indocs/configuration.md"Claude account", plus pointers inAGENTS.md,docs/agent-control.md, the claude harness reference, andsecondmate-provisioning.Tests
tests/fm-spawn-claude-account.test.sh: precedence,defaultpinning, non-claude launches, batch forwarding, secondmate own-home account, secondmate respawn reuse, and refusals (non-claude override, missing/relative/empty folders from every source, unreadable config, remote secondmate).tests/fm-control-relaunch.test.sh: recorded account reused regardless of caller environment or home setting, explicit move persists through later restarts, override refusals happen before the agent stops, harness switch drops the key, and a regression that a task carryingclaude_config_dir=pluspr=keeps its merge poll armed before and after relaunch.Known environment-only failures on the development host, unrelated to this change and reproduced on the unmodified base:
tests/fm-test-run.test.shneedsruby, and two 2-second trace-timing waits intests/fm-control-relaunch.test.share too short for a slow host (the whole file passes with those waits lengthened).🤖 Generated with Claude Code