关于 github-bot
github-bot 是一项通过 GitHub App 身份及其安装令牌调用 GitHub API 的技能。它说明了身份验证、机器人署名、仓库操作和分页处理,适用于明确使用此集成的工作流。
主要功能
- 01生成短时效安装令牌
- 02发起经过身份验证的 GitHub API 调用
- 03以机器人身份标记操作
- 04执行仓库与拉取请求操作
- 05处理分页 API 列表
适用场景
- 01创建议题、拉取请求或发布
- 02读取或更新仓库资源
- 03获取分页接口中的全部结果
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ joelhooks/ joelclaw --skill github-bot安装后在 Claude Code 中输入/github-bot确认已加载。
附带文件scripts/github-token.sh
详细介绍
GitHub Bot
对于由 ShitRat 编写的工作,请使用已安装的 shitrat 工具和 shitratgit[bot] 身份。下方描述的旧版应用仅供明确拥有该应用的集成使用,不应作为 Joel 的 Agent 编写提交、PR 或评论时的默认身份。请确认实际的应用访问权限;旧的仓库数量不能作为依据。
通过 joelclawgithub[bot] GitHub App 与 GitHub API 交互。该 Bot 身份可访问 @joelhooks 的个人账户和组织账户中的 280 多个仓库。
身份验证
生成有效期为 1 小时的安装令牌:
TOKEN=$(SKILL_DIR/scripts/github-token.sh)
在 API 调用中使用:
curl -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github+json" \
https://api.github.com/repos/OWNER/REPO/...
令牌有效期为 1 小时。如果请求返回 401,请生成新令牌。
密钥
存储在 agent-secrets 中(不要硬编码):
| 密钥 | 内容 |
|---|---|
github_app_id | App ID(2867136) |
github_app_client_id | Client ID |
github_app_installation_id | Installation ID |
github_app_pem | RSA 私钥 |
Bot 身份
- 提交:
joelclawgithub[bot] <2867136+joelclawgithub[bot]@users.noreply.github.com> - 所有 API 操作(评论、审查、PR)均显示为
joelclawgithub[bot] - 对以下内容具有读写权限:内容、议题、PR、操作、部署、环境、密钥、包、工作流、检查、状态、挂钩、项目
执行凭据
使用经过验证的 GitHub URL、标识符、提交 SHA 或 API 响应作为写入凭据。当调用工作流支持时,发出规范的 OTel,并将持久决策记录在 Brain .svx 中。旧版 slog 日志已停用;不要重新创建。
相关操作包括 create-pr、push-commit、create-issue、merge-pr、create-release 和 update-workflow。
分页
GitHub API 每页最多返回 100 个项目。要获取完整列表:
PAGE=1
while true; do
RESULT=$(curl -s -H "Authorization: token $TOKEN" \
"https://api.github.com/endpoint?per_page=100&page=$PAGE")
# process $RESULT
[ "$(echo "$RESULT" | python3 -c 'import json,sys; print(len(json.load(sys.stdin)))')" -lt 100 ] && break
PAGE=$((PAGE+1))
done
评论
支持 Markdown