github-ops
Operates GitHub through gh CLI and the REST/GraphQL APIs with explicit target, authorization, impact preview, and independent readback. Use for pull requests, issues, Actions, repositories, collaborators, teams, organization member privileges, base permissions, 2FA enforcement, repository settings, API automation, parallel or superseded PR convergence, and public or enterprise GitHub. Also use when a GitHub write returned success but the requested state did not change, or when deciding whether a setting is writable through CLI, REST, GraphQL, or only the GitHub UI.
1How It Works & Mechanism
Core Principle across the entire skill: Deliver the requested GitHub state, not just a command that looks successful—a 2xx response only proves GitHub accepted the request, not that the field actually changed, the invitation was accepted, the asynchronous job finished, or the business outcome was achieved.
Deliver the requested GitHub state, not a successful-looking command.
The main SKILL.md is strictly a 'hard contract + routing table': it dispatches tasks across 8 references by operational domain and requires loading only the single reference needed for the current task, avoiding an all-at-once load of the ~95KB knowledge base.
Read only the reference required for the task:
Step 1 classifies the request first (read-only / named state change / destructive, public, credential-bearing, production-triggering, or external communication); classification determines authorization scope and whether execution must pause before writing.
- **Answer, inspect, diagnose, or review:** read-only. Do not create a PR, issue,
Step 2 binds identity, host, and target before the first write: verify the active account first (--hostname HOST), then resolve the fully qualified target, enforcing an explicit HOST for multi-GitHub setups.
gh auth status --hostname HOST
Step 3 requires reading the GitHub hosted state (rather than stale local refs or memory) and explicitly producing a six-line impact preview before consequential writes: Target / Current / Requested / Blast radius / Recovery / Readback.
Blast radius: people, repositories, forks, runs, or public surfaces affected
Step 4 requires selecting an interface whose input contract genuinely supports the change, following a fixed precedence: dedicated gh subcommand → documented REST → GraphQL (GraphQL-exclusive or joined relational data only) → UI-only settings; the core trap is that 'response fields do not equal writable fields'.
Response fields are not automatically writable fields. Before using `PATCH`, compare
Step 5 enforces idempotency discipline: pin everything that can be pinned (repository/number/branch/run ID/username/expected SHA), and for non-idempotent writes, read back after a timeout or 5xx before deciding whether to resend.
- Do not blindly retry non-idempotent writes such as comments, invitations, workflow
Step 6 uses fresh readbacks that 'distrust mutation receipts and cached refs' for verification, providing a typed verification evidence table (PR merge / branch deletion / issue-comment-review / repo create-edit-visibility / collaborator & team permissions / org settings / 2FA / workflow / secret).
Run a fresh read that does not trust the mutation response or a cached local ref:
Step 7 closes out with one of four honest states: changed and verified / already satisfied / pending / failed-no-op or partial, requiring failure states to detail recovery paths and pending risks.
- **changed and verified** — requested state is independently observed;
High-risk boundaries are isolated into dedicated sections: repo creation requires explicit OWNER/REPO and visibility, visibility changes require consequence acknowledgement flags, and deletions/transfers/org-level permissions/2FA/secret rotations each follow a dedicated reference.
Repository visibility changes can expose code, Actions logs, artifacts, forks, and
Clear boundary with adjacent skills: local Git recovery (dirty worktrees, bundles, lost commits) belongs to git-safety-net; this skill exclusively owns GitHub hosted state.
This skill owns GitHub-hosted state.
High-risk operations are decoupled into dedicated reference workflows: repository transfer via REST is asynchronous (202 is only pending) and requires polling the new fully qualified name and re-auditing collaborators/teams/protection/Pages/secrets; deletions keep interactive exact-name confirmations and explicitly forbid --yes.
A `202 Accepted` is pending, not complete. Poll the new fully qualified name with a bounded deadline,
Organization-level changes also follow dedicated workflows: determine the source of effective permissions first (repository/team/base permission/org ownership/enterprise policy), evaluate UI-only fields, and only then proceed to writes; 2FA enforcement is treated as an org-wide access change rather than a simple checkbox.
Effective repository permission is the highest grant from repository, team,
Creating, commenting on, transferring, or closing issues is explicitly defined as an 'external action', requiring exact repository and content binding before execution; batch issue governance follows a freeze-list + per-item readback workflow.
Freeze and preview the exact issue set before any bulk write.
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| cli | gh (GitHub CLI) |
| cli | git |
| cli | jq |
| cli | curl(匿名只读回读) |
| cli | unzip(校验下载的运行日志归档) |
| api | GitHub REST API(经 gh api 调用) |
| api | GitHub GraphQL API(gh api graphql;gh pr/issue 列表子命令底层亦为 GraphQL) |
| network | GitHub Enterprise / 多实例主机(占位域名示例,实际由环境提供) |
| network | Webhook 投递目标(示例占位 URL;创建 hook 后仓库事件会持续外发到该地址) |
| network | 官方文档链接(被动引用,非程序化调用) |
4Recommended Governance & Evidence
- 外部端点: Exfiltrating local content or conversation sessions to third-party cloud storage
- 环境变量 / API Key: Reading vendor service credentials: zero scripts or credential-reading code within the skill directory; authentication relies entirely on the gh CLI's existing login state (original text: 'All API calls via `gh api` au')
- 本地工作目录: File I/O and artifact generation: GitHub hosted side (via gh/API): PR/issue create/edit/merge/close, comments and reviews, repository create/rename/archive/transfer/visibility/delete, collaborator and team permissions, etc.
5Second-Pass Verification
- [ok] external_deps 逐条反查调用点是否真实存在 — 10 条依赖全部在文件内定位到调用点:gh(SKILL.md 步骤 2 命令块与全篇)、git(pr_operations.md 的 'git rev-parse '<candidate>^{tree}'' 与远端分支退役小节的 '--force-with-lease="refs/heads/{branch/path}:$expected_sha"')、jq(best_practices.md 的 'gh api rate_limit --jq ...' 与多处 '| jq')、curl(workflow_operations.md 匿名回读两行)、unzip('unzip -tq RUN_ID.zip')、REST(api_reference.md 全篇 gh api repos/...)、GraphQL('gh api graphql -f query=')、企业主机(best_practices.md 的 'gh api --hostname github.example.com user --jq '.login'')、webhook 目标(api_reference.md 的 config[url]=https://example.com/webhook)、文档链接(api_reference.md 末尾三条 https 链接)。无虚构条目;也未漏登记第三方包——全目录不存在 package.json / requirements.txt / go.mod / Gemfile 等依赖清单。
- [ok] 文件清单 glob + git ls-files 全量核对 — github-ops/ 下恰好 9 个文件:SKILL.md + references/{api_reference,best_practices,branch_protection,issue_operations,organization_access_and_settings,pr_operations,repository_operations,workflow_operations}.md;无 scripts/、无模板/数据文件、无隐藏文件、无 symlink;find 与 git ls-files 结果一致;目录内无 LICENSE(LICENSE 在仓库根,MIT,Copyright (c) 2025 daymade,与固定取值相符)。工作副本 HEAD = d5c4678cb5d4fd6acc9c922690df035dbd33d247,与 pin 一致。
- [ok] 指令中记载的 gh 子命令与 flag 真实性核验(本机 gh 2.100.0) — 对 41 组子命令/flag 跑 gh <cmd> --help 校验,缺失 0:含 --accept-visibility-change-consequences、--match-head-commit、--auto/--squash/--rebase、--paginate/--slurp/--input/-X/-f/-F/-i、--hostname、--show-token、repo create --source/--remote/--internal、secret/variable/run/workflow 全族、issue pin/unpin/transfer、pr ready --undo、pr edit --add-project、run rerun --failed/--debug、run download --name/--dir、config set、repo set-default。--json 字段名另用负控验证('--json bogusfieldxyz' 报 'Unknown JSON field'),说明 gh 会先做客户端校验,本 skill 用到的 issue/pr/run/repo/workflow --json 字段集全部通过校验。
- [discrepancy] 安全结论反例①:是否有未登记的网络外发 — 发现两条第一遍未单独点名的外发路径,本稿已补登记:(a) curl 直连 api.github.com 的匿名回读(不是走 gh 的通道,用于运行历史清除验收);(b) 创建 webhook 后仓库事件会持续外发到 config[url] 指定地址(示例为 example.com 占位,替换为真实 URL 后即形成长期数据出口)。其余外发(gh/git/文档链接)与第一遍一致。混淆载荷反查:base64/eval/xxd/加密串在目录内零命中。
- [ok] 安全结论反例②:凭证读取/泄露面 — grep 'token|TOKEN|secret|SECRET|show-token|GH_TOKEN|env|api_key' 的全部命中均为纪律条款或 API 字段名,无一处读取、打印、写盘或作为参数内联:'Never use `gh auth status --show-token`'、'never inline or echo the value'、'keep secrets out of command arguments.'、'token literal in a command, document, process argument, log, or committed environment file.'、'Never copy another environment's credential as a fallback.'、'Use only that host's existing authorized login; do not copy tokens,'。gh secret set 走隐藏交互提示或 stdin 重定向,并明确 'GitHub intentionally does not return the secret value.'。
- [discrepancy] 安全结论反例③:是否有未声明的破坏性/绕过行为 — 两处需在展示层点名的能力(非漏洞):(a) workflow_operations.md 的 '## Purging Public Run History' 提供真实 DELETE(gh api -X DELETE 'repos/OWNER/REPO/actions/runs/RUN_ID' 与 deployment 删除),runs 不可恢复,文档要求先全量备份并匿名回读验收;(b) 同文件含 'gh secret delete SECRET_NAME'、gh variable delete、gh workflow disable 等可令生产流程停摆的操作。SKILL.md 的高危边界清单只列 '- Merges, branch deletions, repository creation/deletion/transfer/visibility changes,' 一行覆盖范围,未把「运行历史清除」纳入该清单(仅路由表以 purge 覆盖),属边界清单与 reference 能力的轻微不同步——用户需知晓删除历史同样不可逆。
- [ok] 实现原理是否夸大:description 声明 vs 实际文档能力 — description 列出的各域逐一有承载:PR(pr_operations.md)、issues(issue_operations.md)、Actions(workflow_operations.md)、repositories(repository_operations.md)、collaborators/teams/base permissions/2FA(organization_access_and_settings.md)、branch protection(branch_protection.md)、API automation 与 public/enterprise GitHub(api_reference.md + best_practices.md)、parallel or superseded PR convergence(pr_operations.md 收敛五步)、「write 返回成功但状态没变」(SKILL.md 第 4/6 步 + 组织设置的静默 no-op 节)、「某设置只能 CLI/REST/GraphQL/UI 哪种能改」(SKILL.md 第 4 步 + UI-only 小节)。七步契约标题在正文以 '### 1.'…'### 7.' 实际存在。反面检查:全文没有自动完成/保证成功式措辞,反而反复要求报 pending/failed/no-op,未夸大。
- [discrepancy] 内部一致性:小标题与内容、示例与边界清单是否自洽 — 一处小标题窄于内容:workflow_operations.md 的小节标题为 '### Managing Secrets (via API)',其下同时给出 gh api repos/{owner}/{repo}/actions/secrets(API)与 gh secret set/list/delete(gh CLI 子命令)——命令本身可执行,仅标题措辞与命令族不完全对应。另一处见上一条(路由表 purge vs 高危边界清单)。其余抽检一致:可见性变更在 SKILL.md 与 repository_operations.md 用同一旗标与读回要求;2FA 在 SKILL.md 验收表与 organization_access_and_settings.md 的流程互相对应。
6Verdict & Scenarios
95a92ed3207a5258…