github-openapi-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub REST API Skill
GitHub REST API Skill
Use this skill to run GitHub REST API operations through + OpenAPI.
uxcReuse the skill for shared execution, auth, and error-handling guidance.
uxc使用该Skill通过 + OpenAPI执行GitHub REST API操作。
uxc复用 Skill以获取共享的执行、授权和错误处理指引。
uxcPrerequisites
前提条件
- is installed and available in
uxc.PATH - is installed and already authenticated with
gh.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
ghuxc推荐方式:将本地gh
认证信息导入uxc
ghuxcImport the current GitHub CLI token into a local bearer credential and create a standard GitHub API binding:
uxcbash
uxc auth credential import github --from ghThis 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令牌导入本地的Bearer凭证,并创建标准GitHub API绑定:
uxcbash
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/uxcOptional Path: Manual bearer token
可选方式:手动配置Bearer令牌
If is unavailable, configure a PAT manually:
ghbash
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 100Do not commit GitHub tokens or hardcode them in this skill or repository.
若不可用,可手动配置PAT(个人访问令牌):
ghbash
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
核心工作流
-
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
-
Inspect operation schema first:
github-openapi-cli get:/user -hgithub-openapi-cli get:/repos/{owner}/{repo} -hgithub-openapi-cli get:/repos/{owner}/{repo}/issues -h
-
Execute reads before writes:
github-openapi-cli get:/usergithub-openapi-cli get:/repos/{owner}/{repo} owner=holon-run repo=uxcgithub-openapi-cli get:/repos/{owner}/{repo}/issues owner=holon-run repo=uxc state=open per_page=10github-openapi-cli get:/repos/{owner}/{repo}/pulls owner=holon-run repo=uxc state=open per_page=10
-
Treat mutations as explicit-confirmation operations:
github-openapi-cli post:/repos/{owner}/{repo}/issues '{"owner":"holon-run","repo":"uxc","title":"Example issue"}'
-
默认使用固定链接命令:
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
-
先检查操作schema:
github-openapi-cli get:/user -hgithub-openapi-cli get:/repos/{owner}/{repo} -hgithub-openapi-cli get:/repos/{owner}/{repo}/issues -h
-
先执行读操作再执行写操作:
github-openapi-cli get:/usergithub-openapi-cli get:/repos/{owner}/{repo} owner=holon-run repo=uxcgithub-openapi-cli get:/repos/{owner}/{repo}/issues owner=holon-run repo=uxc state=open per_page=10github-openapi-cli get:/repos/{owner}/{repo}/pulls owner=holon-run repo=uxc state=open per_page=10
-
将变更操作视为需明确确认的操作:
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 - is equivalent to
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> ... - 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