一键导入
gh-ci-analyzer
使用 gh CLI 分析 GitHub Actions CI 日志,提供结构化的故障诊断和报告 Use when this capability is needed.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
使用 gh CLI 分析 GitHub Actions CI 日志,提供结构化的故障诊断和报告 Use when this capability is needed.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Morning update routine: merge Renovate PRs, rebase local work, apply chezmoi changes Use when this capability is needed.
Use when the user wants to set, change, or clear git commit co-authors for pair or mob programming.
Use when the user asks to install, add, or set up a package, tool, CLI, or application
Use when the user wants to fetch and contextualize a GitHub repository for future reference.
Use when writing or reviewing GitHub-flavored Markdown (README, issues, PRs, docs)
Copy content to my clipboard using `pbcopy`. Use when this capability is needed.
| name | gh-ci-analyzer |
| description | 使用 gh CLI 分析 GitHub Actions CI 日志,提供结构化的故障诊断和报告 Use when this capability is needed. |
| metadata | {"author":"tao12345666333"} |
这个 skill 指导 agent 如何使用 GitHub CLI (gh) 来分析 GitHub Actions CI/CD 日志,诊断失败原因,并提供结构化的分析报告。
确保已安装并认证 GitHub CLI:
gh auth login
gh auth status
# 列出最近的 workflow runs
gh run list
# 列出特定 workflow 的 runs
gh run list --workflow "CI.yml"
# 限制显示数量
gh run list --limit 10
# 按状态过滤
gh run list --status failed
gh run list --status completed
# 查看特定 run 的基本信息
gh run view <run-id>
# 查看特定 workflow 的最新 run
gh run view --workflow "CI.yml"
# 查看特定分支的最新 run
gh run view --branch main
# 查看失败 job 的日志
gh run view <run-id> --log-failed
# 查看特定 job 的日志
gh run view <run-id> --job <job-id>
# 查看完整日志(包括成功的)
gh run view <run-id> --log
# 查看当前 PR 的检查状态
gh pr checks
# 查看特定 PR 的检查状态
gh pr checks <pr-number>
# 查看 PR 的详细状态
gh pr view <pr-number> --json statusCheckRollup
# 查看最近的失败 runs
gh run list --status failed --limit 5
记录失败的 run ID 和 workflow 名称。
# 查看失败 run 的概览
gh run view <run-id>
# 查看失败日志
gh run view <run-id> --log-failed
在日志中寻找以下关键信息:
# 查看关联的 PR
gh pr view --json number,title,headRefName
# 查看 PR 的检查状态
gh pr checks
识别特征:
分析要点:
识别特征:
分析要点:
识别特征:
分析要点:
识别特征:
分析要点:
# CI 失败分析报告
## 基本信息
- **Run ID**: <run-id>
- **Workflow**: <workflow-name>
- **分支**: <branch-name>
- **提交**: <commit-sha>
- **时间**: <timestamp>
- **PR**: <pr-number> (如果适用)
## 失败概览
- **失败 Job**: <job-name>
- **失败 Step**: <step-name>
- **错误类型**: <error-category>
- **失败时间**: <failure-timestamp>
## 错误详情
[粘贴关键错误日志]
## 根本原因分析
[详细分析失败的根本原因]
## 影响范围
- **受影响功能**: <affected-features>
- **影响程度**: <high/medium/low>
- **是否阻塞性**: <yes/no>
## 修复建议
1. **立即修复**: <immediate-fix-steps>
2. **长期改进**: <long-term-improvements>
3. **预防措施**: <prevention-measures>
## 相关资源
- **失败日志链接**: <log-url>
- **PR 链接**: <pr-url>
- **提交链接**: <commit-url>
# 获取最近 10 个失败的 runs
gh run list --status failed --limit 10 --json databaseId,headBranch,conclusion
# 批量查看失败日志
for run_id in <run-ids>; do
echo "=== Run $run_id ==="
gh run view $run_id --log-failed
done
# 在日志中搜索特定错误
gh run view <run-id> --log | grep -i "error\|exception\|failed"
# 搜索超时相关
gh run view <run-id> --log | grep -i "timeout"
# 查看 job 执行时间
gh run view <run-id> --json jobs | jq '.jobs[] | {name: .name, duration: .completedAt - .startedAt}'
参考 scripts/ 目录中的辅助脚本:
analyze-failed-run.sh: 分析单个失败 runbatch-analyze.sh: 批量分析多个失败generate-report.sh: 生成结构化报告# 检查认证状态
gh auth status
# 重新认证
gh auth login
# 检查版本
gh --version
确保有足够的仓库权限:
repo scope 用于私有仓库public_repo scope 用于公开仓库Source: tao12345666333/amcp — distributed by TomeVault.