Claude Corner
Pasting Test Output Into Claude From Another Terminal? Type ! and Run It in Claude Code.
By Steven Sorensen ยท 3 Dec 2026

At a glance
- Start a prompt with ! and Claude Code runs it as a shell command without Claude interpreting or approving it.
- The command and its output land in the conversation, and Claude replies to the result.
- One setting keeps the output in context without a reply, so you can run several commands first.
You run the tests in a second terminal, copy forty lines of failures, and paste them into Claude. The copy loses lines, and Claude never sees the command you ran. Claude Code can run it for you inside the session.
Why it matters
Anthropic's interactive mode guide calls it shell mode. Prefix your input with ! and Claude Code runs the command directly without going through Claude, adds the command and its output to the conversation context, and shows the output live as it runs. Claude then responds to the output on its own, so ! npm test gets you an explanation of the failures without a second prompt.
How to hand Claude a command's output without copying it
We have not run these steps in a live session.
- Type
!at the start of an empty prompt, then the command, such as! npm test. - Read Claude's reply. The guide says Claude responds once the output lands in the transcript.
- For a long test run, press
Ctrl+Bto background it, which the guide says shell mode supports. - Repeat a command by typing part of it and pressing
Tab. The guide says shell mode completes from your previous!commands in the current project. - To collect several outputs before Claude says anything, set
respondToBashCommandstofalsein a settings file such as~/.claude/settings.json. The settings reference says the output then goes into context without a reply, so you can ask about it all at once. - Leave shell mode with
Escape,Backspace, orCtrl+Uon an empty prompt.
# We have not run this script end to end on every platform.
# In the Claude Code prompt: run the tests and let Claude explain the failures.
! npm test
# In the Claude Code prompt: put more output on record.
! git status
# In ~/.claude/settings.json: keep output in context without an automatic reply.
{
"respondToBashCommands": false
}
Gotchas
- Your command skips the sandbox. The guide says commands you type in shell mode run outside the sandbox even when sandboxing is on, because the sandbox applies to the commands Claude runs. The sandboxing guide lists the exceptions, such as a background session under strict sandbox mode.
- There is no approval step. The guide says shell mode "doesn't require Claude to interpret or approve the command," so read a destructive command twice before you press Enter.
- Pasting can switch modes. The guide says pasting text that starts with
!into an empty prompt enters shell mode too, so check the prompt before you press Enter. - Every reply costs a prompt. The guide says Claude's automatic reply costs the same as a normal prompt, so turn the reply off while you gather output, then ask one question.
- A stashed command keeps its mode. The guide says
Ctrl+Sstashes your prompt, and restoring it brings a stashed!command back in shell mode.
Shell mode pairs well with backgrounding, see Claude Started Your Dev Server and the Turn Just Sat There? Press Ctrl+B and Keep Working.
Sources:
- Interactive mode, Claude Code docs
- Settings reference, Claude Code docs
- Sandboxing, Claude Code docs
- Settings, Claude Code docs
Recommended AI prompt
Copy this paragraph into ChatGPT, Claude, Gemini, Grok, or whatever AI you use.
I use Claude Code and keep copying command output from another terminal into the chat. Using only Anthropic's Claude Code docs on shell mode, the respondToBashCommands setting and sandboxing, ask which commands I usually paste and whether I run with the sandbox on. Then give me a short checklist for running those commands with the ! prefix, deciding when to turn off the automatic reply, and spotting commands I should still run with care because shell mode skips approval and the sandbox.