[FEATURE] A way to skip that "Do you want to use this API key?" question on startup

Resolved 💬 4 comments Opened Jan 29, 2026 by simonw Closed Mar 1, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

I'm helping run a class on Claude Code for a relatively non-technical audience. We're using GitHub Codespaces with a pre-configured API key for this, but we have a problem that the first time they start Claude Code it asks them this question:

!Terminal prompt from a CLI application with light background. Text reads: "Detected a custom API key in your environment" (in yellow), "ANTHROPIC_API_KEY: sk-ant-...iRt" followed by obscured characters, "Do you want to use this API key?", "1. Yes", "> 2. No (recommended) ✓" with "recommended" in green and a checkmark, "Enter to confirm · Esc to cancel"

They keep hitting "Yes" because that's "recommended", but that breaks things and causes great confusion, we need them to accept the API key that we've pre-configured for them.

Feature request: a documented way to avoid this. Maybe an environment variable like CLAUDE_CODE_ACCEPT_API_KEY=1 or similar.

Proposed Solution

An environment variable that skips that question, something like:

CLAUDE_CODE_ACCEPT_API_KEY=1

Alternative Solutions

I'm currently trying to work around this by running the following script on Codespaces startup:

if [ -z "${ANTHROPIC_API_KEY:-}" ]; then
  echo "ANTHROPIC_API_KEY is not set"
else
  cat > ~/.claude.json <<CLAUDE_JSON
{
  "hasCompletedOnboarding": true,
  "customApiKeyResponses": {
    "approved": [
      "${ANTHROPIC_API_KEY: -20}"
    ],
    "rejected": []
  }
}
CLAUDE_JSON
fi

It does not feel like a robust and future-proof solution though.

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

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