ColoredCow / ColoredCow/engineering-recipes
fix: Claude fails to post review comment when markdown contains special characters
- Dominant language
- Shell
- Stars
- 1
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
## 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](https://github.com/coloredcow-admin/coloredcow/pull/1152)
**Workflow Run:** [Run 23399208437 (08:29 UTC, 22 March 2026)](https://github.com/coloredcow-admin/coloredcow/actions/runs/23399208437)
### 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 | **Denied** — `Write` 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](https://docs.google.com/document/d/1nMY5In7WSbIvN0HZ-nnlhHlUWcsLQRQnteQTLXRM7gk/edit?tab=t.impait1nzi1n).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.