Skip to content

skills(running-in-ci): cover nested fenced blocks in backtick-escape rule - #495

Merged
max-sixty merged 1 commit into
mainfrom
hourly/review-25913393886
May 15, 2026
Merged

max-sixty merged 1 commit into
mainfrom
hourly/review-25913393886

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Summary

Extend the existing <<'EOF' ... EOF backtick-escape rule to cover nested fenced code blocks. The current rule warns about escaping inline code spans (\`foo\`); the same single-quoted-heredoc mechanic also corrupts nested fences when the model defensively escapes the inner three-backtick fence (\`\`\`bash) to keep it from closing the outer fence. The fix is the standard markdown idiom: use a longer outer fence (four or five backticks) so the inner three-backtick fence renders intact without escaping.

Evidence

PRQL/prql#5900 (tend ci-fix: transient classifier ignores repeat occurrences, opened by prql-bot 2026-05-15T08:56:34Z). The body wraps a proposed skill addition in a ```markdown outer fence and contains an inner ```bash fence plus several inline code spans. The model escaped the inner fence and all inline backticks inside the inner section, producing visibly corrupted markdown — the rendered body shows \`\`\`bash, \`rustup-init\`, \`composer connect timeout\`, \`docker pull rate limit\`, \`gh issue search\`, and trailing \`\`\` (six distinct corrupted spans). Direct API spot-check:

$ gh api repos/PRQL/prql/issues/5900 --jq '.body' | grep -c '\\`'
6

This is the first such occurrence in the PRQL evidence gist's tracked corruption-scan history (prior ticks all reported backslash-backtick: clean); the evidence log for May 2026 records the scans.

Classification

  • Failure class: structural. The trigger is deterministic — a body composed in a single-quoted heredoc that contains a nested fenced block + the model's defensive instinct to escape the inner fence. Replayed, this produces the same corruption every time. The existing rule already classifies the inline-code-span variant as authored (not preprocessor-injected); the nested-fence variant is the same shape with a different originating model habit.
  • Evidence level: structural / 1 occurrence — sufficient under review-gates.md: "Structural: no decision point — the same conditions produce the same failure every time... One clear occurrence is sufficient evidence for a targeted fix."
  • Change magnitude: targeted fix — one sentence appended to an existing paragraph. Within the Gate-2 magnitude budget for structural-fix scope.

Change

plugins/tend-ci-runner/skills/running-in-ci/SKILL.md: extend the existing backtick-escape paragraph (already covering inline spans like \`foo\`) with a second sentence covering nested fenced blocks. Recommend a longer outer fence (four or five backticks outside, three inside) as the standard remedy. Adds a parenthetical noting that --body-file via the Write tool helps with delivery but not authoring — the model still has to author with bare backticks, since Write preserves data verbatim.

Notes

…rule

Extend the existing single-quoted-heredoc backtick-escape paragraph to
cover the nested-fence variant (model escapes the inner three-backtick
fence and inline spans inside it). Recommend a longer outer fence
(four or five backticks) as the standard remedy. Evidence: PRQL/prql#5900
shipped with six visible `\\`...\\`` spans in its body, the first
backslash-backtick corruption observed in PRQL's evidence gist history.
@tend-agent tend-agent added the claude-behavior Behavioral issues found by review-reviewers label May 15, 2026
@max-sixty
max-sixty merged commit 3d2afe6 into main May 15, 2026
4 checks passed
@max-sixty
max-sixty deleted the hourly/review-25913393886 branch May 15, 2026 17:10
max-sixty added a commit that referenced this pull request May 15, 2026
…unneeded guidance (#504)

## Bug

Linux Claude Code v2.1.142's bubblewrap-backed subprocess sandbox wraps
bash commands using the legacy `shell-quote` quote function with the
regex `/(["\\$`!])/g`, which escapes `!` to `\!` in any argv token that
mixes `'` with whitespace. That landed `\!=` in `jq` filters,
`assert\!()` in code references, `feat(api)\!:` in conventional-commit
titles, etc. The same binary contains a **fixed** `'\''`-wrap quoting
path for the macOS `sandbox-exec` route — both paths coexist, only the
Linux-bwrap path still uses the buggy quoter. See
[anthropics/claude-code#35701](anthropics/claude-code#35701)
(closed as stale; multiple duplicates closed since).

## Fix

1. **`action.yaml`**: set `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=0` on the
`claude-code-action` invocation. This disables the bwrap sandbox and
routes bash through the fixed `'\''`-wrap path. Trade-off: loses
subprocess env isolation. Applied at the composite-action level, so all
`max-sixty/tend@v1` consumers pick it up automatically once tagged.

2. **Skills**: with the bug worked around, the bang-trap guidance can
go. Removed across `triage`, `notifications`, `review-runs`,
`review-reviewers`, and `running-in-ci`:
- "Don't use `!` in comment body" / "use Write tool for bodies with `!`"
- `!=` rewrite warnings in `jq` recipes (and the awkward `(.status ==
"completed") | not` rephrase)
   - `--title-file` and `git commit -F` workarounds
   - `||` not `if !` rationale comments
   - `<<'EOF'`/`<<EOF` interpolation footgun warning

3. **Body composition**: standardized on Write tool + `--body-file` for
substantial PR/comment/gist bodies. Removed the inline `gh ... --body
"$(cat <<'EOF' ...)"` heredoc patterns from `review-reviewers`'s gist
seed and step summary and the line-wrap example in `running-in-ci`.
Write-tool composition is reviewable, sandbox-independent, and bypasses
the shell-quoting layer entirely.

## Kept on purpose

- **Backtick-in-heredoc paragraph** (extended via origin/main merge with
[#495](#495 nested-fence
guidance). This is a model authoring habit, *not* the shell-quote bug —
the workaround doesn't help. The paragraph now covers inline spans AND
nested fences, recommending longer outer fences for nesting and bare
backticks throughout.
- **Corruption-scan tripwires in `review-reviewers`** (`grep -nP '\\!'`
and `` grep -nP '\\\`' ``). If the workaround stops working — bug
returns upstream, env var override, the sandbox surface changes — the
scans catch it in the bot's own output.
- **`no-preprocessor-poison-in-skills` pre-commit hook**. Different bug
(slash-command preprocessor crashes on literal `` !` `` in plugin skill
`.md` files, regressed twice per #234/#243/#244), unrelated to the
Bash-tool rewrite.

## Validation posture

Workaround is empirically targeted: the bug reproduces in CI (bwrap
sandbox active), does not reproduce locally (`sandbox-exec` on the fixed
path), and the env-var docstring inside the binary explicitly documents
the opt-out. If a regression slips, `review-reviewers`'s `grep -nP
'\\!'` / `` grep -nP '\\\`' `` scans against the bot's own output fire
on the next run. Easy revert via `git revert <commit>` if anything
misbehaves.

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-behavior Behavioral issues found by review-reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants