skillhawk

Why is Claude Code billing my API key instead of my subscription?

Because an API key is in the environment the agent runs in. Claude Code's documentation says that when ANTHROPIC_API_KEY is set, it is used instead of your Claude Pro, Max, Ultra, Team or Enterprise subscription even if you are logged in; in interactive mode you are asked once, and in non-interactive mode (claude -p) the key is always used when present. Scheduled agents (cron, launchd, scripts that load a .env, CI) usually run non-interactively, so they bill the key per token without asking.

Where the key usually comes from

How to switch a run back to your subscription

A worked example

What skillhawk agents prints for scheduled agents (example data):

 ! cron           claude  */30 * * * * cd ~/repo && claude -p "sweep"  (crontab)
     bills: API key, pay per token (ANTHROPIC_API_KEY)
   launchd        claude  com.me.nightly.plist  (~/Library/LaunchAgents/com.me.nightly.plist)
     bills: subscription token (CLAUDE_CODE_OAUTH_TOKEN)

API keys your shell exports (1)
 ! ~/.zshrc: ANTHROPIC_API_KEY. Agents started from this shell, including `claude -p` in scripts, bill this key per token, even when you are signed in to a subscription.

The Skillhawk command that helps

Read-only; it prints variable names, never their values:

npx skillhawk agents

It reads your crontab, launchd or systemd user jobs, the scripts and .env files they load, this repository's scheduled GitHub workflows and your shell start-up files.

Questions

Does claude -p use my Max subscription?

Only if no API key is present. Claude Code's documentation says that in non-interactive mode (-p) an ANTHROPIC_API_KEY in the environment is always used when present, instead of your subscription.

How do I know which account a run is using?

Run /status in Claude Code, which marks the credential not in use. For scheduled jobs, check the environment they run in; npx skillhawk agents lists each scheduled agent with the credential it will use.

Sources

Skillhawk is a tool in this space, so weigh our framing accordingly. Last updated 2026-11-18.

Related

Try skillhawk review