Code Execution & File Creation
Code execution and file creation gives Claude a secure, sandboxed computing environment where it can write and run code, manipulate files, and produce downloadable documents — all without leaving the conversation. On claude.ai (web, desktop, and mobile), this means Claude can process uploaded data, perform calculations, generate visualizations, and create professional files in formats like Excel (.xlsx), PowerPoint (.pptx), Word (.docx), and PDF. The sandbox runs Bash commands and supports multiple programming languages; Claude autonomously writes the scripts, executes them, and returns results or downloadable files directly in the chat.
For API users, the feature is exposed as a tool (currently `code_execution_20250825` in public beta) that can be attached to any supported model request. A newer version, `code_execution_20260120`, adds REPL state persistence and programmatic tool calling from within the sandbox, but is limited to Opus 4.5+ and Sonnet 4.5+. Because code runs in an isolated container, the environment is separated from the user's local machine and from the broader internet unless network egress is explicitly enabled by an administrator.
File uploads and downloads are both capped at 30 MB per file. Large PDFs exceeding this limit can still be passed directly into the computing environment for processing without consuming the conversational context window. The feature is available across all plans — Free, Pro, Max, Team, and Enterprise — on the web, Claude Desktop, and Claude Mobile, with no extra subscription charge beyond the plan itself.
When you’d use it
- ◆Automated Document Generation — A user needs a professionally formatted Excel budget tracker, Word report, or PowerPoint deck but doesn't have the time or software skills to build it manually. They describe the structure and content to Claude, which writes and executes the appropriate Python libraries to produce the file and returns it as a download.
- ◆Data Analysis and Visualization — An analyst uploads a CSV of sales data and asks Claude to clean it, calculate summary statistics, and produce a bar chart PNG and a formatted Excel pivot table. Claude runs pandas and matplotlib in the sandbox and returns both files.
- ◆Survey or Research Report Production — A researcher uploads hundreds of rows of survey responses and asks for three simultaneous outputs: a PowerPoint with key findings, a Word document with an executive summary and recommendations, and an Excel workbook with organized raw data and average scores by category.
- ◆Agentic API Workflows with Dynamic Filtering — A developer builds an agent that combines web search and code execution: Claude fetches a large external dataset, runs a Python filter script in the sandbox to trim irrelevant rows before they enter the context window, then synthesizes only the filtered results — saving tokens and improving accuracy.
- ◆Financial Modeling and Forecasting — A finance professional asks Claude to build a multi-year revenue forecast spreadsheet with formula-driven rows, compounding growth rates, and a line chart. Claude generates an .xlsx file with working formulas and formatted currency columns, ready for direct use in Excel.
What changed recently
- ◆2025-11-24 — Claude Sonnet 4.5 released. Identified as the most capable model for file creation tasks in claude.ai, delivering more consistent professional-quality outputs with fewer iteration cycles needed.
- ◆2025-08-25 — API code execution tool upgraded to code_execution_20250825. Added Bash command support and multi-language file manipulation, replacing the legacy Python-only code_execution_20250522. No price change.
- ◆2026-01-20 — code_execution_20260120 released for API. Adds REPL state persistence (variables and state persist across multiple code execution calls in a session) and programmatic tool calling from within the sandbox. Available only on Opus 4.5+ and Sonnet 4.5+.
- ◆2026-05-29 — Public sharing of conversations containing file artifacts from code execution disabled for Free, Pro, and Max users. Team and Enterprise users retain sharing capability via organization controls.
This is the short version
The full chapter has three worked examples, the common pitfalls, and the workflow that makes it pay — plus the other 84 features, kept current.
Get Claude Master — $97 →