AI Prompt to Triage Flaky CI Test Failures Using GitHub's MCP Server
This AI prompt helps engineers and tech leads figure out which failing CI tests are genuine bugs and which are flaky tests that fail intermittently for unrelated reasons, using GitHub's MCP Server to pull the actual workflow run history, logs, and commit diffs for a repository instead of relying on a single failed run. A model connected through MCP can query recent runs of the same test across different commits and spot whether a failure correlates with a specific code change or shows up randomly regardless of what changed.
The prompt asks the model to compare the failing test's recent run history, check whether the failure message is identical across runs or varies (a sign of a race condition or timing issue), and cross-reference the commits that landed around the first failure. This saves engineers from re-running a flaky suite repeatedly by hand or quarantining a genuinely broken test as 'just flaky' and shipping a real regression.
Because CI logs and run histories can run long and get expensive to pass through a model repeatedly during an active incident, teams pulling large volumes of log output alongside this prompt can use Token Optimizer to trim verbose logs down before each triage pass.
Prompt template
Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.
Example input
When to use it
- A CI pipeline has intermittent test failures and the team needs to know which ones are flaky versus real regressions before merging.
- You're deciding whether to quarantine a test or investigate it, and want evidence from run history instead of a gut call.
- A release is blocked by failing tests and you need a fast triage of which failures are safe to re-run and which need a fix first.
- You want a repeatable process for distinguishing timing-related test flakiness from genuine logic bugs introduced by a recent commit.
Best practices
- Pull the test's run history across at least the last 10-15 runs through MCP rather than judging from one failed run, so you can see whether the failure is consistent or intermittent.
- Ask the model to check whether the failure message, stack trace, or line number changes between runs, since identical failures point to a real bug and varying ones point to flakiness.
- Have it cross-reference the commits merged around the first failure, not just the most recent one, since flaky tests sometimes start failing a few commits after the actual cause landed.
- When log output from multiple runs is too long to review efficiently, trim it with Token Optimizer before feeding it into the triage prompt.
Common mistakes
- Labeling a test as flaky after only one or two failures instead of checking its run history for a real pattern.
- Quarantining a test without checking whether a genuine regression landed around the same time the failures started.
- Ignoring differences in failure messages between runs, which is often the clearest signal separating a timing issue from a logic bug.
- Triaging the symptom (the failing test) without looking at what changed in the surrounding code or infrastructure right before failures began.
FAQs
How do I tell if a failing CI test is flaky or a real bug?
Check the test's run history instead of a single failure: if the failure message and stack trace are identical across multiple runs and line up with a specific commit, it's likely a real regression; if the failures are inconsistent and uncorrelated with any code change, it's more likely flaky.
How many failed runs should I look at before calling a test flaky?
At least 3 to 5 failed runs is a reasonable minimum before quarantining a test as flaky, since one or two failures can easily be a real but intermittent bug rather than true flakiness.
Can an AI model actually pull my GitHub Actions run history automatically?
Yes, if it's connected through GitHub's MCP server it can query workflow run history, logs, and the commits associated with each run directly, rather than you needing to copy and paste logs manually.
What should I do with a test I've confirmed is genuinely flaky?
Quarantine it so it doesn't block merges, but track it separately and revisit it, since a test that's flaky due to a real race condition can mask a production bug if ignored indefinitely.
What tool can help me check this prompt's quality before using it on a live incident?
Prompt Debugger — scans the prompt for vague constraints or missed edge cases, which matters here since a weak classification rule could mislabel a real regression as flaky.