[BUG] Bash tool call drops "cd /path &&" prefix from SSH commands silently
Resolved 💬 3 comments Opened Mar 21, 2026 by the-mace Closed Mar 21, 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?
When Claude generates a Bash tool call containing ssh user@host "cd /path && command", the cd /path && portion is silently dropped from the actual command parameter. The command executes as ssh user@host "command" instead.
What Should Happen?
The full command ssh user@host "cd /path && command" should be executed as written.
Error Messages/Logs
No error from Claude Code itself — the wrong command runs silently. The SSH target returns an error because the working directory is wrong, e.g.: fatal: not a git repository (or any of the parent directories): .git
Steps to Reproduce
- Ask Claude to SSH into a remote machine and run a command that requires a directory change, e.g. "pull the latest code on the remote machine"
- Observe that Claude generates ssh user@host "cd /path && git pull" in its reasoning/description
- Check the actual Bash tool call command parameter — it will be ssh user@host "git pull" with cd /path && missing
- The command fails because the remote shell is not in the expected directory
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.81 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Workaround:
Using ; instead of && works correctly:
ssh user@host "cd /path ; git pull"
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗