github-cli-workarounds

仓库创建 2026年7月4日最近提交 22 天前SkillHot 收录 22 天前
▸ 精选理由

直接解决常见命令行陷阱,便于自动化脚本或代理可靠地创建 issues/PR/gist。

▸ 风险提示

不当拼接命令可能导致命令注入或意外执行,注意转义与校验。

这个 Skill 做什么

解决使用 gh 时遇到的 shell 转义与特殊字符插入问题的实用技巧。

在 shell 里用 GitHub CLI(gh)创建 issue/gist/PR 时,遇到含有 $、反引号、引号或多行正文导致的解析问题,这里给出实用对策。会教你如何用转义、here-doc、临时文件或 gh 的文件参数来避免变量展开与命令替换,保证内容原样提交。侧重可直接复制运行的命令级解决方案。

▸ 展开 SKILL.md 英文原文

Workarounds for shell escaping issues when using the GitHub CLI (`gh`) for creating issues, gists, and pull requests with content containing special characters like `$`, backticks, or quotes. Use when creating GitHub issues, gists, or pull requests where content contains `$variables`, backtick-enclosed code, or multi-line bodies that cause shell parsing errors.

开发编程GitHub CLIShell 转义命令行技巧通用
0
Stars
0
Forks
23
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/ceilidhboy/skills/master/skills/github-cli-workarounds/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/ceilidhboy/skills/master/skills/github-cli-workarounds/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# GitHub CLI Workarounds

## The Problem

When using `gh issue create --body "..."` or `gh gist create` with inline content, the shell interprets special characters:

- **`$variable`** — expanded as a shell variable (e.g., `$content`, `$images`)
- **Backticks `` ` ``** — interpreted as command substitution
- **Double quotes** — broken nesting with the shell's quoting

This causes `Syntax error: word unexpected` or truncated content.

## The Fix: Always Use Temp Files

### For Issues

Write the body to a temp file, then use `--body-file`:

```bash
cat > /tmp/gh-body.md << 'ISSUEBODY'
Content with $variables, `backticks`, and "quotes" works fine here.
ISSUEBODY

gh issue create --repo owner/re
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有