AI triage for failed Buildkite builds, posted to Slack
When a build fails, an AI assistant reads the failing job's log, explains the likely cause in plain English, and posts a clear alert to your Slack channel.
When a Buildkite build finishes in a failed state, investigate what went wrong and post a clear, human-readable alert to Slack. Trigger this workflow on a Buildkite webhook for the build.finished event, and only continue when the build's state field is the lowercase string "failed". Ignore builds that finished passed, blocked, or canceled.
Before doing anything else, make sure this is the first time the branch has turned red so the channel is not spammed on repeated failures. Use List Builds for a Pipeline, filtered to this pipeline and branch, to find the build that finished immediately before this one. Only continue if that previous build passed, which means this is a passing-to-failing transition. If the branch was already failing on the prior build, stop without posting anything, the same way Buildkite's own started-failing notifications behave.
Once you have confirmed this is a new failure, use Get a Build to pull the build's details: the pipeline name, branch, commit hash, commit message, and the person who created the build, including their name and email. Identify which jobs in the build failed, and for each failed job use Get a Job's Log Output to read the tail end of the log, where the error usually surfaces.
Read the failing logs and write a short, plain-English diagnosis of the most likely cause. Classify it into one of: a failing test, a compile or build error, a timeout, or an infrastructure or flaky-runner issue, and briefly say what in the log points to that conclusion. Keep it to a couple of sentences that a busy engineer can skim.
Post the alert to the team's Slack channel as a bot using Send a Message. Include the pipeline and branch, the specific step or job that failed, your plain-English diagnosis, and a direct link to the build in Buildkite. Try to mention the commit author: take the build creator's email and use Look Up User by Email to find their Slack user, then @-mention that user in the message so they see it. If there is no matching Slack user, just name the author in plain text. Format the message with Slack mrkdwn so the pipeline, branch, and failing step stand out.
Example output
Additional information
What does this prompt do?
- Watches Buildkite for builds that finish in a failed state and jumps in automatically.
- Reads the end of the failing job's log and writes a plain-English diagnosis of the likely cause, whether that's a failing test, a broken build, a timeout, or a flaky runner.
- Posts a clear alert to Slack with the pipeline, branch, the step that failed, the diagnosis, and a link straight to the build.
- Only pings the channel the first time a branch turns red, so your team isn't spammed on every repeated failure.
What do I need to use this?
- A Buildkite account with the pipelines you want to monitor.
- A Slack workspace and a channel where alerts should be posted.
- Optional: matching email addresses between Buildkite and Slack so the right person gets mentioned.
How can I customize it?
- Choose which pipelines or branches trigger an alert, for example only your main branch or your production pipelines.
- Pick the Slack channel and decide whether to @-mention the person who pushed the commit.
- Adjust the tone and length of the diagnosis, or how much of the log the assistant reviews.
Frequently asked questions
Will this spam my channel every time a build fails?
How does it know what caused the failure?
Will it tag the person who broke the build?
Can I limit it to certain pipelines or branches?
Does it work with private Slack channels?
Related templates
Stop staring at red builds trying to guess what broke.
Let an assistant read the log, explain the failure, and alert the right person in Slack the moment a build turns red.