Diagnose CI Gate

Diagnose CI Gate

Determines whether a failing CI check was caused by the current change, classifies it as bug, flaky, environment or pipeline, and recommends one action.

Skill files2 files

references/

SKILL.md197 lines
1
---
2
name: 'diagnose-ci-gate'
3
description: 'Determine whether a failing CI check was caused by the current change, then recommend exactly one action. Use when a required check fails on a pull request, when asked "is this failure mine?", when a job passes locally but fails in CI, or before retrying a red build. Covers fetching the real log, reading the first error instead of the tail, classifying bug / flaky / environment / pipeline, comparing against the base branch and recent runs, reproducing with CI versions, and fixing a flaky test rather than re-running it forever.'
4
---
5
6
# Diagnose CI Gate
7
8
A red check is a claim, not a diagnosis. Before you change code or press
9
re-run, establish three things from evidence: what actually failed, which class
10
of failure it is, and whether this change caused it.
11
12
This skill is for a failing required check on a pull request or a branch. For
13
cutting CI cost in general, use the `github-actions-efficiency` skill. For a
14
domain-specific flaky suite, use the skill for that tool (for example
15
`cypress-flake-fixer`) after this triage.
16
17
## When to Use This Skill
18
19
- A required check fails on a pull request and you need to know if it is yours
20
- A job passes locally but fails in CI, or fails on only some runs
21
- Someone says "that failure is unrelated, just re-run it"
22
- A build has been retried several times and keeps failing
23
- You are about to edit a workflow file to make a check pass
24
25
## Prerequisites
26
27
- `gh` CLI authenticated, or the raw logs pasted by the user
28
- Read access to the base branch and its recent runs
29
- The commands in the failing step, so they can be reproduced
30
31
If logs are truncated, partial, or only a summary, stop and ask for the full
32
log. Do not diagnose from the last few lines of a summarized check.
33
34
## Workflow
35
36
### 1. Get the failing job, not the check summary
37
38
```bash
39
gh pr checks <pr-number> # which check, which state
40
gh run list --branch <branch> --limit 10 # current and recent runs
41
gh run view <run-id> --log-failed # only the failing steps
42
gh run view <run-id> --job <job-id> --log # one job, full log
43
```
44
45
Record the commit SHA under test, the runner image, and the time. A failure on
46
an older SHA is a different problem from a failure on the current head.
47
48
### 2. Read from the first error
49
50
Read the top of the failing step, not the bottom. The first error is usually
51
the cause; everything after it is fallout from that cause or from the runner
52
giving up.
53
54
Quote the exact lines, and name the command that produced them. If the log
55
shows only a summary line (`Process completed with exit code 1`), find the step
56
that emitted it and read that step's output.
57
58
### 3. Classify the failure
59
60
| Class | Signal | Confirm by |
61
| --- | --- | --- |
62
| **Bug** | Same failure every run, deterministic input | Re-running fails identically at the same assertion |
63
| **Flaky** | Passes sometimes, timing/ordering/network/shared state | At least one green run of the same job on the same SHA, or a local loop that fails intermittently |
64
| **Environment** | Tool version, missing secret, runner image, cache, disk or memory | Version in CI differs from local, or the step fails before any project code runs |
65
| **Pipeline** | The workflow itself is wrong: bad path filter, wrong working directory, missing dependency install, YAML error, or a check that asserts a target the pull request cannot produce (such as a production URL for a page that is not merged yet) | The command succeeds against the pull request's own build, and the workflow line or its target is demonstrably wrong |
66
67
Write the class and the evidence for it in one sentence each. A failure that
68
cannot be classified is not ready for a fix.
69
70
### 4. Decide whether this change caused it
71
72
Compare with the base branch before claiming anything about ownership:
73
74
```bash
75
gh run list --branch main --limit 10
76
git merge-base HEAD origin/main
77
```
78
79
If the same job fails on the base branch, or on recent runs of the base branch,
80
it is pre-existing. Say so and link the run.
81
82
Some jobs only run on pull requests, so no base-branch run exists. In that case,
83
say that instead of implying you compared, and use the diff to establish what
84
the change added.
85
86
To test the base directly without disturbing the worktree, create a unique
87
throwaway worktree and remove it when done:
88
89
```bash
90
base_dir="$(mktemp -d)"
91
git worktree add "$base_dir" "$(git merge-base HEAD origin/main)"
92
( cd "$base_dir" && <failing command> )
93
git worktree remove --force "$base_dir"
94
```
95
96
`mktemp -d` returns a fresh path, so concurrent runs cannot collide. `--force` is
97
safe here because the directory was created for this check and the failing
98
command may have written build output into it. Never point this at a path that
99
holds work, and remove the worktree with `git worktree remove` instead of
100
deleting the directory by hand. If a directory was deleted by hand, run
101
`git worktree prune`.
102
103
This example is POSIX shell. On Windows, run it from Git Bash, or use
104
PowerShell:
105
106
```powershell
107
$baseDir = Join-Path $env:TEMP ("ci-base-" + [guid]::NewGuid())
108
git worktree add $baseDir (git merge-base HEAD origin/main)
109
Push-Location $baseDir; <failing command>; Pop-Location
110
git worktree remove --force $baseDir
111
```
112
113
If it passes on the base and fails on the head, name the commit and the file and
114
line that introduced it. If the change is a dependency bump, check the lockfile
115
diff and the tool version, not only the source diff.
116
117
### 5. Reproduce with CI's versions
118
119
Run the failing command with the versions CI used, from the same working
120
directory, with the same environment variables and the same install step. Read
121
the versions from the log, not from your local machine.
122
123
If you cannot reproduce it, say so and name every difference you found: OS,
124
runtime version, dependency resolution, environment variable, timezone,
125
parallelism, cached state. "Cannot reproduce" is a finding, not a failure.
126
127
### 6. Choose exactly one action
128
129
- **Retry** - only when you already have evidence the failure is flaky. Name
130
the green run of the same job on the same SHA.
131
- **Fix the code** - name the file, line, and change. This is the default for a
132
deterministic bug.
133
- **Fix the pipeline** - name the workflow file and line. This is for pipeline
134
faults, not for hiding a real failure.
135
136
For a flaky test, do the follow-up work instead of re-running forever:
137
138
1. Run it repeatedly and record the failure rate: `for i in $(seq 1 20); do <command>; done`
139
2. Find the shared state, timing assumption, or ordering dependency behind it
140
3. Fix or quarantine it with an owner and a removal date, and say which
141
142
### 7. Verify and report
143
144
Re-run the check after the fix and show the result. For a flaky test, show the
145
repeated runs.
146
147
Report in this shape:
148
149
```text
150
Check: <name> on <SHA>
151
First error: <quoted line> (<step>, <command>)
152
Class: bug | flaky | environment | pipeline
153
Ownership: introduced by <commit/file:line> | pre-existing (<run link>)
154
Reproduced: yes (<command>) | no (<differences>)
155
Action: retry | fix code | fix pipeline
156
Result: <run link, or the repeated-run tally>
157
```
158
159
## Verification Checklist
160
161
- [ ] The quoted error comes from the real log, with the step and command named
162
- [ ] The failure is classified, with the evidence for that class
163
- [ ] The base branch and recent runs were checked before claiming ownership
164
- [ ] The failure was reproduced with CI versions, or the differences are listed
165
- [ ] The recommended action is one of retry, fix code, or fix pipeline, with a reason
166
- [ ] The check was re-run after the fix, and the result is shown
167
168
## Rules
169
170
- Never recommend re-running without evidence that the failure is flaky
171
- Never call a failure unrelated without comparing against the base branch
172
- Never skip, delete, or weaken a failing test to make a check pass
173
- Never add `continue-on-error`, `if: always()`, or a path filter to hide a real failure
174
- Never treat a passing retry as proof the root cause is gone; say what changed
175
- Never diagnose from a summary line when the full log is available
176
177
## Validation
178
179
[`references/validation.md`](references/validation.md) records this skill applied
180
to real failed checks on a public repository: the job log, the classification,
181
the ownership evidence, the reproduction attempt, and the recommended action.
182
183
The first scenario is a transcript from GitHub Copilot CLI, prompted only with
184
the failing job log, in a checkout where the failing command passes. It returned
185
the report format below, classified the failure as pipeline, and attributed it to
186
the parent commit rather than the change under test. Both findings were confirmed
187
afterwards, and a depth-1 checkout reproduces the failure. The scenario exists to
188
show the report surviving a green local run instead of collapsing into "cannot
189
reproduce, probably flaky".
190
191
## Limitations
192
193
- Log access depends on permissions. Without it, ask for the log instead of guessing
194
- Private runners and self-hosted infrastructure can fail for reasons the log does not show
195
- A failure that only reproduces under load or on real hardware may need production-like infrastructure
196
- This skill diagnoses and recommends. It does not decide whether a check is allowed to be bypassed; that is a policy decision for the repository owner
197

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…