Claude Opus 4 fails to discover environment variables before claiming "I don't have access"

Resolved 💬 3 comments Opened Apr 19, 2026 by clairmont425 Closed Apr 22, 2026

Preflight Checklist

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

What's Wrong?

Working in a session with $CODEMAGIC_API_TOKEN exported in the shell environment, Claude told the user "I can't log into Codemagic from here" and "I don't have a Codemagic API token exposed to me" — without ever running env or echo $CODEMAGIC_API_TOKEN to check. The token was sitting right there in the same shell it had already been running curl commands in.

Beyond missing the env var, Claude also failed to check ~/.claude/hook-approvals.log which contained prior working examples of curl https://api.codemagic.io/builds -H "x-auth-token: $CODEMAGIC_API_TOKEN" from past sessions.

This same session earlier ran a local flutter build appbundle --release instead of reading the codemagic.yaml sitting at the repo root — burning ~25 minutes and filling the user's C: drive. Both failures are the same pattern: asserting a constraint ("I can't verify" / "I need the keystore") without doing the 5-second check that would have disproven it.

Model: claude-opus-4-7. Session: 91d79071-2d64-4032-b7e1-c6bbc29fe43c.

What Should Happen?

when i've selected my project environment the api's that i've linked should be recognizedand linked

Error Messages/Logs

Steps to Reproduce

Body:
Working in a session with $CODEMAGIC_API_TOKEN exported in the shell environment, Claude told the user "I can't log into Codemagic from here" and "I don't have a Codemagic API token exposed to me" — without ever running env or echo $CODEMAGIC_API_TOKEN to check. The token was sitting right there in the same shell it had already been running curl commands in.

Beyond missing the env var, Claude also failed to check ~/.claude/hook-approvals.log which contained prior working examples of curl https://api.codemagic.io/builds -H "x-auth-token: $CODEMAGIC_API_TOKEN" from past sessions.

This same session earlier ran a local flutter build appbundle --release instead of reading the codemagic.yaml sitting at the repo root — burning ~25 minutes and filling the user's C: drive. Both failures are the same pattern: asserting a constraint ("I can't verify" / "I need the keystore") without doing the 5-second check that would have disproven it.

Model: claude-opus-4-7. Session: 91d79071-2d64-4032-b7e1-c6bbc29fe43c.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Model: claude-opus-4-7. Session: 91d79071-2d64-4032-b7e1-c6bbc29fe43c.

Claude Code Version

opus 4.7 claude code

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

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