用途:ghx 是一份共享指导,规范在 GitHub issue、pull request 和 review 工作流中直接使用 gh 与 gh api 的方式,强调安全命令模式、载荷处理以及常见的采集与发布配方。它仅提供指导,不包含脚本、包装器或可执行入口。
适用场景:需要直接用 gh 从 GitHub 采集 issue 或 PR 上下文;安全地发布 PR 正文、issue 评论或 review 回复;寻找可复用的 GitHub CLI 模式而不依赖仓库本地脚本;在多个技能间统一 GitHub CLI 安全规则。不适用于:作为命令或可执行工具使用;需要 Holon 运行时内部机制而非 GitHub CLI 指导的任务;替代 github-review、github-pr-fix 或 github-issue-solve 中的任务特定逻辑。
前提条件:需要 gh CLI 认证;GITHUB_TOKEN 或 GH_TOKEN 需具备目标仓库操作所需的作用域;需要结构化过滤或 JSON 后处理时建议使用 jq。
安全规则:不要在命令行内联大型 markdown 或 JSON 载荷,长正文一律通过文件传递,例如 gh issue create --body-file <file>、gh issue comment --body-file <file>、gh pr create --body-file <file>、gh pr edit --body-file <file>;仅在 stdin 明确可用且有意为之时才使用 --body-file -。复杂请求体优先使用 gh api --input <file>;传递多个标量字段时优先重复使用 -f key=value,而非手工拼接 shell 字符串。
常用配方:采集 issue 上下文可用 gh issue view 123 --repo owner/repo --json number,title,body,state,url,author,createdAt,updatedAt,labels 与 gh api repos/owner/repo/issues/123/comments --paginate;采集 PR 上下文可用 gh pr view 123 --repo owner/repo --json ...、gh pr view 123 --repo owner/repo --json files、gh pr diff 123 --repo owner/repo,以及 gh api graphql 查询 reviewThreads;创建或更新 PR 可用 gh pr create --repo owner/repo --title "Title" --body-file /tmp/pr-body.md --head feature/x --base main 与 gh pr edit 123 --repo owner/repo --title "Updated title" --body-file /tmp/pr-body.md;发布 PR 级评论可用 gh api repos/owner/repo/issues/123/comments -X POST --input /tmp/comment.json;回复 review 评论可用 gh api repos/owner/repo/pulls/123/comments -X POST -F in_reply_to=456789 -f body='Thanks, fixed in the latest commit.';发布带行内评论的 review 时,使用 gh api 配合 JSON 载荷文件,使正文与行内评论保持结构化、可复现。
注意事项:自动化中优先通过 --repo owner/repo 显式指定仓库;后续步骤需要结构化数据时优先使用机器可读的 --json 输出;采集大量记录时记得对 REST 端点使用 --paginate。
限制:本技能为纯指导,不提供可执行代码;具体认证作用域、平台支持与收费信息暂未提供。