Files
magnus919_agent-skills/opensource-contributions/references/gh-pr-create-body-pitfall.md
T
Magnus Hedemark c5c4d2434a feat: add opensource-contributions skill
Comprehensive open source contribution guidance with progressive disclosure.
Restructured from a single ~23K-token monolithic SKILL.md into a concise
~1.2K-token orchestrator with 10 focused reference files.

Changes:
- SKILL.md: 1,720 lines → 100 lines (AgentSkills.io compliant frontmatter)
- 10 new reference files covering phases 0a-4, pitfalls, default posture
- Portable PR template compliance checker script (stdlib-only)
- All personal context scrubbed for public export
- AGENTS.md + README.md updated with trigger table entry

Signed-off-by: Magnus Hedemark <magnus919@pm.me>
2026-05-28 21:43:30 -04:00

1.3 KiB

gh pr create — body content shell expansion pitfall

Problem

When the PR body contains characters that the shell interprets (backticks, curly braces, JSON, $ variables), gh pr create --body "..." fails because the shell expands the content before passing it to gh.

Example: A body containing JSON-like text or backtick-wrapped inline code:

gh pr create --title "feat: add widget" --body '{"query": "test", "exclude_tags": ["vault:private"]}'

The shell interprets {}, [], and other special characters, causing gh to error with unknown argument or similar.

Fix: use --body-file

Write the body to a temporary file and pass it via --body-file:

cat > /tmp/pr-body.md << 'HEREDOC'
## Summary

## Changes

- 

## Related Issues

Closes #N

## Test Plan

- [ ]
HEREDOC

gh pr create --title "feat: ..." --body-file /tmp/pr-body.md --base main --head my-branch

The 'HEREDOC' (quoted) prevents shell expansion of the content. This works for any body content including JSON, backticks, and special characters.

When to use

Any PR body that contains:

  • JSON or code blocks with {}
  • Backtick-wrapped inline code
  • Curly braces or square brackets
  • Markdown with special characters

For plain-text bodies with no special characters, --body "..." is fine.