Feature request: Allow nested/recursive CLI calls for testing LLM applications

Resolved 💬 2 comments Opened Jan 18, 2026 by iduartgomez Closed Jan 18, 2026

Use Case

When developing LLM-powered applications inside Claude Code, those applications often need to call Claude themselves (via CLI or API). Currently, if the application uses claude --print as its LLM provider, nested calls hang/return empty.

Example scenario:

  1. User is working in Claude Code on a research project
  2. The project has a ClaudeCodeProvider class that uses claude --print to make LLM calls
  3. User wants to test the project by running experiments
  4. Experiments fail because nested claude CLI calls don't work

Current Behavior

When running inside Claude Code (CLAUDECODE=1), calls to claude --print hang indefinitely and return empty. This happens even with:

  • --session-id <new-uuid> (fresh session)
  • --no-session-persistence
  • Clearing all CLAUDE* environment variables
  • Combinations of the above

Proposed Solution

Add an option to explicitly allow nested calls, such as:

claude --print --allow-nested "prompt here"

Or alternatively, make --no-session-persistence + --session-id work for isolated one-shot calls that don't interfere with the parent session.

Workaround

We implemented a fallback to use the direct Anthropic API when CLAUDECODE=1 is detected and ANTHROPIC_API_KEY is available. This works but:

  • Requires an API key (defeats purpose of CLI-based workflow)
  • Adds complexity to handle both paths
  • Different behavior between development and production

Environment

  • Claude Code version: 2.1.11 (VSCode extension)
  • macOS Darwin 24.6.0
  • Tested from both terminal and VSCode integrated terminal

View original on GitHub ↗

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