What changed: magpie read and wrote Claude Code's own sign-in under the
service "Claude Code-credentials" whatever CLAUDE_CONFIG_DIR said. Claude
Code 2.1.296 names its item "Claude Code-credentials-<sha256(dir)[:8]>"
when CLAUDE_CONFIG_DIR is set (j$ in its secure storage: the suffix is
dropped only when CLAUDE_CONFIG_DIR is unset), which is what
claudeDirService already computes for saved accounts' directories. Now
claudeHomeService gives that name for the read (both the account's item
and by service alone) and for saveClaudeCredential.
Why now: the previous commit asks the account's item before the file, so
with CLAUDE_CONFIG_DIR set the plain "Claude Code-credentials" item — the
default directory's sign-in, maybe another account — would have beaten the
.credentials.json in CLAUDE_CONFIG_DIR. It was already wrong before that
commit (a sign-in was written to an item Claude Code under that directory
never reads), only less visible.
Run (tip of both commits, sandbox HOME, fake `security` on PATH, private
GOCACHE): TestClaudeConfigDirKeychainItem fails with claudeHomeService
ignoring CLAUDE_CONFIG_DIR (it read "home-item") and passes with it.
gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows pass; go test -count=1 ./internal/provider ok (116s);
go test -race -count=5 on the keychain tests ok.
Not run: no real Keychain, no real Claude Code run under CLAUDE_CONFIG_DIR
(the name rule is read from the 2.1.296 binary), no other package's tests
(only internal/provider changed).