github-openapi-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub REST API Skill

GitHub REST API Skill

Use this skill to run GitHub REST API operations through
uxc
+ OpenAPI.
Reuse the
uxc
skill for shared execution, auth, and error-handling guidance.
使用该Skill通过
uxc
+ OpenAPI执行GitHub REST API操作。
复用
uxc
Skill以获取共享的执行、授权和错误处理指引。

Prerequisites

前提条件

  • uxc
    is installed and available in
    PATH
    .
  • gh
    is installed and already authenticated with
    gh auth login
    .
  • Network access to
    https://api.github.com
    .
  • Access to the official GitHub REST OpenAPI schema URL:
    • https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
  • 已安装
    uxc
    且其可在
    PATH
    中访问。
  • 已安装
    gh
    并通过
    gh auth login
    完成认证。
  • 能够访问
    https://api.github.com
    的网络环境。
  • 可访问官方GitHub REST OpenAPI schema的URL:
    • https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json

Authentication

认证

Preferred Path: Import local
gh
auth into
uxc

推荐方式:将本地
gh
认证信息导入
uxc

Import the current GitHub CLI token into a local
uxc
bearer credential and create a standard GitHub API binding:
bash
uxc auth credential import github --from gh
This creates:
  • credential:
    github
  • binding:
    github-api
  • bound host:
    https://api.github.com
Verify the binding:
bash
uxc auth binding match https://api.github.com/repos/holon-run/uxc
将当前GitHub CLI令牌导入本地
uxc
的Bearer凭证,并创建标准GitHub API绑定:
bash
uxc auth credential import github --from gh
此操作会创建:
  • 凭证:
    github
  • 绑定:
    github-api
  • 绑定主机:
    https://api.github.com
验证绑定:
bash
uxc auth binding match https://api.github.com/repos/holon-run/uxc

Optional Path: Manual bearer token

可选方式:手动配置Bearer令牌

If
gh
is unavailable, configure a PAT manually:
bash
uxc auth credential set github \
  --auth-type bearer \
  --secret-env GITHUB_TOKEN

uxc auth binding add \
  --id github-api \
  --host api.github.com \
  --path-prefix / \
  --scheme https \
  --credential github \
  --priority 100
Do not commit GitHub tokens or hardcode them in this skill or repository.
gh
不可用,可手动配置PAT(个人访问令牌):
bash
uxc auth credential set github \
  --auth-type bearer \
  --secret-env GITHUB_TOKEN

uxc auth binding add \
  --id github-api \
  --host api.github.com \
  --path-prefix / \
  --scheme https \
  --credential github \
  --priority 100
请勿将GitHub令牌提交到代码库,也不要在此Skill或仓库中硬编码令牌。

Core Workflow

核心工作流

  1. Use fixed link command by default:
    • command -v github-openapi-cli
    • If missing, create it:
      uxc link github-openapi-cli https://api.github.com --schema-url https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
    • github-openapi-cli -h
  2. Inspect operation schema first:
    • github-openapi-cli get:/user -h
    • github-openapi-cli get:/repos/{owner}/{repo} -h
    • github-openapi-cli get:/repos/{owner}/{repo}/issues -h
  3. Execute reads before writes:
    • github-openapi-cli get:/user
    • github-openapi-cli get:/repos/{owner}/{repo} owner=holon-run repo=uxc
    • github-openapi-cli get:/repos/{owner}/{repo}/issues owner=holon-run repo=uxc state=open per_page=10
    • github-openapi-cli get:/repos/{owner}/{repo}/pulls owner=holon-run repo=uxc state=open per_page=10
  4. Treat mutations as explicit-confirmation operations:
    • github-openapi-cli post:/repos/{owner}/{repo}/issues '{"owner":"holon-run","repo":"uxc","title":"Example issue"}'
  1. 默认使用固定链接命令:
    • command -v github-openapi-cli
    • 若不存在则创建:
      uxc link github-openapi-cli https://api.github.com --schema-url https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
    • github-openapi-cli -h
  2. 先检查操作schema:
    • github-openapi-cli get:/user -h
    • github-openapi-cli get:/repos/{owner}/{repo} -h
    • github-openapi-cli get:/repos/{owner}/{repo}/issues -h
  3. 先执行读操作再执行写操作:
    • github-openapi-cli get:/user
    • github-openapi-cli get:/repos/{owner}/{repo} owner=holon-run repo=uxc
    • github-openapi-cli get:/repos/{owner}/{repo}/issues owner=holon-run repo=uxc state=open per_page=10
    • github-openapi-cli get:/repos/{owner}/{repo}/pulls owner=holon-run repo=uxc state=open per_page=10
  4. 将变更操作视为需明确确认的操作:
    • github-openapi-cli post:/repos/{owner}/{repo}/issues '{"owner":"holon-run","repo":"uxc","title":"Example issue"}'

Guardrails

防护机制

  • Keep automation on JSON output envelope; do not use
    --text
    .
  • Parse stable fields first:
    ok
    ,
    kind
    ,
    protocol
    ,
    data
    ,
    error
    .
  • github-openapi-cli <operation> ...
    is equivalent to
    uxc https://api.github.com --schema-url https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json <operation> ...
    .
  • Prefer read operations before write operations.
  • Treat issue creation, issue edits, comments, labels, repo administration, releases, and workflow-trigger endpoints as write/high-risk operations; require explicit user confirmation before execution.
  • 自动化操作需基于JSON输出格式,请勿使用
    --text
    参数。
  • 优先解析稳定字段:
    ok
    kind
    protocol
    data
    error
  • github-openapi-cli <operation> ...
    等效于
    uxc https://api.github.com --schema-url https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json <operation> ...
  • 优先执行读操作,再执行写操作。
  • 将Issue创建、Issue编辑、评论、标签、仓库管理、发布和工作流触发等端点视为写入/高风险操作,执行前需用户明确确认。

References

参考资料

  • Usage patterns:
    references/usage-patterns.md
  • GitHub REST OpenAPI schema:
    https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
  • GitHub REST docs:
    https://docs.github.com/rest
  • 使用模式:
    references/usage-patterns.md
  • GitHub REST OpenAPI schema:
    https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
  • GitHub REST文档:
    https://docs.github.com/rest