[BUG] "Run in terminal" strips ALL spaces from commands

Resolved 💬 4 comments Opened May 8, 2026 by Bonyfac1 Closed Jun 8, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Hi Anthropic team,

When clicking the ▷ "Run in terminal" button on a code block in Claude for Mac, all spaces are stripped from the command before it is sent to the terminal. This includes spaces between arguments AND spaces inside quoted strings, which corrupts both the syntax and the semantics of the command.

The terminal window flashes briefly but nothing executes, because the squashed command is invalid.

Examples observed:

  • Code block: echo hello → Preview shown: echohello
  • Code block: echo "a b c" → Preview shown: echo"abc"

The second example is particularly concerning: spaces inside the quoted string are also removed, which would change the meaning of the command even if it did execute.

The same command copied via the 📋 Copy button and pasted into the terminal manually with Cmd+V works correctly — spaces are preserved. The bug appears to be specific to the run-in-terminal pipeline.

Screenshots attached.

Note: This is about Claude Desktop (Mac app) v1.6608.0, not the Claude Code CLI.

What Should Happen?

When I click the ▷ "Run in terminal" button on a code block, the exact command shown in the code block should be sent to my terminal — byte-for-byte identical, with all spaces preserved (both between arguments and inside quoted strings). The terminal should then execute the command normally.

Error Messages/Logs

No error message is shown. The terminal window flashes briefly and closes silently. No stderr / stdout output is produced because the squashed command is invalid.

Steps to Reproduce

  1. Ask Claude for any shell command, e.g. echo hello or echo "a b c"
  2. Verify the rendered code block displays the correct command
  3. Click the ▷ "Run in terminal" button
  4. Observe the gray preview line below the button — spaces have been removed
  5. Terminal flashes briefly but nothing executes

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude for Mac 1.6608.0 (build f65729) — note: this is Claude Desktop, not Claude Code CLI

Platform

Anthropic API

Operating System

macOS 26.5 Tahoe

Terminal/Shell

Terminal.app (macOS)

Additional Information

Platform note: This is Claude Desktop for Mac (the desktop app),
not the Claude Code CLI or direct API integration. The "Platform"
field above was filled with "Anthropic API" because no Desktop
option was available in the dropdown.

<img width="507" height="120" alt="Image" src="https://github.com/user-attachments/assets/0e132a8b-c478-4a92-8c85-5e27fe0201b2" />
<img width="525" height="118" alt="Image" src="https://github.com/user-attachments/assets/9368ee6c-0c33-42d0-a2e3-94fcdca6cf8d" />

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗