[BUG] Non-interactive Claude Code (-p) cannot use existing Claude Pro login

Resolved 💬 4 comments Opened Mar 26, 2026 by diogovalada Closed May 19, 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?

Summary

Claude Code interactive mode recognizes my Claude Pro subscription, but non-interactive print mode does not.

In the same machine/environment:

  • claude launches normally and shows me as logged in with Claude Pro
  • claude -p ... fails with Not logged in · Please run /login

This reproduces on both:

  • Windows PowerShell
  • WSL (Ubuntu) Bash

It also happened after removing ANTHROPIC_API_KEY, so this does not appear to be just API-key precedence.

Claude Code version

v2.1.84

Subscription / account mode

  • Claude Pro subscription
  • not using Max
  • interactive Claude Code shows the correct logged-in account and subscription

Environment

Windows

  • Windows host
  • PowerShell

Linux

  • WSL Ubuntu
  • same behavior there

Exact behavior

1. Interactive mode recognizes my subscription

Running:

claude

shows me as logged in, for example:

  • Claude Pro
  • correct account email
  • normal interactive usage works

2. Non-interactive print mode does not

Running:

claude --model sonnet --effort high --allowedTools "Read" --bare -p "hi"

returns:

Not logged in · Please run /login

This happens even though interactive claude in the same environment is already logged in and works.

Additional observations

At first I also had ANTHROPIC_API_KEY set, and then non-interactive usage failed with:

Credit balance is too low

After unsetting ANTHROPIC_API_KEY, the failure changed to:

Not logged in · Please run /login

So:

  • with ANTHROPIC_API_KEY set, Claude Code appears to prefer API billing
  • without it, interactive subscription auth works
  • but non-interactive -p still does not see login state

What Should Happen?

If interactive Claude Code is already logged in via Claude Pro subscription, non-interactive print mode should be able to use the same authenticated subscription state.

This should happen even if the ANTHROPIC_API_KEY env var is set.

Error Messages/Logs

Steps to Reproduce

Windows PowerShell

  1. Ensure ANTHROPIC_API_KEY is unset:
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
  1. Start interactive Claude:
claude
  1. Confirm the UI shows:
  • logged-in account
  • Claude Pro subscription
  1. Exit interactive Claude.
  1. Run:
claude --model sonnet --effort high --allowedTools "Read" --bare -p "hi"
  1. Observe:
Not logged in · Please run /login

WSL Ubuntu

  1. Start interactive Claude:
claude
  1. Confirm it shows:
  • logged-in account
  • Claude Pro subscription
  1. Exit.
  1. Run:
claude --model sonnet --effort high --allowedTools "Read" --bare -p "hi"
  1. Observe:
Not logged in · Please run /login

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.84

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Related:
#1932

View original on GitHub ↗

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