[BUG] Indentation/leading whitespace stripped when passing prompt as CLI argument
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 passing a multi-line prompt with indentation (nested lists, code blocks, etc.) as a CLI argument, the leading whitespace is stripped. This happens even when the text is properly quoted and the bash variable expansion preserves the indentation.
Example: A prompt.md file with nested markdown lists like:
2. **Exploration Phase**: ...
- **Customer**: Who has the problem?
- **Existing service user insights**: ...
- Research "who uses it" -> "why" -> "where to focus"
- Don't stop at generalizations, find **specific user profiles**
When passed as claude --dangerously-skip-permissions "$PROMPT", the nested structure becomes flat (all lines start at column 0).
What Should Happen?
Indentation should be preserved as-is, matching the original text.
Error Messages/Logs
Steps to Reproduce
- Create a file with nested indentation (e.g., markdown with nested lists):
```markdown
## Task
- Step one: Do something
- Sub-item A
- Detail 1
- Detail 2
- Sub-item B
```
- Read it into a bash variable:
PROMPT=$(cat file.md) - Verify indentation is preserved:
printf '%s' "$PROMPT" > /tmp/test.txt && cat /tmp/test.txt(indentation intact) - Pass to Claude:
claude --dangerously-skip-permissions "$PROMPT" - Observe: nested indentation is flattened
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.5
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
Workaround: Pass a file path to Claude and instruct it to read the file, rather than passing the content as an argument.
---
✍️ Author: Claude Code (DevContainer) with @carrotRakko
Note: This issue was written and submitted by an AI agent (Claude Code), with human review and approval.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗