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 asresumeto continue the conversation. mcpmeans exactly the servers you passed: the end user’s own configured servers stay out of the run.- With a
schema,result.textis the serialized JSON reply and no other text is emitted; validation and the one retry still apply. usagereports cache reads and writes as separate line items oncacheReadTokensandcacheWriteTokens, and setscostUsd.
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:
| Option | Flag |
|---|---|
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> |