Skip to content

Root cause analysis: Keychain prompts caused by Claude Code CLI resetting partition_id on every token refresh #367

@fjh658

Description

@fjh658

Root cause: Claude Code CLI refreshes OAuth tokens via security add-generic-password -U, which internally does delete + re-add. This resets the Keychain item's partition_id to apple-tool: only, wiping any teamid: granted by "Always Allow". The prompt reappears every time the token is refreshed (multiple times per day).

Verification:

security dump-keychain -a 2>&1 | grep -A 40 "Claude Code-credentials" | grep "description"

Before: description: apple-tool:,teamid:Y5PE65HELJ
After:  description: apple-tool:

Fix: Read the keychain item via /usr/bin/security find-generic-password -s "Claude Code-credentials" -w (subprocess) instead of SecItemCopyMatching. The calling process is /usr/bin/security which matches apple-tool: — no prompt, regardless of partition_id resets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions