Rule: When handing shell commands to Rich’s WSL terminal for paste-and-execute, prefer one-command-per-line short enough not to wrap visually (~80 chars max). Avoid:
- Heredocs (
<< 'EOF' ... EOF) — terminal narrow-width injects whitespace into the EOF terminator, breaking the heredoc; pasted Python heredocs especially fail because the PYEOF marker doesn’t survive the paste round-trip. - For-loops on a single line with
; do ... ; donebody — when the loop’s URL list or argument list visually wraps onto a new line, real newlines get injected and the for-loop becomes syntactically invalid. - Compound
&&-chains with quoted SQL/JSON in-carguments — the quoted string can wrap mid-string and the shell sees a newline inside the literal, splitting the-cargument from its value. - Multi-line bash blocks with continuation backslashes (
\) — terminals sometimes preserve the visual newline AND the backslash, leading to syntax errors.
Why: Per three paste-mangling failures observed on 2026-05-02 BST, all in the same session:
| # | Command shape | Failure mode | Recovery |
|---|---|---|---|
| 1 | `… ~/tools/inherit-spike-env/bin/sssom\n —version 2>&1 | head -1 …(multi-line&&`-chain with backslash continuation) | Terminal split arguments mid-line: https://github.com/buffalo-mfg-works/AM-C\nDM-Ontology-Map became 2 separate command lines |
| 2 | for iri in "url1" "url2" "url3"; do code=$(...); echo "..."; done (for-loop on single line) | Terminal wrapped after "url1" and inserted real newline before "url2"; bash saw bare URL token outside loop and parsed as syntax error | Removed for-loop; checked URLs individually instead |
| 3 | psql -d inherit_spike_s29 -c\n "CREATE EXTENSION..." (-c arg followed by visually-wrapped quoted SQL) | Terminal wrapped after -c and injected newline; bash saw -c with no argument; quoted SQL was parsed as a separate command | Split into 2 commands: provisioning then verify |
How to apply:
-
For VERIFICATION commands: prefer one short single-line command per line (each fits in <80 chars). Multiple commands → multiple separate paste blocks, with explicit instruction “paste each separately, on its own line”.
-
For COMPLEX scripts that genuinely need multi-line: write to
/tmp/script.shvia single-quoted printf one-line-at-a-time, thenbash /tmp/script.sh. Example pattern:printf 'echo line-1\necho line-2\nfor x in a b c; do echo $x; done\n' > /tmp/script.sh && bash /tmp/script.shThe printf single-line transmission survives terminal wrapping; the
\nliteral escape in the single-quoted string becomes real newlines INSIDE the script file, where they’re safe. -
For commands that need a SQL or JSON literal: prefer dollar-quoted PostgreSQL strings (
$$...$$) or escaped JSON ('\''for single-quote escape) to avoid nested-quote ambiguity. Better: write the SQL to a.sqlfile and run viapsql -f /tmp/q.sql. -
For LOOPS over a small fixed list: unroll the loop into N separate command lines. 3-iteration loop is rarely worth the for-loop syntax cost when paste-safety is the constraint.
-
At command-emit time: count the rendered chars of the longest single line. If >80, refactor before emitting. The sub-rule under
feedback_test_theories_immediately_when_tabledapplies: even paste-safety is a kind of theory-test for the channel itself; test the command shape before handing off. -
In subagent prompts that hand off commands to Rich: include this memory’s name in the prompt’s discipline list so the subagent applies the rule consistently.
Boundary tests (when this rule fires STRONGLY):
- ✓ Emitting an
&&-chained verify command with multipleechoheaders + tool invocations - ✓ Emitting a for-loop over URLs / IRIs / paths
- ✓ Emitting a heredoc-based file-write
- ✓ Emitting Postgres / MySQL
-cSQL with quoted strings - ✓ Emitting Python one-liners with quoted module imports + print statements
Boundary tests (when this rule does NOT apply):
- ✓ Commands Claude Code runs directly via the Bash tool (the Bash tool doesn’t go through terminal width-wrapping; this rule is specifically for paste-to-Rich’s-terminal handoffs)
- ✓ Commands written to a file Rich reads (e.g.,
BUILD-PLAN.mdinstructions; these aren’t pasted as commands, they’re read as text) - ✓ One-line commands ≤80 chars (no risk of wrap)
Codification trigger: Three paste-mangling failures observed on 2026-05-02 BST in the ε.ι derisking spike session, all in the same ~3-hour window. Each failed in a different way (multi-line backslash-continuation; single-line for-loop; compound -c with quoted SQL) — the failure modes ARE distinct, but the underlying cause (terminal width wrap injecting newlines) is the same. Three instances in one session is enough signal to codify rather than treat each as a one-off paste defect.
Forward integration:
- Refined-prompt v3.6 → v3.7 candidate: add Step under Software-install-handoff section: “PASTE-SAFETY: emit one-command-per-line short enough not to wrap; for complex scripts use printf-to-file + bash-script-file pattern”.
- This memory is referenced from
feedback_kill_condition_maturity_vocabulary_v3_7_consolidated.mdCandidate 6 (plan-file URL/IRI/filename verification pass) as a sibling discipline.
Related memories:
feedback_test_theories_immediately_when_tabled.md— paste-safety is a kind of theory-test for the channel itself; test the command shape before handing offfeedback_logging_contract_closure_within_same_session.md— paste-safety failures are loud + immediate (Rich pastes back the broken output) so they don’t accumulate as silent decision-debt the way untested theories dofeedback_kill_condition_maturity_vocabulary_v3_7_consolidated.md— sibling consolidation memory; references this memory under Candidate 6