← Claude Code Hub
✦ Tip #007 Feb 11, 2026

Run Shell Commands Without Leaving Claude Code

Type ! followed by any command to run it directly in your shell without leaving Claude Code. Use Ctrl+B for background processes.

Claude Code has a built-in bash mode: type ! followed by any command and it runs directly in your shell, without Claude interpreting or approving it. Output appears in real time and gets added to the conversation context — Claude sees the result and can act on it.

This is one of those features you don't discover by reading the docs — you see someone use it. You're debugging, need a quick git log or a cat of a file, and instead of jumping to another tab you just type ! git log --oneline -5. Seems minor, but it eliminates the constant context switching.

It's not an obvious feature, but once you discover it, it changes how you work. No need to open another terminal or split pane. You type, it runs, you keep talking.

TL;DR Prefix any command with ! to run it directly. Use Ctrl+B to send long-running processes to the background. Claude sees the output from both.

Result:

> ! git status

On branch feature/auth
Changes not staged for commit:
  modified:   src/auth/login.ts
  modified:   src/auth/session.ts

How to use it

1. Run a quick command

Type ! followed by the command:

! npm test
! git diff --stat
! ls -la src/

Claude doesn't intervene — the command goes straight to your shell. But the output is added to the conversation, so you can ask "what failed?" right after.

2. Send a long process to the background

If a command takes too long (builds, tests, dev servers), press Ctrl+B while it's running:

! npm run build
# taking too long → press Ctrl+B
# Claude is available again while the build finishes in background

You can also ask Claude directly to run something in the background.

3. History-based autocomplete

Type ! followed by the first few letters and press Tab. Claude Code autocompletes from previous ! commands in the current project.

! np  → Tab → ! npm test

And to search your previous prompts, not just ! commands? Press Ctrl+R for reverse search over your prompt history — across every project, too.

Reference

Aspect Detail
Prefix ! at the start of input
Execution Directly in your shell, no Claude interpretation
Output Shown in real time and added to conversation context
Background Ctrl+B during execution (tmux: press twice)
Autocomplete Tab completes from project's ! command history
Permissions No approval needed — it's your terminal

Official docs: Interactive mode — Bash mode

Free guide

51 tips to master Claude Code.

One page per tip. Five chapters. What I actually use daily in production — no theory, no fluff.

  • I. Getting started 10 tips
  • II. Awareness 3 tips
  • III. Mastery 22 tips
  • IV. Autonomy 10 tips
  • V. Comparison 6 tips
Are you a professional Web developer?

You'll receive the guide by email · You join the Gravitas newsletter · Unsubscribe anytime

of 51
#

Wmedia · 51 Tips
Free guide · 51 tips · 5 chapters

51 tips to master Claude Code.

Are you a professional Web developer? · Unsubscribe anytime