What this thread does
The problem
A pull request has red checks. You tell the agent "fix CI" and one of two things goes wrong. Either it dumps a huge log into its context and loses the thread, or it sees only part of the failure, fixes that, pushes, and CI is red again for a different job.
What the sources say
Microsoft's VS Code repo ships an agent skill for this (MIT licence, fix-ci-failures, last changed 16 June 2026). It needs only the gh CLI. Its order of work:
1. Find the PR for the branch: gh pr view --json number,title,url,statusCheckRollup. 2. List only failed checks: gh pr checks --json name,state,link,bucket --jq '.[] | select(.bucket == "fail")'. The run ID is the number after /runs/ in each check's link. If checks are still running, gh pr checks --watch --fail-fast. 3. List failed jobs in a run: gh run view <RUN_ID> --json jobs --jq '.jobs[] | select(.conclusion == "failure") | {name, id: .databaseId}'. 4. Get the log, with three options:
gh run view <RUN_ID> --job <JOB_ID> --log-failed, piped throughtail -100orgrep -E "Error|FAIL|error TS|AssertionError|failing". The skill warns this blocks or errors until the whole run has finished, not just the failed job.- Artifacts, when the useful output is uploaded as logs:
gh run download <RUN_ID> -n <artifact> -D /tmp/ci-logs. - The per-job API while the run is still going:
gh api repos/<owner>/<repo>/actions/jobs/<JOB_ID>/logs > "$TMPDIR/ci-job-log.txt", thengrep -n '##\[error\]'to find the failing line andsed -nto read around it. The skill says to save to a file first because a full job log can pass 30,000 lines and tool output gets truncated.
5. Fix, verify locally, push, and watch again with gh pr checks --watch --fail-fast.
A separate project hit the opposite bug. In the closed zhupanov/larch issue 6427 (authored upstream 5 July 2026 and closed there the same day; this migrated copy was created 29 September and closed 3 October 2026) the CI-fix helper kept only the last 100 lines of the failed-job log. On one run with three failing test shards it captured 101 lines and saw one shard; the untruncated gh run view <id> --log-failed output was 902 lines and showed all three. The agent fixed a subset, pushed, and needed extra CI rounds. The fix was to stop truncating and to change the procedure to a hard rule: list and fix every failing job before committing and pushing.
How to use this
- Tell the agent the order: failed checks, then failed jobs, then one log per job, saved to a file or filtered, never the whole run pasted in.
- Add the rule from larch: write down the list of failing jobs first and do not push until each one is addressed or explained.
- Do not filter too broadly. The VS Code skill says to start with
##[error]and use broader patterns if that does not reveal enough; search from##[error]or from the failing step name. - Copy the skill file as a starting point, but replace the VS Code specifics (artifact names, test script,
microsoft/vscodein the API call).
Limits
Both sources are project documents, not controlled tests. The flags come from the skill text; check them against your installed gh version. Not run by us.
Sources
Checked against primary sources:
- fix-ci-failures SKILL.md at the cited commit (Microsoft, MIT repo): step order, the
ghcommands, the--log-failedwarning and thetail -100/grepfilters match; last change to the file 16 June 2026. - zhupanov/larch issue 6427 (zhupanov): 101 lines captured versus 902 from untruncated
--log-failed, three failing shards, and the planned fix (return the full output, fix every revealed failure before pushing) are as described.
Not confirmed here: the 30,000-line figure and the per-job API/artifact steps beyond what the skill file shows were only skimmed; the recommendation to start with ##[error] and broaden the search only if needed is from the VS Code skill, not the larch issue.
Started from a post by @Microsoft (microsoft/vscode), packaged by the editor. Original post