Skip to content

fix: Claude fails to post review comment when markdown contains special characters #14

@Soumyadipgithub

Description

@Soumyadipgithub

Problem

When Claude generates a code review containing markdown formatting (code blocks, backticks, inline code), the gh pr comment --body "..." shell command breaks due to special character escaping. Claude retries multiple times with different formats, wastes API turns, and eventually posts a degraded plain-text version.

Evidence

PR: coloredcow-admin/coloredcow#1152
Workflow Run: Run 23399208437 (08:29 UTC, 22 March 2026)

What happened step by step

Claude generated a well-formatted review with markdown headers, code blocks, and backticks. Then tried to post it:

Attempt Command Result
1 gh pr comment --body "..." with escaped backticks Denied — shell parsing broke
2 Write to a temp file first DeniedWrite tool not in allowed-tools
3 cat << 'EOF' | gh pr comment --body-file - Denied — didn't match allowed-tools pattern
4 gh pr comment --body "..." with different escaping Denied — still broke
5 gh pr comment -b 'short plain text' Worked — but all formatting stripped

Impact

  • Review posted but degraded quality — no markdown, no code blocks, just a single paragraph
  • Cost $0.22 instead of ~$0.10 (26 turns instead of ~6) due to retries
  • Developer gets a less useful review

Comparison

What Claude wanted to post (from logs):

## Code Review Summary

### Critical Issues
None identified.

### Suggestions
**robots.txt:41** — Minor inconsistency...
**includes/ai-crawler-logger.php:145-147** — Inline styles...

What actually got posted (after 5 retries):

Code Review Summary - Critical Issues: None identified. - Suggestions: robots.txt:41 Minor bot name inconsistency. includes/ai-crawler-logger.php:145-147 Inline styles violate CLAUDE.md hard rule...

Root Cause

The prompt in claude-code-review.yml says:

"Create ONE single comment with your complete review"

But doesn't tell Claude how to post it safely. Claude defaults to gh pr comment --body "..." which breaks when the review contains backticks, code blocks, or other shell-special characters.

File Reference

  • .github/workflows/claude-code-review.yml — the prompt input default value
  • For More details, check this doc file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions