# ClaudeBashToolMiddleware

> **Class** in `langchain_anthropic`

📖 [View in docs](https://reference.langchain.com/python/langchain-anthropic/middleware/bash/ClaudeBashToolMiddleware)

Middleware that exposes Anthropic's native bash tool to models.

## Signature

```python
ClaudeBashToolMiddleware(
    self,
    workspace_root: str | None = None,
    *,
    startup_commands: tuple[str, ...] | list[str] | str | None = None,
    shutdown_commands: tuple[str, ...] | list[str] | str | None = None,
    execution_policy: Any | None = None,
    redaction_rules: tuple[Any, ...] | list[Any] | None = None,
    tool_description: str | None = None,
    env: dict[str, Any] | None = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `workspace_root` | `str \| None` | No | Base directory for the shell session.  If omitted, a temporary directory is created. (default: `None`) |
| `startup_commands` | `tuple[str, ...] \| list[str] \| str \| None` | No | Optional commands executed after the session starts. (default: `None`) |
| `shutdown_commands` | `tuple[str, ...] \| list[str] \| str \| None` | No | Optional commands executed before session shutdown. (default: `None`) |
| `execution_policy` | `Any \| None` | No | Execution policy controlling timeouts and limits. (default: `None`) |
| `redaction_rules` | `tuple[Any, ...] \| list[Any] \| None` | No | Optional redaction rules to sanitize output. (default: `None`) |
| `tool_description` | `str \| None` | No | Optional override for tool description. (default: `None`) |
| `env` | `dict[str, Any] \| None` | No | Optional environment variables for the shell session. (default: `None`) |

## Extends

- `ShellToolMiddleware`

## Constructors

```python
__init__(
    self,
    workspace_root: str | None = None,
    *,
    startup_commands: tuple[str, ...] | list[str] | str | None = None,
    shutdown_commands: tuple[str, ...] | list[str] | str | None = None,
    execution_policy: Any | None = None,
    redaction_rules: tuple[Any, ...] | list[Any] | None = None,
    tool_description: str | None = None,
    env: dict[str, Any] | None = None,
) -> None
```

| Name | Type |
|------|------|
| `workspace_root` | `str \| None` |
| `startup_commands` | `tuple[str, ...] \| list[str] \| str \| None` |
| `shutdown_commands` | `tuple[str, ...] \| list[str] \| str \| None` |
| `execution_policy` | `Any \| None` |
| `redaction_rules` | `tuple[Any, ...] \| list[Any] \| None` |
| `tool_description` | `str \| None` |
| `env` | `dict[str, Any] \| None` |


## Methods

- [`wrap_model_call()`](https://reference.langchain.com/python/langchain-anthropic/middleware/bash/ClaudeBashToolMiddleware/wrap_model_call)
- [`awrap_model_call()`](https://reference.langchain.com/python/langchain-anthropic/middleware/bash/ClaudeBashToolMiddleware/awrap_model_call)

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/c59e83a1ffba63d709ea4847445845edd82085dc/libs/partners/anthropic/langchain_anthropic/middleware/bash.py#L19)