Escape Backticks in PR Descriptions Break Inline Code Formatting

Status Open
Maintainer reply None cached
Activity 0 comments · opened Oct 2, 2026

User Story

As a developer using Claude Code to open pull requests, I want inline code in PR descriptions to render as formatted code so that the descriptions are readable without manual cleanup.

Background

When Claude Code (model: Sonnet 5.5) writes a PR description through gh pr create --body, it sometimes backslash-escapes the backticks around inline code, producing \code\ in the body. GitHub treats the backslash as an escape, so the code span does not render. The PR shows literal backslashes and backticks instead of formatted code.

In one session, two PRs were created the same way and only one was affected:

  • Rendered correctly: Bare foo now prints help
  • Rendered incorrectly: \foo\ step fails on every pull request

Both were created via gh pr create --body "$(cat <<'EOF' ... EOF)". Inside a quoted heredoc (<<'EOF') the shell does not process escapes, so any backslash the model emits reaches GitHub unchanged. The model appears to apply escaping for a double-quoted shell context even when it is unnecessary.

This has been observed in two distinct sessions and is a regression: earlier models (Opus 5.5 and Sonnet 5) did not do this.

Impact: every affected PR description needs a manual edit, and the problem is easy to miss until the PR is already visible to reviewers.

Acceptance Criteria

  • [ ] PR descriptions created via gh pr create render inline code as formatted code, with no stray backslashes before backticks
  • [ ] The model does not backslash-escape backticks inside a quoted heredoc (<<'EOF'), where no shell expansion occurs
  • [ ] The same applies to gh pr edit --body, gh issue create --body, and commit messages passed through heredocs
  • [ ] A regression check covers the case: generating a PR body that contains inline code through each of the paths above yields a body with no \` sequences
  • [ ] Behavior on Sonnet 5.5 matches Opus 5.5 and Sonnet 5 on the same prompt

Technical Notes

  • Reproduction: ask Claude Code on Sonnet 5.5 to open a PR whose description references identifiers or flags in inline code, then inspect the result with gh pr view <n> --json body --jq .body | grep -F '\'`.
  • The behavior is intermittent, so a reliable check needs several runs.
  • Possible levers: system prompt guidance for the Bash tool's PR and commit examples (heredoc usage and quoting), and model-side handling of shell quoting for markdown payloads.

Out of Scope

  • Changing how GitHub renders markdown
  • Editing previously created PR descriptions
  • Other quoting issues that are not backtick escaping

View original on GitHub ↗