MUST USE for ANY GitHub work - instead of the gh CLI, gh api, curl to api.github.com, or a browser. Pull requests (view, create, edit, review, comment, merge, checks, diff, files), waiting for CI, issues, Actions runs and failed-job logs, workflow dispatch, releases, search, raw REST/GraphQL, and repository setup (create a repo, description, topics, README, labels, secrets, rulesets and branch protection, workflow files), through a typed Bun SDK for eval cells plus a CLI and MCP. Local commit...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Github?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/code-yeongyu-github)
---
name: github
description: "MUST USE for ANY GitHub work - instead of the gh CLI, gh api, curl to api.github.com, or a browser. Pull requests (view, create, edit, review, comment, merge, checks, diff, files), waiting for CI, issues, Actions runs and failed-job logs, workflow dispatch, releases, search, raw REST/GraphQL, and repository setup (create a repo, description, topics, README, labels, secrets, rulesets and branch protection, workflow files), through a typed Bun SDK for eval cells plus a CLI and MCP. Local commits, rebases and history belong to the `git` skill. Triggers: GitHub, PR, pull request, issue, CI, checks, Actions, workflow run, release, gh, gh pr, gh api, gh run watch, gh repo create, gh secret set, 'is CI green', 'wait for CI', 'open a PR', 'merge the PR', 'why did the workflow fail', 'comment on the issue', 'make a new repo', 'protect the branch', 'set the topics'."
---
# GitHub
Typed GitHub operations that replace `gh` subprocesses: trimmed JSON, pagination followed, failures carry a `kind`.
Replace `<skill-root>` with this skill's own directory.
```js
const { client, surface } = await import("<skill-root>/scripts/sdk.ts")
const pr = await client.pr.view({ repo: "owner/name", number: 123 })
```
## Rules
1. **PASS `repo: "owner/name"` IN EVERY EVAL-CELL CALL.** When omitted it falls back to the git origin of the process cwd, and an eval kernel's cwd is rarely the repo you mean.
2. **NEVER READ `scripts/src` TO LEARN AN OPERATION.** Its inputs are one expression away: `surface.ops.issue.list.input.json` (JSON Schema) and `.description`. Every list returns `{ ...scope, items, truncated }`: `items` is always an array, and `truncated` means matching rows were left out or GitHub marked the search incomplete. Scope fields like `repo`, `owner`, or `number` depend on the operation.
3. **NEVER MERGE WITHOUT `matchHeadSha`.** Read `pr.view` (`mergeState`, `reviewDecision`, `headSha`) and `pr.checks`, then call `pr.merge({ matchHeadSha })`. A head that moved after you verified it then refuses with kind `conflict` instead of landing commits nobody checked.
4. **NEVER POLL CHECKS OR SLEEP FOR CI.** Use `await client.pr.wait(...)` or `run.wait(...)` for waits under about 4 minutes. A longer wait runs as a `tool.monitor` command: **READ [references/waiting.md](references/waiting.md) BEFORE ARMING ONE.**
5. **A WRITE THAT FAILS WITH `server` OR `network` MAY HAVE LANDED.** Writes are never retried for you. Read the target back (`issue.view({ comments: 3 })`, `pr.view`) before sending it again, or you post it twice.
6. **BEFORE CREATING OR CONFIGURING A REPO, READ THE REFERENCE FOR THAT STEP.** Creating one, description, topics, README, merge options, labels, secrets: [references/repo-setup.md](references/repo-setup.md). Rulesets and branch protection: [references/branch-rules.md](references/branch-rules.md). Workflow files and action pins: [references/workflows.md](references/workflows.md).
7. **CHANGE REPO SETTINGS ONLY WHERE THE TASK OWNS THE REPO.** Visibility, rulesets, secrets, Actions and merge options on a shared repo are the owner's call: read and report, write on their word.
8. **PR BODY SCREENSHOTS GO THROUGH GITHUB USER ATTACHMENTS ONLY.** Never commit temporary images, never use Releases or an external host: [references/evidence-attachments.md](references/evidence-attachments.md).
## Pull requests, issues, runs
| gh habit | Operation | What to know |
|---|---|---|
| `gh pr view` | `pr.view` | `state`, `draft`, `merged`, `mergeCommit`, `mergedBy`, `autoMerge`, `mergeable`, `mergeState`, `reviewDecision`, `headSha`, `baseSha`, `checks` (rollup), `closes`; `comments: N` / `commits: N` add the latest N; `body: false` trims |
| `gh pr checks` | `pr.checks` | each check has `bucket` (pass, fail, pending, skipping, cancel), `required`, `runId`; plus `counts`; `only: ["fail"]` filters |
| `gh pr checks --watch` | `pr.wait` | returns `verdict` pass, fail, timeout, no_checks or head_moved |
| `gh pr list`, `gh pr status` | `pr.list`, `pr.status` | items carry `headSha`, `baseSha`, `state: "merged"`, `mergedAt`, `mergeCommit`; `truncated` says the limit cut the list; `author`, `label`, `search` and merged-only also return `total` |
| `gh pr diff` | `pr.files`, `pr.diff` | read `files` first; `diff` is capped by `maxBytes` |
| `gh pr create / edit / comment / ready / close / reopen` | `pr.create` `pr.edit` `pr.comment` `pr.ready` `pr.close` | `comment.editId` replaces a comment; `ready.undo` turns it back into a draft; reopen is `edit({ state: "open" })` |
| `gh pr review / update-branch / revert / lock / unlock` | `pr.review` `pr.updateBranch` `pr.revert` `pr.lock` `pr.unlock` | `review.comments` puts comments on lines of the diff; `updateBranch.expectedHeadSha` refuses a moved head with kind `conflict` |
| review feedback (gh has no command) | `pr.reviews` `pr.replyToThread` `pr.resolveThread` `pr.dismissReview` | `reviews` returns review bodies and line threads with `resolved` and `outdated`; `unresolvedOnly: true` is the list still to handle; reply first, then resolve |
| `gh pr checkout` | `pr.checkout` | runs git in the `dir` you pass |
| `gh pr merge`, `--admin` | `pr.merge` | rule 3, with the full 40-character SHA; without `method`, the first the repository allows; it calls the merge endpoint directly, so the token's bypass rights apply as with `--admin`; `auto: true` enables auto-merge (or merges now if it already can); a failed branch delete after the merge is `branchDeleteError`, never a throw |
| `gh issue view / list / status / create / edit / comment / close / reopen` | `issue.view` `issue.list` `issue.status` `issue.create` `issue.edit` `issue.comment` `issue.close` | `list` excludes PRs and sorts by update; `close` takes `reason` and a `comment`; reopen is `edit({ state: "open" })` |
| `gh issue pin / unpin / lock / unlock / transfer / develop / delete` | `issue.pin` `issue.unpin` `issue.lock` `issue.unlock` `issue.transfer` `issue.develop` `issue.delete` | `develop` lists or creates a linked branch; `delete` cannot be undone |
| `gh run list / view` | `run.list` `run.view` | filter by `workflow`, `branch`, `sha`, `status`; `view` names the failed steps |
| `gh run view --log-failed`, `--log`, `--job`, `--attempt` | `run.logs`, `run.job` | `run.logs` returns one entry per job in `items`: failed jobs by default, `allJobs`, `jobId` (any job), `attempt`, `step` (number from `run.job`, or part of a name); `tail` (150), `head`, `full`, `maxBytes`; `output: <dir>` writes `<jobId>.log` files; an unavailable log is that job's `error`, and no matching job gives a `note`; the raw tail is runner cleanup, so pass `grep: "##\\[error\\]"` for the cause |
| `gh run watch` | `run.wait` | returns the conclusion with failed jobs and steps |
| `gh run rerun / cancel / delete / download` | `run.rerun` `run.cancel` `run.delete` `run.download` | cancel only runs you started; `download` unpacks artifacts into `dir` |
| `gh workflow run / list / view / enable / disable` | `run.dispatch` `workflow.list` `workflow.view` `workflow.enable` `workflow.disable` | |
| `gh cache list / delete` | `cache.list` `cache.delete` | |
| `gh api repos/{o}/{r}/commits/{ref}`, `.../commits` | `commit.view`, `commit.list` | `view` gives files and stats (`patch: true` adds patches); `list` takes `ref`, `path`, `author`, `since`, `until` |
| `gh api .../commits/{ref}/status`, `.../check-runs` | `commit.status`, `commit.checks` | for any ref, not only a PR head; `checks` items carry `id` and `output` |
| `gh api .../check-runs/{id}/annotations` | `check.annotations` | `path`, `startLine`, `level`, `message`: where a failure is |
## Repositories and everything else
| gh habit | Operation | What to know |
|---|---|---|
| `gh repo view / list` | `repo.view` `repo.list` | |
| `gh repo create / edit / rename / archive / unarchive / fork / sync` | `repo.create` `repo.edit` `repo.rename` `repo.archive` `repo.unarchive` `repo.fork` `repo.sync` | rules 6 and 7; `create` and `fork` are API-only, with no clone or push; `edit` takes `addTopics` / `removeTopics` |
| `gh repo delete` | `repo.delete` | cannot be undone; `confirm` must equal `owner/name`; needs the `delete_repo` scope |
| `gh repo read-file / read-dir`, `gh browse -n`, `gh repo clone` | `repo.readFile` `repo.readDir` `repo.url` `repo.clone` | `clone` runs git into the `dir` you pass |
| `gh repo autolink / deploy-key / gitignore / license` | `repo.autolink.*` `repo.deployKey.*` `repo.gitignore.*` `repo.license.*` | |
| `gh ruleset list / view / check` | `ruleset.list` `ruleset.view` `ruleset.check` | plus `ruleset.create` `ruleset.edit` `ruleset.delete` and `branchProtection.view` `.set` `.delete`, which gh lacks |
| `gh release list / view` | `release.list` `release.view` | no `tag` means the latest |
| `gh release create / edit / upload / download / delete / delete-asset` | `release.create` `release.edit` `release.upload` `release.download` `release.delete` `release.deleteAsset` | `files` is a list of `{ path }` for local files |
| `gh label list / create / edit / delete / clone` | `label.*` | |
| `gh secret list / set / delete` | `secret.*` | `env`, `org` or `user` scope; the value is sealed on this machine and never returned; never type it into cell code, and on the CLI it is taken only through `--input <file|->`, never as a flag |
| `gh variable list / get / set / delete` | `variable.*` | |
| `gh gist *` | `gist.list` `gist.view` `gist.create` `gist.edit` `gist.rename` `gist.delete` `gist.clone` | |
| `gh project *` | `project.*` | addressed by `owner` and `number`; needs the `project` scope |
| `gh discussion *` | `discussion.*` | |
| `gh codespace list / view / create / edit / stop / delete` | `codespace.*` | needs the `codespace` scope |
| `gh ssh-key *`, `gh gpg-key *` | `sshKey.*` `gpgKey.*` | writes need `admin:public_key` / `admin:gpg_key` |
| `gh attestation download` | `attestation.list` | fetches attestations; it does not verify them |
| `gh search issues / prs / code / repos / commits` | `search.issues` `search.code` `search.repos` `search.commits` | `search.issues` takes `type: "pr"` or `"issue"` |
| `gh status`, `gh org list`, `gh auth status` | `status` `org.list` `auth.status` | `auth.status` shows the login, the token's scopes and where the token came from, never the token |
| `gh api`, `gh api graphql`, `gh api rate_limit` | `api.rest` `api.graphql` `api.rate` | only when no typed operation fits; `query` values may be numbers and booleans; `paginate` returns `{ items, key, truncated }` and finds the list in a wrapped page itself; a download (job log, artifact, tarball) comes back as `{ text }` or, with `output`, is written to that file |
| `gh api .../branches`, `.../git/refs`, `.../tags` | `branch.list/view/create/delete`, `tag.list/view/create/delete` | `list` takes `prefix`; `create` takes `from` (SHA, branch or tag); `delete` needs `confirm` equal to the name |
| `gh api .../compare/{base}...{head}` | `repo.compare` | `status`, `ahead`, `behind`, `mergeBase`, `commits`, `files` |
| `gh api .../issues/{n}/comments`, `.../issues/comments/{id}` | `issue.comments`, `comment.view`, `comment.delete` | `issue.comments` lists every comment with ids (`since`, `truncated`); edit by id with `issue.comment({ editId })` |
**No operation, by design:** `gh auth login/logout/refresh/switch/setup-git/token`, `alias`, `completion`, `config`, `extension`, `repo set-default`, `skill`, `copilot`, `agent-task`, the interactive `codespace ssh/cp/code/jupyter/ports/logs/rebuild`, and the Sigstore checks (`attestation verify`, `release verify`, `release verify-asset`). Those run on the gh CLI itself.
## Errors
Every failure is a `SurfaceError` with a `kind` and a `hint`. Branch on `kind`, never on message text.
- `conflict`: not mergeable, or the head moved. Re-read `pr.view`; **DO NOT RETRY**.
- `not_found`: also what a private repo answers when the token cannot see it.
- `forbidden`: the token lacks a scope (`auth.status` lists them), or the plan does not offer the feature.
- `rate_limited`: the hint gives the reset time. Waits of 60 s or less already happen for you.
- `usage`: the input failed its schema and nothing was sent.
- `git`: a local git command that an operation ran (`pr.checkout`, `repo.clone`) exited non-zero.
## Other surfaces
- Auth needs no setup: `GH_TOKEN`, then `GITHUB_TOKEN`, then the existing gh login. With one of the two variables set, nothing here needs the gh CLI installed: `repo.clone`, `pr.checkout` and `gist.clone` hand the same token to git through the child's environment, never through argv, the remote URL or `.git/config`.
- A token kept elsewhere (a vault, a secret manager): `createClient({ token: () => Promise.resolve(value) })` from `sdk.ts` uses that provider instead, with no gh and no token variable needed, and `auth.status` reports it as `injected`. The transport calls the provider on every request, so memoize it rather than reading the vault each time.
- Shell: `bun <skill-root>/scripts/cli.ts pr checks --repo o/n --number 123`, with `--help` at any level. `--pick a,b.c` prints only those fields (each item of a list), like `gh --jq`; any text field reads from a file or stdin with `--<field>-file <path|->` (`--body-file notes.md`), like `gh --body-file`.
- MCP: `cli.ts mcp` (stdio); `--read-only` drops every writer. `--http` serves loopback only and needs `--token-env NAME`: every request must carry that bearer token.
## Rare areas: through `api.rest`
These have no typed operation because agents almost never need them; call `api.rest` with the route (and `paginate: true` for lists). On the CLI, `--pick` cuts the answer like `gh --jq`.
| Area | Route |
|---|---|
| Rule suites and ruleset history | `repos/{o}/{r}/rulesets/rule-suites`, `repos/{o}/{r}/rulesets/{id}/history` |
| Custom properties | `repos/{o}/{r}/properties/values`, `orgs/{org}/properties/schema` |
| Traffic and insights | `repos/{o}/{r}/traffic/views`, `.../traffic/clones`, `.../traffic/popular/paths` |
| Pages | `repos/{o}/{r}/pages`, `repos/{o}/{r}/pages/builds/latest` |
| Packages | `orgs/{org}/packages?package_type=container`, `.../packages/{type}/{name}/versions` |
| Actions runners, runner groups, permissions, OIDC | `repos/{o}/{r}/actions/runners`, `orgs/{org}/actions/runner-groups`, `repos/{o}/{r}/actions/permissions`, `repos/{o}/{r}/actions/oidc/customization/sub` |
| Interaction limits | `repos/{o}/{r}/interaction-limits` |
| Gist comments, forks, stars | `gists/{id}/comments`, `gists/{id}/forks`, `PUT gists/{id}/star` |
| Project views, status updates, iteration fields | `api.graphql` on `ProjectV2` (`views`, `statusUpdates`, `ProjectV2IterationField`) |
| Code quality findings, Copilot assignment and spaces | `api.graphql` / `api.rest` per the GitHub docs; preview APIs change often |
| Audit log and billing | `orgs/{org}/audit-log`, `orgs/{org}/settings/billing/usage` (org owner token) |
| SSH certificate authorities, migrations and imports | `orgs/{org}/ssh-certificate-authorities`, `orgs/{org}/migrations` |
Not supported: GitHub Enterprise Server (the API and git host are github.com), Sigstore verification and opening a browser (use the gh CLI, or return the URL from `repo.url`), LFS and wikis (git operations, outside the API).
Every request sends `X-GitHub-Api-Version: 2022-11-28`, supported until 2028-03-10. Moving to `2026-03-10` is a planned migration, not a header bump: it removes `merge_commit_sha` from pull request responses (read by `pr.list`), the singular `assignee`, and changes `run.dispatch` and attestation responses.