| name | gh-body-safe |
| description | Use when creating or editing GitHub PRs/issues/comments with `gh`; write markdown bodies to temp files and pass `--body-file` instead of inline `--body` to avoid shell quoting and markdown corruption across Windows, WSL2, and Linux. |
| version | 1.0.0 |
| author | Eric Hansen + Hermes Agent |
| license | MIT |
| metadata | {"hermes":{"tags":["github","gh","pull-requests","issues","shell","portability"],"related_skills":["github-pr-workflow","github-issues"]}} |
GitHub CLI Body-File Safety
Overview
Use temp files for any non-trivial GitHub CLI body. Inline --body strings are fragile: shell escaping, backticks, markdown fences, quotes, $ expansion, and Windows/PowerShell differences can silently corrupt PR or issue text.
Hermes usually runs bash on this Windows host, but the workflow must remain portable to WSL2 and Linux. --body-file is the portable default.
When to Use
Use for:
gh pr create
gh pr edit
gh issue create
gh issue edit
gh pr comment
- any
gh command with multi-line markdown content
Skip only for trivial one-line comments with no special characters.
Bash Pattern
body_file="$(mktemp)"
cat > "$body_file" <<'EOF'
- Change one
- Change two
- `pytest`
EOF
gh pr create \
--title "feat: concise title" \
--body-file "$body_file"
rm -f "$body_file"
Edit Existing PR
body_file="$(mktemp)"
cat > "$body_file" <<'EOF'
Explain the revised scope here.
EOF
gh pr edit 123 --body-file "$body_file"
rm -f "$body_file"
Common Pitfalls
- Do not use inline
--body for markdown fences, backticks, or multi-line content.
- Quote the heredoc delimiter as
<<'EOF' so shell variables are not expanded.
- Remove the temp file after the command succeeds or fails.
- If a GitHub operation fails unexpectedly, run
gh auth status before assuming the repo or PR is wrong.
Verification Checklist