# ! Shell Mode

> The ! prefix that runs your own shell command and puts its output in the chat.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** bang prefix, run a shell command in Claude Code

## Think of it like

It is like doing a job by hand while a friend looks on. Then you ask what they think.

## Definition

Shell mode is the Claude Code feature you start by typing ! at the start of the prompt. The command runs in your shell at once, with no approval, and its output joins the chat. Claude then replies to it, at the cost of a normal prompt. It runs outside the sandbox, because the sandbox fences only Claude's commands. Esc or Backspace on an empty prompt leaves it.

## Example

Leo types ! npm test. The tests fail, and Claude explains why without a second prompt.

## Example code

```console
! npm test
```

Run the tests yourself. Claude sees the output and explains the failures.

## Why it matters

You can run a quick command yourself and still give Claude what it printed.

## Common mistake

Thinking the sandbox fences it. Commands you type with ! run outside the sandbox.

## Three principles

- **Your command, run now.** No approval.
- **Output joins the chat.** Claude replies.
- **Outside the sandbox.** Not fenced.

## Related terms

- [Bash Tool](https://learn.benibix.com/term/ai/bash-tool)
- [sandbox.enabled](https://learn.benibix.com/term/ai/sandbox-enabled-setting)
- [Ctrl+B Shortcut](https://learn.benibix.com/term/ai/ctrl-b-shortcut)
- [Shell](https://learn.benibix.com/term/infrastructure/shell)

## 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

- [Claude Code Prompt Shortcuts](https://learn.benibix.com/learn/ai-claude-code/claude-code-prompt-shortcuts): Claude Code, 4/16

![With the ! prefix, your command runs in the shell with no approval, its output joins the chat, and Claude replies to it.](https://learn.benibix.com/diagrams/shell-mode-flow.svg)

---

Source: https://learn.benibix.com/term/ai/shell-mode-shortcut
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-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
