I made a script that calls Claude Code in non-interactive mode once for each endpoint in my codebase, with instructions to perform a security review on the endpoint it is given. I thought it would be able to authenticate with Anthropic via the OAuth token it presumably put on my device when I previously authenticated in interactive mode. But it turns out this is not the case . My script run costed over $300 when authenticated with an API key. When I opened the interactive Claude Code and ran the script in the included bash terminal (or, to skirt the default 2 minute timeout, asked Claude to run the script in the background), all calls to Anthropic were authenticated with my subscription account (and, unsurprisingly, quickly ate up my usage limit). As far as I can tell, this is not documented anywhere. It makes sense that this works - I believe tasks work the same way. This seems like a neat and useful feature.