Unable to use API key for non-interactive automation in Claude Code 2.0.37+ (regression from 2.0.30)

Resolved 💬 3 comments Opened Nov 14, 2025 by rjwalters Closed Jan 15, 2026

Description

I'm building an automated testing system that needs to run Claude Code non-interactively in Docker containers. I've discovered that Claude Code 2.0.30 works with the .claude.json workaround from issue #441, but versions 2.0.37 and later fail to use this configuration and still prompt for OAuth browser authentication.

Versions Tested

  • 2.0.30: ✅ Works with .claude.json workaround
  • 2.0.37: ❌ Ignores .claude.json, prompts for OAuth
  • 2.0.41: ❌ Ignores .claude.json, prompts for OAuth

Current Workaround (2.0.30 only)

Following the workaround from #441, I create ~/.claude.json:

{
  "changelogLastFetched": 1000000000000,
  "primaryApiKey": "$ANTHROPIC_API_KEY",
  "hasCompletedOnboarding": true,
  "lastOnboardingVersion": "2.0.30"
}

This works perfectly in 2.0.30 - Claude Code starts without prompting and uses the API key directly.

Problem in 2.0.37+

In versions 2.0.37 and later, the same .claude.json file is ignored. Instead, Claude Code:

  1. Detects the ANTHROPIC_API_KEY environment variable
  2. Shows a yellow box with the masked key
  3. Prompts "Do you want to use this API key?" with Yes/No options
  4. Requires interactive terminal input to proceed

For non-interactive automation (Docker containers, CI/CD, testing), this makes 2.0.37+ unusable.

Attempted Solutions

I've tried:

  • .claude.json with primaryApiKey (works in 2.0.30, ignored in 2.0.37+)
  • .claude/settings.json with apiKeyHelper: "disabled" (doesn't work)
  • .config/claude-code/settings.json with apiKeyHelper: "disabled" (doesn't work)
  • --dangerously-skip-permissions flag (only skips tool permissions, not auth)

Expected Behavior

When .claude.json contains a valid primaryApiKey, Claude Code should:

  1. Use that key without prompting
  2. Not show the API key confirmation dialog
  3. Allow completely non-interactive operation

This worked in 2.0.30 and appears to be a regression in 2.0.37+.

Request

Could you either:

  1. Restore the 2.0.30 behavior where .claude.json bypasses the API key prompt, or
  2. Provide an official method for non-interactive API key configuration

For automated testing and CI/CD use cases, it's critical to be able to configure authentication without interactive prompts.

Environment

  • Docker containers (Ubuntu 24.04 Noble)
  • Non-interactive terminal
  • API key provided via environment variable
  • Configuration files created before Claude Code starts

Thank you for considering this issue!

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗