Turn failed CircleCI builds into tracked Linear issues
When a build fails on your default branch, we open a Linear issue with the broken jobs and tests, or update the existing ticket so you never get duplicates.
Watch my CircleCI project with a poll trigger on the workflow-completed event, so this runs every time a workflow finishes. Only act when the workflow's status is failed and it ran on my default branch (for example main or master). Ignore successful and canceled workflows, and ignore any failure that happened on a non-default branch.
When a real failure comes in, use CircleCI's Get a workflow's jobs to list the jobs in the workflow and identify which ones failed. Then use Get test metrics for a workflow to pull the failing tests for that workflow, capturing their names so I can reference them later.
Before filing anything, call Get flaky tests for a project to fetch the project's known-flaky tests. Compare the failing tests against that flaky list. If every failing test is already flagged as flaky, stop and do nothing, so I do not open tickets for known-flaky noise. Only continue when at least one failing test is not flaky, or when a job failed for a reason that is not a test.
For a genuine failure, use Linear's Search Issues to look for an existing open issue about this pipeline or one of the failing tests. Match on the project or workflow name and on the failing test names, and only consider issues that are still open (not done, canceled, or archived).
If no open issue matches, use Linear's Create Issue to open a new one. Write an AI-drafted title and description that name the failed jobs and the failing tests and include a direct link to the CircleCI build. If a matching open issue already exists, do not create a duplicate; instead use Add Comment to Issue to note that the failure recurred, and include how many times it has now happened based on the issue's history.
Keep everything scoped to the default branch, and skip any failure where every failing test is already flagged flaky.
Additional information
What does this prompt do?
- Watches your CircleCI project and reacts only when a build fails on your default branch, ignoring passing and canceled runs and any other branch.
- Pulls the exact jobs and tests that broke and writes a clear, ready-to-read summary of the failure with a link back to the build.
- Skips the noise from known flaky tests, so you only get tickets for real, repeatable failures.
- Checks Linear first: opens a new issue when nothing matches, or adds a note to the existing one saying the failure came back and how many times.
What do I need to use this?
- A CircleCI account connected to the project you want to watch
- A Linear workspace where new issues can be created and commented on
- Test results turned on in your CircleCI setup so the failing tests are visible
How can I customize it?
- Set which branch counts as your default, for example main or master
- Choose the Linear team and default priority used for new issues
- Adjust how strict the flaky-test filter is, or turn it off to capture every failure
Frequently asked questions
Will this create a new ticket every time a build fails?
Does it file tickets for flaky tests?
Will it react to failures on feature branches?
Can I use this with Jira instead of Linear?
What goes into the ticket?
Related templates
Stop letting broken builds slip through the cracks.
Every real failure on your default branch becomes a tracked Linear issue automatically, without the duplicate noise.