AnyAgent

Claude Code

Use Claude Code through AnyAgent: what you can ask for, how it behaves, and the flags underneath.

The claude-code adapter drives the Claude Code CLI in headless mode, detected as the claude binary on PATH; import claudeCode from anyagent/claude-code.

What you can ask for

Nearly every run option works: readOnly, model (Claude Code’s own vocabulary, such as "opus"), effort (closed vocabulary: low, medium, high, xhigh, max), systemPrompt (appended to the CLI’s own, never replacing it), resume, forkSession, mcp, and schema. Only attachments throws, since Claude Code has no headless attachment flag. authStatus() asks claude auth status --json; models() throws, since the CLI has no listing mechanism. The full grid is on the support matrix.

Good to know

  • The session id lands on result.sessionId; pass it back as resume to continue the conversation.
  • mcp means exactly the servers you passed: the end user’s own configured servers stay out of the run.
  • With a schema, result.text is the serialized JSON reply and no other text is emitted; validation and the one retry still apply.
  • usage reports cache reads and writes as separate line items on cacheReadTokens and cacheWriteTokens, and sets costUsd.

Under the hood

Every run executes claude -p --output-format stream-json --verbose --permission-mode bypassPermissions with the prompt piped over stdin. Run options change the mode and append flags:

OptionFlag
readOnly: true--permission-mode manual plus --disallowedTools Bash,Edit,NotebookEdit,Write
model--model <name>
effort--effort <level>
systemPrompt--append-system-prompt <text>
resume--resume <sessionId>
forkSession: true--fork-session, appended beside --resume to branch into a fresh session id
mcp--mcp-config <json> plus --strict-mcp-config
schema--json-schema <json>

On this page