Skip to main content

Claude Code CLI Provider

Use your Anthropic Max subscription to power Wunderland agents — no API key needed. The claude-code-cli provider invokes your locally-installed Claude Code CLI as a subprocess.

Officially Supported

Anthropic explicitly supports programmatic use of Claude Code via the -p flag. Their headless mode documentation provides examples for scripted calls, CI/CD pipelines, and automation. This is the intended use case.

Prerequisites​

  1. Claude Code CLI installed on your machine
  2. Anthropic account logged in (Free, Pro, or Max plan)

Install Claude Code​

npm install -g @anthropic-ai/claude-code

Or download from claude.ai/download.

Log in​

claude

Follow the browser-based login flow. Once authenticated, Claude Code caches your credentials locally.

Setup with Wunderland​

Interactive login​

wunderland login

Select "Claude Code CLI (Max subscription)" from the menu. Wunderland will verify your installation and authentication automatically:

  Claude Code CLI Provider
────────────────────────
✓ CLI installed /usr/local/bin/claude (v1.5.0)
✓ Authenticated
✓ Model available claude-sonnet-4-20250514

Ready to use! No API key needed.

Direct provider flag​

wunderland login --provider claude-code-cli

Manual config​

~/.wunderland/config.json
{
"llmProvider": "claude-code-cli",
"llmModel": "claude-sonnet-4-20250514"
}

Or per-agent:

agent.config.json
{
"llmProvider": "claude-code-cli",
"llmModel": "claude-opus-4-20250514"
}

Available Models​

ModelBest ForContextOutput Limit
claude-sonnet-4-20250514 (default)Most tasks — balanced speed and quality200K16K
claude-opus-4-20250514Complex reasoning, deep analysis200K32K
claude-haiku-4-5-20251001Fast, lightweight tasks200K8K

All models are $0 per token — your subscription handles billing.

Override the model:

wunderland chat --provider claude-code-cli --model claude-opus-4-20250514

Or via environment variable:

export CLAUDE_CODE_MODEL=claude-opus-4-20250514

How It Works​

  1. Wunderland spawns claude --bare -p --output-format json as a subprocess
  2. Your conversation is piped via stdin
  3. Claude Code uses your local authentication (no tokens leave your machine)
  4. The JSON response is parsed back into AgentOS's standard format

The --bare flag strips Claude Code's own plugins, hooks, and MCP servers for clean, reproducible output. --max-turns 1 ensures a single completion per call (no agentic tool loops).

Tool Calling​

When Wunderland needs the model to call tools, it uses Claude Code's --json-schema flag to enforce structured output. The model responds with either text or a structured tool call array. This gives reliable tool calling without any custom parsing.

Troubleshooting​

"Claude Code CLI is not installed"​

npm install -g @anthropic-ai/claude-code
# or
brew install claude-code # macOS

"Not authenticated"​

claude  # opens browser login flow

"Timed out"​

Claude Code didn't respond within 2 minutes. Try:

  • Using a faster model: claude-haiku-4-5-20251001
  • Checking your internet connection
  • Running claude --bare -p "test" manually to diagnose

"Rate limited"​

Your Max plan's usage limits have been reached. Wait a few minutes and try again. Limits assume ordinary individual usage — running large automated pipelines may trigger enforcement.

vs. Anthropic API Key Provider​

Featureclaude-code-clianthropic
AuthClaude Code login (subscription)ANTHROPIC_API_KEY (Console)
Cost$0 per token (subscription)Pay-per-token
SetupInstall CLI + loginGet API key from Console
Rate limitsSubscription limitsAPI rate limits
Best forPersonal use, developmentProduction, high-volume

Use claude-code-cli for personal development and experimentation. Use anthropic for production deployments where you need predictable billing and higher rate limits.