In short.
Anthropic’s Bash tool guide teaches developers how to let Claude request shell commands, but the application must provide and protect the execution environment. Its central design is a persistent Bash process controlled by the application, with commands and results exchanged through the Messages API. The guide covers implementation, security controls, token overhead and operational limits. Its examples are starting points rather than evidence of a complete secure runner; no commands or examples were executed, and reliability, performance and total cost are not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is the complete selected documentation page at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/bash-tool.md], source revision sha256:3da982782f0b6833f2adf28de033a5847b78f2b2de43e9cff0c023a8030165d3. This includes its code examples, historical-version notice, security warnings, pricing table, limitations and data-handling exceptions. Every linked page is excluded, including detailed pricing, provider setup, model deprecations and retention requirements. Examples were not executed, and runtime behavior, security effectiveness and deployment readiness are not established.
The overview
Resource identity
The resource is Anthropic’s documentation page titled Bash tool, supplied at [https://platform.claude.com/docs/en/agents-and-tools/tool-use/bash-tool.md]. It teaches an API integration in which Claude proposes commands and the developer’s application executes them.
The page identifies bash_20250124 as the current tool version. This is a client tool: the shell process and its files live in the application’s environment.
Practical assessment
The guide is useful for developers who need implementation detail for command-running agents. It connects the API request format to session management, result handling and operational safeguards, making the integration responsibilities clear.
The main catch is the amount of infrastructure left to the developer. The minimal runner does not include every required control, and the page explicitly says its sample command validator is only a tripwire. No evidence establishes production reliability or security effectiveness.
Who it suits
The documented uses include running builds and tests, processing datasets, managing files, configuring environments and automating scripts. It suits developers building Claude applications that need command-line access to their own execution environment.
Beginners can use the request-and-result examples to understand tool calling, but implementing the runner requires familiarity with APIs, subprocesses and permissions. Experienced developers receive concrete session and timeout patterns, though deployment architecture and platform-specific hardening remain their responsibility.
Documented capabilities
Claude can request commands across multiple turns while the application retains the same working directory, environment variables and files. The tool also supports a restart request. A response may contain several tool calls, which the page instructs applications to execute in order within the same session.
The tool definition requires type and name, with the name fixed to bash. Its input schema is built into the model and cannot be modified. Claude supplies command, or restart set to true instead of a command. Request examples cover cURL, CLI and several programming languages.
Using it
What an integration needs
An integration needs access to a supported Claude model, an authenticated API client, a Bash environment and application code that handles tool requests. The developer must manage the shell’s lifetime, installed commands, permissions, timeouts, output size and result messages.
The page states that bash_20250124 requires no beta header and is accepted from Claude Sonnet 3.7 onward. It lists availability through Claude API, Amazon Bedrock including bedrock-runtime, Claude Platform on AWS, Google-managed Claude on Google Cloud and Microsoft Foundry. Individual provider configurations were not assessed.
The runner examples use /bin/bash, and several timeout examples rely on Unix-style process groups. Portability to other operating systems is not established.
How command execution works
Claude returns a tool_use block containing a requested command. The application executes it and returns combined stdout and stderr in a tool_result linked by tool_use_id. That result becomes part of the next request, after which Claude may request another command or produce an answer.
The API is stateless; shell persistence comes entirely from the application keeping a Bash process alive. The sample runner prints a unique sentinel after each command to identify the end of its output. Multiple tool calls receive separate results together in the next user message.
Execution failures should be returned with is_error set to true. The application continues the exchange while the response stop_reason is tool_use.
Implementation path
Declare a tool with type bash_20250124 and name bash in a Messages API request. Start a persistent Bash process, handle command and restart inputs, preserve the assistant’s tool-use message, and return a matching tool_result for every requested call.
The page recommends isolating the session in a container or virtual machine, using minimal privileges, validating commands with an allowlist, setting CPU, memory and disk limits, and redacting secrets before returning output. It also calls for command logging, output truncation and deadlines that stop the shell and its child processes before restarting.
These controls require application code and environment configuration. Adding the tool declaration alone does not provide an execution environment or enforce command restrictions.
Illustrative workflow
For a request to list Python files in the current directory, the page shows Claude requesting ls *.py. The application runs that command and returns the resulting filenames with the matching tool_use_id. The filenames shown in the documentation are illustrative output.
A separate example changes the working directory to /tmp and then requests the directory again, demonstrating the intended persistence between calls. Another chains package installation, script creation and execution. None of these examples was executed, so their runtime behavior is not established.
Assessment & evidence
Limits and implementation gaps
The documented interface does not support interactive commands, password prompts or GUI applications. Claude receives output only when the application returns a tool result. Oversized requests are rejected rather than automatically truncated, so output limits must be enforced by the application.
The sample validator does not catch every shell operator, including operators attached directly to another token. The page explicitly identifies isolation as the real enforcement boundary. Its restrictive sample allowlist also rejects operators used in other workflow examples, so applications must define a consistent execution policy.
From the shown code, the minimal runner returns text without propagating the command’s exit status. An integration therefore needs additional failure handling to reliably produce is_error results. Shell restart resets session state; deletion of previously created files is not established.
Design tradeoffs
The design places execution control with the application. This supports access to its own tools and files, while persistent shell state allows later commands to use earlier setup. The corresponding responsibility is that permissions, resource controls and recovery behavior depend on the developer’s implementation.
The documented token overhead, lack of automatic output truncation and warning about oversized requests support keeping returned output focused. Long logs can increase request size without adding useful context. This is a practical inference from the documented design, not a measured efficiency result.
Related tools and choices
The page points to the Text editor tool for viewing and modifying files, and describes pairing it with Bash when edited code needs to be run. Its full capabilities and costs are not established by this page.
It also distinguishes the Code execution tool, which runs in Anthropic’s sandboxed container. That environment is separate from the application’s Bash session, and state is not shared. The page provides no comparative benchmark or complete pricing comparison between these approaches.
Evidence and confidence
The evidence is one complete Anthropic documentation page containing API examples, runner implementations, security guidance, pricing overhead, version information and availability notices. It supports statements about the documented interface and intended behavior.
No independent measurements, execution traces or security-validation results are supplied. Nothing was executed. Command success, timeout cleanup, isolation effectiveness, performance and behavior across supported platforms remain unassessed.
Access & freshness
Token overhead and unknown costs
The page states that the Bash tool definition adds 325 input tokens per request for Claude 4.7 and later models and Claude Mythos Preview, or 244 for Claude 4.6 and earlier models. This is additional to the model-specific tool-use system prompt.
Returned command output, errors and file contents also consume tokens. Repeated command-and-result exchanges therefore affect usage, and the page recommends truncating large outputs.
No currency prices, hosting costs or complete task-cost examples are supplied. Total cost is unknown and depends on model pricing, conversation size, command output, execution infrastructure and the number of exchanges.
Reuse and data handling
The supplied page does not state a license for its documentation or embedded code examples. Redistribution permissions and applicable service terms are unknown from this evidence.
The page marks the feature as eligible for zero data retention, excluding Covered Models, and eligible for HIPAA readiness. The linked model-specific retention requirements and contractual conditions are outside the supplied evidence; these eligibility statements do not establish a particular deployment’s compliance.
Commands run in the application’s environment, but output returned as tool results is sent to Claude. The page specifically recommends removing credentials and other secrets from that output.
Version and freshness
The source was captured on 2026-11-14 at 23:04:45.762 UTC. It describes bash_20250124 as current and stable, requiring no beta header. It identifies bash_20241022 as an older version limited to a retired Claude Sonnet 3.5 model.
No publication or last-updated date is supplied. The date embedded in the tool identifier is not evidence of the page’s maintenance date. Changes after the capture, including model availability, pricing and retention eligibility, are unknown.
Next steps for developers
Begin with a disposable isolated environment and a narrowly allowed read-only command. Implement the complete tool-result exchange, then verify session persistence, restart behavior, command failures, hung-command cleanup and output truncation before expanding the workload.
Review the sample validator’s documented gaps, add reliable exit-status handling, and define filesystem, network and resource access for the intended task. Confirm that secrets are removed from returned output and that logs are handled appropriately.
Before estimating a budget or handling sensitive data, obtain the chosen model’s current prices and applicable retention and service terms. Those details are not established by this page.
