# Bash Tool

> The tool that runs shell commands on your computer.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** Bash, Claude Code Bash tool, Bash(npm run *)

## Think of it like

It is like a friend who types on your keys for you.

## Definition

The Bash tool runs shell commands on your computer, such as tests, builds and git. Each command runs in its own process. A change of folder carries over to the next command, but a variable you export does not. A command stops after two minutes by default, and Claude can ask for up to ten. Long jobs, such as a dev server, can run in the background. Bash asks before it runs, unless a rule or your mode allows the command.

## Example

Emma asks Claude to fix a failing test. It runs the tests with Bash, reads the error, makes a fix, and runs them again until they pass.

## Example code

```json
{"permissions": {"allow": ["Bash(npm run *)"]}}
```

Let every npm run script go through without asking.

## Why it matters

It is what lets Claude check its own work by running it, not just reading it.

## Common mistake

Allowing Bash with no pattern. That lets every command run, so allow only the ones you trust, like Bash(npm test).

## Three principles

- **Runs commands.** Tests, builds, git.
- **Two minutes by default.** Up to ten.
- **Asks first.** Unless a rule allows it.

## Related terms

- [Shell](https://learn.benibix.com/term/infrastructure/shell)
- [PowerShell Tool](https://learn.benibix.com/term/ai/powershell-tool)
- [Monitor Tool](https://learn.benibix.com/term/ai/monitor-tool)
- [Permission Rule](https://learn.benibix.com/term/ai/permission-rule)

## Told apart from

- [! Shell Mode vs the Bash Tool](https://learn.benibix.com/compare/shell-mode-shortcut-vs-bash-tool): People think a ! command and a command Claude runs are the same thing. With !, you run the command yourself, at once, with no approval and outside the sandbox. The Bash tool is how Claude runs a command, so it goes through your permission rules and the sandbox. Both put the output in the chat.

## Taught in

- [Bash, WebFetch and WebSearch](https://learn.benibix.com/learn/ai-claude-code/bash-webfetch-and-websearch): Claude Code, 10/16

![Bash runs a command and returns its output. Monitor runs one in the background and sends each new line as it comes.](https://learn.benibix.com/diagrams/ct-shell-tools.svg)

---

Source: https://learn.benibix.com/term/ai/bash-tool
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
