Files
AutoGPT/docs/integrations/block-integrations/claude_code.md
Bently 82d7134fc6 feat(blocks): Add ClaudeCodeBlock for executing tasks via Claude Code in E2B sandbox (#11761)
Introduces a new ClaudeCodeBlock that enables execution of coding tasks
using Anthropic's Claude Code in an E2B sandbox. This block unlocks
powerful agentic coding capabilities - Claude Code can autonomously
create files, install packages, run commands, and build complete
applications within a secure sandboxed environment.

Changes 🏗️

- New file backend/blocks/claude_code.py:
  - ClaudeCodeBlock - Execute tasks using Claude Code in an E2B sandbox
- Dual credential support: E2B API key (sandbox) + Anthropic API key
(Claude Code)
- Session continuation support via session_id, sandbox_id, and
conversation_history
- Automatic file extraction with path, relative_path, name, and content
fields
  - Configurable timeout, setup commands, and working directory
- dispose_sandbox option to keep sandbox alive for multi-turn
conversations

Checklist 📋

For code changes:

- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] Create and execute ClaudeCodeBlock with a simple prompt ("Create a
hello world HTML file")
- [x] Verify files output includes correct path, relative_path, name,
and content
- [x] Test session continuation by passing session_id and sandbox_id
back
- [x] Build "Any API → Instant App" demo agent combining Firecrawl +
ClaudeCodeBlock + GitHub blocks
- [x] Verify generated files are pushed to GitHub with correct folder
structure using relative_path

Here are two example agents i made that can be used to test this agent,
they require github, anthropic and e2b access via api keys that are set
via the user/on the platform is testing on dev

The first agent is my

Any API → Instant App
"Transform any API documentation into a fully functional web
application. Just provide a docs URL and get a complete, ready-to-deploy
app pushed to a new GitHub repository."

[Any API → Instant
App_v36.json](https://github.com/user-attachments/files/24600326/Any.API.Instant.App_v36.json)


The second agent is my
Idea to project
"Simply enter your coding project's idea and this agent will make all of
the base initial code needed for you to start working on that project
and place it on github for you!"

[Idea to
project_v11.json](https://github.com/user-attachments/files/24600346/Idea.to.project_v11.json)

If you have any questions or issues let me know.

References
https://e2b.dev/blog/python-guide-run-claude-code-in-an-e2b-sandbox

https://github.com/e2b-dev/e2b-cookbook/tree/main/examples/anthropic-claude-code-in-sandbox-python
https://code.claude.com/docs/en/cli-reference

I tried to use E2b's "anthropic-claude-code" template but it kept
complaining it was out of date, so I make it manually spin up a E2b
instance and make it install the latest claude code and it uses that
2026-01-23 10:05:32 +00:00

4.5 KiB

Claude Code Execution

What it is

The Claude Code block executes complex coding tasks using Anthropic's Claude Code AI assistant in a secure E2B sandbox environment.

What it does

This block allows you to delegate coding tasks to Claude Code, which can autonomously create files, install packages, run commands, and build complete applications within a sandboxed environment. Claude Code can handle multi-step development tasks and maintain conversation context across multiple turns.

How it works

When activated, the block:

  1. Creates or connects to an E2B sandbox (a secure, isolated Linux environment)
  2. Installs the latest version of Claude Code in the sandbox
  3. Optionally runs setup commands to prepare the environment
  4. Executes your prompt using Claude Code, which can:
    • Create and edit files
    • Install dependencies (npm, pip, etc.)
    • Run terminal commands
    • Build and test applications
  5. Extracts all text files created/modified during execution
  6. Returns the response and files, optionally keeping the sandbox alive for follow-up tasks

The block supports conversation continuation through three mechanisms:

  • Same sandbox continuation (via session_id + sandbox_id): Resume on the same live sandbox
  • Fresh sandbox continuation (via conversation_history): Restore context on a new sandbox if the previous one timed out
  • Dispose control (dispose_sandbox flag): Keep sandbox alive for multi-turn conversations

Inputs

Input Description
E2B Credentials API key for the E2B platform to create the sandbox. Get one at e2b.dev
Anthropic Credentials API key for Anthropic to power Claude Code. Get one at Anthropic's website
Prompt The task or instruction for Claude Code to execute. Claude Code can create files, install packages, run commands, and perform complex coding tasks
Timeout Sandbox timeout in seconds (default: 300). Set higher for complex tasks. Note: Only applies when creating a new sandbox
Setup Commands Optional shell commands to run before executing Claude Code (e.g., installing dependencies)
Working Directory Working directory for Claude Code to operate in (default: /home/user)
Session ID Session ID to resume a previous conversation. Leave empty for new conversations
Sandbox ID Sandbox ID to reconnect to an existing sandbox. Required when resuming a session
Conversation History Previous conversation history to restore context on a fresh sandbox if the previous one timed out
Dispose Sandbox Whether to dispose of the sandbox after execution (default: true). Set to false to continue conversations later

Outputs

Output Description
Response The output/response from Claude Code execution
Files List of text files created/modified during execution. Each file includes path, relative_path, name, and content fields
Conversation History Full conversation history including this turn. Use to restore context on a fresh sandbox
Session ID Session ID for this conversation. Pass back with sandbox_id to continue the conversation
Sandbox ID ID of the sandbox instance (null if disposed). Pass back with session_id to continue the conversation
Error Error message if execution failed

Possible use case

API Documentation to Full Application: A product team wants to quickly prototype applications based on API documentation. They create an agent that:

  1. Uses Firecrawl to fetch API documentation from a URL
  2. Passes the docs to Claude Code with a prompt like "Create a web app that demonstrates all the key features of this API"
  3. Claude Code builds a complete application with HTML/CSS/JS frontend, proper error handling, and example API calls
  4. The Files output is used with GitHub blocks to push the generated code to a new repository

The team can then iterate on the application by passing the sandbox_id and session_id back to Claude Code with refinement requests like "Add authentication" or "Improve the UI", and Claude Code will modify the existing files in the same sandbox.

Multi-turn Development: A developer uses Claude Code to scaffold a new project:

  • Turn 1: "Create a Python FastAPI project with user authentication" (dispose_sandbox=false)
  • Turn 2: Uses the returned session_id + sandbox_id to ask "Add rate limiting middleware"
  • Turn 3: Continues with "Add comprehensive tests"

Each turn builds on the previous work in the same sandbox environment.