claude-code - 💡(How to fix) Fix [BUG] macOS Keychain warning on every launch: add-generic-password missing -U flag causes -25299 "item already exists" [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48162Fetched 2026-04-15 06:31:25
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Error Message

Error Messages/Logs

  1. Deleting the entry and re-logging in does not fix it — the error returns on the next launch

Root Cause

▎ On every launch, Claude Code shows a Keychain warning: SecKeychainItemCreateFromContent (<default>): The specified item already exists in the
▎ keychain; add-generic-password: returned -25299. This happens because Claude Code uses security add-generic-password without the -U (update/upsert) ▎ flag, so it fails whenever a Claude Code-credentials entry already exists in the login keychain.

Code Example

macOS Keychain is not writable (security: SecKeychainItemCreateFromContent (<default>): The specified item already exists in the keychain.
  add-generic-password: returned -25299)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

▎ On every launch, Claude Code shows a Keychain warning: SecKeychainItemCreateFromContent (<default>): The specified item already exists in the
▎ keychain; add-generic-password: returned -25299. This happens because Claude Code uses security add-generic-password without the -U (update/upsert) ▎ flag, so it fails whenever a Claude Code-credentials entry already exists in the login keychain.

What Should Happen?

Claude Code should either use security add-generic-password -U to upsert the credential, or check for an existing entry before attempting to write. ▎ No warning should appear on normal startups when valid credentials already exist.

Error Messages/Logs

macOS Keychain is not writable (security: SecKeychainItemCreateFromContent (<default>): The specified item already exists in the keychain.
  add-generic-password: returned -25299)

Steps to Reproduce

Steps to Reproduce

  1. Run claude login to authenticate (this creates a Claude Code-credentials keychain entry)
  2. Launch Claude Code normally
  3. The keychain warning appears on startup because it tries to re-add the credential that already exists
  4. Deleting the entry and re-logging in does not fix it — the error returns on the next launch

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.108

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

No response

extent analysis

TL;DR

Modify the security add-generic-password command to include the -U flag to upsert the credential, allowing Claude Code to update existing entries without raising a warning.

Guidance

  • The error occurs because Claude Code attempts to add a new credential to the keychain without checking if it already exists, resulting in a duplicate entry error.
  • To fix this, the security add-generic-password command should be modified to include the -U flag, which allows the command to update an existing entry instead of attempting to create a new one.
  • Verify the fix by running claude login to authenticate, then launching Claude Code normally and checking for the absence of the keychain warning.
  • Consider adding a check before attempting to write to the keychain to ensure that the credential does not already exist, as an alternative solution.

Example

security add-generic-password -U -s "Claude Code-credentials" -a "username" -w "password" -D "Claude Code credential"

This example demonstrates how to use the -U flag to upsert the credential.

Notes

The provided solution assumes that the security command is being used directly by Claude Code. If the command is being called through a wrapper or another script, the solution may need to be adapted accordingly.

Recommendation

Apply the workaround by modifying the security add-generic-password command to include the -U flag, as this is a straightforward fix that addresses the root cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING