$ recombobulate _
home / tips / pass-multiline-prompts-to-claude-code-with-shell-heredocs
0

Pass Multiline Prompts to Claude Code with Shell HEREDOCs

bagwaa @bagwaa · Mar 26, 2026 · Prompting
pass-multiline-prompts-to-claude-code-with-shell-heredocs

When you're scripting with claude --print, trying to cram a multi-point prompt into a single quoted string gets ugly fast. Shell HEREDOCs give you clean, readable multi-line prompts with no escaping.

claude --print << 'EOF'
Review the following code for:
1. Security vulnerabilities
2. Performance bottlenecks
3. Missing error handling

Respond with a bullet list for each category.
EOF

Single-quoting the delimiter ('EOF') prevents the shell from expanding variables inside the HEREDOC — useful when your prompt contains dollar signs or backticks. Drop the quotes when you want variable interpolation:

FILE="src/auth/middleware.ts"
CONTEXT="This is a financial application handling PII data."

claude --print << EOF
Context: $CONTEXT

Review $(basename $FILE) for security issues only.
Be brief — one sentence per issue.

$(cat $FILE)
EOF

This pattern works well in Makefiles too:

review:
	@claude --print << 'EOF'
	Summarise what changed in the last 5 commits and flag anything risky.
	$(shell git log --oneline -5)
	EOF

HEREDOCs make Claude automation scripts dramatically more readable than escaped single-liners.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Ask Claude to Scaffold New Features Using Your Existing Code Conventions

Before asking Claude to scaffold a new feature, point it at your existing code first — it will match your naming, structure, error handling, and test patterns exactly rather than defaulting to framework boilerplate.

bagwaa @bagwaa · 2 hours ago
0
Describe the Entire Feature in Plain English Before Claude Starts Building

Give Claude the full picture upfront before it writes any code, so it builds the right thing the first time with fewer correction rounds.

bagwaa @bagwaa · 3 hours ago
0
Structure Complex Prompts Faster by Speaking Them Aloud

Long multi-step prompts with lots of context are harder to type than to speak — your brain can narrate relationships and constraints faster than your fingers can type them.

bagwaa @bagwaa · 7 hours ago