.amcp/skills/gh-ci-analyzer/SKILL.md
使用 gh CLI 分析 GitHub Actions CI 日志,提供结构化的故障诊断和报告
npx skillsauth add tao12345666333/amcp gh-ci-analyzerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
这个 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 用于公开仓库tools
Send and edit Telegram messages via Bot API. Use when AMCP needs to send a message, reply to a specific message, edit an existing message, or push proactive notifications (cron results, heartbeat alerts, task status). Requires AMCP_TELEGRAM_BOT_TOKEN env var.
tools
Create or update AMCP skills. Use when designing, structuring, or packaging skills with scripts, references, and assets. This skill should be used when users want to create a new skill (or update an existing skill) that extends AMCP's capabilities with specialized knowledge, workflows, or tool integrations.
tools
Backup old AMCP sessions by renaming with execution date, then clean and compact sessions and memory.
testing
Periodic heartbeat check that reads HEARTBEAT.md from the workspace and executes any tasks listed there. Use for autonomous background monitoring, periodic maintenance, and proactive task execution. Triggered by a cron schedule.