Reference · Tools
Claude Code Execution
Execute code in a sandboxed environment via Claude code execution tool.
The Claude Code Execution node sends a task to the Anthropic Messages API with the code_execution tool enabled, causing Claude to write and run Python code in an isolated sandbox. It returns both the generated code and its output, making it useful for things like on-the-fly data analysis or algorithmic processing that static nodes can't handle. Any files written during execution are attached to the output item as binary data for downstream nodes to use directly.
- Node type
- Action (binary)
- Parameters
- 6
- Outputs
- Output, Error
- Credentials
- Anthropic
Claude Code Execution
Execute code in a sandboxed environment via Claude code execution tool.
Overview
The Claude Code Execution tool sends a user message to the Anthropic Messages API with the code_execution tool enabled, allowing Claude to write and execute Python code in a sandboxed environment. The model can perform calculations, data analysis, string manipulation, and algorithmic tasks, returning both the code it wrote and the execution output. Any files the model writes during the run are downloaded and attached to the output item as binary data, so downstream nodes can use the bytes directly.
Category: AI
Tool Name: claude_code_execution
Version: 1
Appearance: Icon: anthropic | Color: #d4a574
Node Type
Action (Binary) — handles file/binary data operations
Input / Output
| Direction | Port(s) |
|---|---|
| Input | Input |
| Output | Output, Error |
Credentials
This tool requires Anthropic credentials. See the Credentials Guide for setup instructions.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| Model | options | Yes | Claude Sonnet | The Claude model to use for code execution. Always uses the latest version (auto-updated). |
| Options: Claude Opus (most capable — complex analysis, coding and multi-step reasoning), Claude Sonnet (balanced — strong quality at lower cost and latency), Claude Haiku (fastest — simple tasks and high-volume work). Each option tracks the current release of its tier, so the underlying model ID updates without any change to your node. | ||||
| System Prompt | string | No | — | Optional system-level instructions for the model. Guides how the model approaches code execution tasks. Supports expressions. |
| User Message | string | Yes | — | The user message or prompt to send. The model will write and execute Python code to fulfill this request. Supports expressions like {{ $json.task }}. |
| Options | collection | No | {} | Advanced generation and output settings. |
| — Max Tokens | number | No | 16384 | Maximum number of tokens in the response. Code execution responses can be lengthy. |
| — Temperature | number | No | 1 | Sampling temperature (0-1). Lower values make output more deterministic. |
| — Response Field Name | string | No | response | Name of the JSON field to store the model text response in. |
| — Include Code | boolean | No | true | Whether to include the executed code and language in the output JSON. |
| Include Input | boolean | No | false | Whether to include the original input item JSON fields in the output. |
| Max Concurrency | number | No | 5 | Maximum number of items to process concurrently. Keep low to respect Anthropic rate limits. |
Output Data
One API call per input item, and one output item per input item. The model’s narrative text lands on the field named by Response Field Name (response by default). A single run may execute code several times, so the code blocks and their results are returned as arrays. Binary data on the input item is forwarded unchanged, and any files the sandbox produced are added to it.
{
"response": "The model's narrative explanation of what it did",
"codeBlocks": [ { "code": "print(sum(range(10)))", "language": "python" } ],
"code": "print(sum(range(10)))",
"language": "python",
"codeOutputs": [ { "stdout": "45\n", "stderr": "", "returnCode": 0, "isError": false } ],
"codeOutput": "45\n",
"files": [
{ "binaryKey": "sales_chart.png", "fileId": "file_011...", "filename": "sales_chart.png", "mimeType": "image/png", "size": 48213 }
],
"model": "claude-...",
"usage": { "input_tokens": 620, "output_tokens": 1840 },
"stopReason": "end_turn"
}
codeBlocksholds every block of code the model executed, in order.codeandlanguageare a convenience copy of the first block, and both are omitted when Include Code is off.codeOutputsholds one entry per execution, with the capturedstdout,stderr, exitreturnCode, and anisErrorflag.codeOutputis the joined stdout of every execution.codeErroris added and set totruewhen any execution failed, alongsidecodeErrorMessagewith the failure text. Note that a failing script is not a node error — the item still leaves through the Output port, so branch oncodeErrorif you need to react to it.fileslists every file the sandbox produced. Each entry names thebinaryKeyunder which the bytes were attached to this output item, plus the AnthropicfileIdthat downstream Claude nodes can reference directly. The array is empty when nothing was written.modelis the model that actually answered,usageis Anthropic’s token accounting, andstopReasonsays why generation stopped.
Reference the result downstream by expression, e.g. {{ $json.codeOutput }}.
Usage Examples
- Calculate statistical metrics from data
- Generate and run Python code to solve a math problem
- Perform data transformations with code execution
- Run algorithmic computations with Claude
- Parse and process text data with Python
Example Configuration
Minimal — one computation per item:
{
"type": "claude_code_execution",
"parameters": {
"userMessage": "Calculate the first 20 Fibonacci numbers and return them as a JSON array."
}
}
Deterministic data processing with the input fields carried through:
{
"type": "claude_code_execution",
"parameters": {
"systemPrompt": "You are a data engineering assistant. Always return results as valid JSON. Never include explanatory prose outside a code block.",
"userMessage": "Parse the CSV data in {{ $json.csvContent }} and return summary statistics (mean, median, min, max) for each numeric column.",
"includeInput": true,
"maxConcurrency": 3,
"options": {
"maxTokens": 4096,
"temperature": 0,
"responseFieldName": "stats",
"includeCode": true
}
}
}
Generate a chart and pick the file up as binary downstream:
{
"type": "claude_code_execution",
"parameters": {
"systemPrompt": "You are a scientific visualization expert. Produce clean, publication-ready plots.",
"userMessage": "Generate a bar chart from {{ $json.salesData }} and save it as 'sales_chart.png'. Return a one-sentence summary.",
"maxConcurrency": 2,
"options": {
"maxTokens": 8192,
"temperature": 0,
"responseFieldName": "chartResult",
"includeCode": true
}
}
}
Error Handling
| Mode | Behavior |
|---|---|
| stop | Halts workflow on first error |
| continue | Skips failed items, passes successful ones through |
| errorPort | Routes failed items to Error output port |
Tips
Claude Code Execution sends Python tasks to the Anthropic Messages API and runs them in a secure, isolated sandbox using the code execution tool type. Use it when a workflow requires dynamic computation, data analysis, string manipulation, or algorithmic logic that static processing nodes cannot handle. The tool outputs both the generated Python code and its execution result on the main channel, routing runtime failures to the error channel.
Frequently asked questions
What credentials do I need to use this node?
You need an Anthropic credential configured in BusyBot. This means a valid Anthropic API key that has access to the Messages API with the code_execution tool type enabled. No other credential type is accepted by this node.
What comes out of the Output vs. Error channels?
The main Output channel carries both the Python code Claude generated and the result of its execution. If the code fails at runtime — an exception, a syntax error, or a sandbox-level failure — the node routes that to the Error channel instead. Downstream nodes should be wired to both channels if you need to handle failures explicitly.
If Claude writes a file during execution, how do I access it?
Any files written to the sandbox during the run are automatically downloaded by the node and attached to the output item as binary data. Downstream nodes receive the raw bytes directly, so you can pass them to a file-writing node, an upload node, or any node that accepts binary input without an extra conversion step.
What kinds of tasks is this node actually suited for?
It's designed for dynamic computation that static workflow nodes can't perform — things like numerical calculations, data analysis, string manipulation, and custom algorithmic logic. If your workflow needs to process structured data with logic that varies per run, or perform math that isn't covered by a fixed formula node, this is the right fit. It's not a general-purpose API caller; it specifically routes tasks through Claude's sandboxed Python environment.
Does Claude decide what Python code to write, or do I specify it?
You send a user message as input, and Claude writes the Python code itself based on that message before executing it. You describe the task in plain language or structured instructions; the model handles code authorship. The node then returns what Claude wrote alongside the output, so you can inspect the generated code in the workflow results.
Build with the Claude Code Execution node
Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need Anthropic credentials first.
Open BusyBotLast updated . Spotted something wrong? Tell us.