<!-- BusyBot node reference — https://busybot.net/tools/claude-code-execution/ -->

> Node: Claude Code Execution (`claude_code_execution`) · Action (binary) · v1
> Category: AI · Credentials: Anthropic (`anthropic`)
> Updated: 2026-08-16

# 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](https://busybot.net/credentials/anthropic/) 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.

```json
{
  "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"
}
```

- `codeBlocks` holds every block of code the model executed, in order. `code` and `language` are a convenience copy of the first block, and both are omitted when Include Code is off.
- `codeOutputs` holds one entry per execution, with the captured `stdout`, `stderr`, exit `returnCode`, and an `isError` flag. `codeOutput` is the joined stdout of every execution.
- `codeError` is added and set to `true` when any execution failed, alongside `codeErrorMessage` with the failure text. Note that a failing script is not a node error — the item still leaves through the Output port, so branch on `codeError` if you need to react to it.
- `files` lists every file the sandbox produced. Each entry names the `binaryKey` under which the bytes were attached to this output item, plus the Anthropic `fileId` that downstream Claude nodes can reference directly. The array is empty when nothing was written.
- `model` is the model that actually answered, `usage` is Anthropic's token accounting, and `stopReason` says 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:

```json
{
  "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:

```json
{
  "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:

```json
{
  "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.