帮助你定位并修复拉取请求中的 CI 检查失败问题
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "fix-ci-failures" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/vscode/main/.github/skills/fix-ci-failures/SKILL.md 2. 保存为 ~/.claude/skills/fix-ci-failures/SKILL.md 3. 装好后重载技能,告诉我可以用了
请帮我排查这个 PR 的 CI 失败。使用 gh CLI 找到该 PR,列出失败的检查项,下载相关日志和 artifacts,总结根因,并给出修复建议或直接生成修复方案。
输出失败检查清单、错误根因分析,以及可执行的修复步骤或代码修改建议。
这个分支的 CI 测试失败了。请下载失败任务日志,定位是哪一个测试、依赖或配置导致失败,并迭代提出修复,直到形成明确可实施的修改方案。
输出具体失败点、影响范围、修复思路,以及推荐提交的修改内容。
请检查此 PR 的失败 CI 任务,下载 artifacts 和日志,提取关键报错信息,判断是环境问题、脚本问题还是代码回归,并给出下一步修复优先级。
输出分类后的故障原因判断、关键证据摘要,以及按优先级排序的修复建议。
This skill guides you through diagnosing and fixing CI failures on a PR using the gh CLI. The user has the PR branch checked out locally.
# Get the current branch name
git branch --show-current
# Find the PR for this branch
gh pr view --json number,title,url,statusCheckRollup
If no PR is found, the user may need to specify the PR number.
# List all checks and their status (pass/fail/pending)
gh pr checks --json name,state,link,bucket
# Filter to only failed checks
gh pr checks --json name,state,link,bucket --jq '.[] | select(.bucket == "fail")'
The link field contains the URL to the GitHub Actions job. Extract the run ID from the URL — it's the number after /runs/:
https://github.com/microsoft/vscode/actions/runs/<RUN_ID>/job/<JOB_ID>
If checks are still IN_PROGRESS, wait for them to complete before downloading logs:
gh pr checks --watch --fail-fast
# List failed jobs in a run (use the run ID from the check link)
gh run view <RUN_ID> --json jobs --jq '.jobs[] | select(.conclusion == "failure") | {name: .name, id: .databaseId}'
There are two approaches depending on the type of failure.
Best for build/compile/lint failures where the error is in the step output:
# View only the failed step logs (most useful — shows just the errors)
gh run view <RUN_ID> --job <JOB_ID> --log-failed
Important:
--log-failedrequires the entire run to complete, not just the failed job. If other jobs are still running, this command will block or error. Use Option C below to get logs for a completed job while the run is still in progress.
The output can be large. Pipe through tail or grep to focus:
# Last 100 lines of failed output
gh run view <RUN_ID> --job <JOB_ID> --log-failed | tail -100
# Search for common error patterns
gh run view <RUN_ID> --job <JOB_ID> --log-failed | grep -E "Error|FAIL|error TS|AssertionError|failing"
Best for integration test failures where detailed logs (terminal logs, ext host logs, crash dumps) are uploaded as artifacts:
# List available artifacts for a run
gh run download <RUN_ID> --pattern '*' --dir /dev/null 2>&1 || gh run view <RUN_ID> --json jobs --jq '.jobs[].name'
# Download log artifacts for a specific failed job
# Artifact naming convention: logs-<platform>-<arch>-<test-type>-<attempt>
# Examples: logs-linux-x64-electron-1, logs-linux-x64-remote-1
gh run download <RUN_ID> -n "logs-linux-x64-electron-1" -D /tmp/ci-logs
# Download crash dumps if available
gh run download <RUN_ID> -n "crash-dump-linux-x64-electron-1" -D /tmp/ci-crashes
Tip: Use the test runner name from the failed check (e.g., "Linux / Electron" →
electron, "Linux / Remote" →remote) and platform map ("Windows" →windows-x64, "Linux" →linux-x64, "macOS" →macos-arm64) to construct the artifact name.
Warning: Log artifacts may be empty if the test runner crashed before producing output (e.g., Electron download failure). In that case, fall back to Option C.
When the run is still in progress but the failed job has completed, use the GitHub API to download that job's step logs directly:
# Save the full job log to a temp file (can be very large — 30k+ lines)
gh api repos/microsoft/vscode/actions/jobs/<JOB_ID>/logs > "$TMPDIR/ci-job-log.txt"
…
帮助开发者验证 Azure DevOps 流水线改动,快速排查构建与 YAML 配置问题。
在推送代码或触发 CI 前检查常见问题,提前发现格式、变更集与策略风险。