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:

  1. 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.
  2. For-loops on a single line with ; do ... ; done body — 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.
  3. Compound &&-chains with quoted SQL/JSON in -c arguments — the quoted string can wrap mid-string and the shell sees a newline inside the literal, splitting the -c argument from its value.
  4. 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 shapeFailure modeRecovery
1`… ~/tools/inherit-spike-env/bin/sssom\n —version 2>&1head -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
2for 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 errorRemoved for-loop; checked URLs individually instead
3psql -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 commandSplit into 2 commands: provisioning then verify

How to apply:

  1. 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”.

  2. For COMPLEX scripts that genuinely need multi-line: write to /tmp/script.sh via single-quoted printf one-line-at-a-time, then bash /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.sh
    

    The printf single-line transmission survives terminal wrapping; the \n literal escape in the single-quoted string becomes real newlines INSIDE the script file, where they’re safe.

  3. 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 .sql file and run via psql -f /tmp/q.sql.

  4. 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.

  5. 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_tabled applies: even paste-safety is a kind of theory-test for the channel itself; test the command shape before handing off.

  6. 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 multiple echo headers + tool invocations
  • ✓ Emitting a for-loop over URLs / IRIs / paths
  • ✓ Emitting a heredoc-based file-write
  • ✓ Emitting Postgres / MySQL -c SQL 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.md instructions; 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.md Candidate 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 off
  • feedback_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 do
  • feedback_kill_condition_maturity_vocabulary_v3_7_consolidated.md — sibling consolidation memory; references this memory under Candidate 6