---
title: "Find flaky tests with an AI agent · AgentDots"
description: "When a test fails and then passes on rerun, your agent confirms the flakiness, traces the cause and proposes a fix in a pull request on a separate branch."
url: https://agentdots.org/playbooks/flaky-test-hunt/
lang: en
---

Playbooks · Code

# Flaky test hunt

When a test fails at random, the agent reruns it, finds the pattern and proposes a fix on a branch.

When something happensMedium stakes

## Paste this into your agent

```
<code>When a test fails in CI and then passes on a rerun, record it. Run the suspect test in isolation enough times to confirm it is flaky, then look for the cause, such as timing, shared state or test order. Propose a fix on a new branch, with a pull request laying out the evidence. Do not disable, skip or delete tests, and do not merge or push to the main branch.</code>
```

## What the agent does

1. Spot tests that fail and then pass
2. Rerun the suspect test in isolation
3. Trace the cause of the flakiness
4. Open a pull request with the fix and the evidence

## Rules to add

- Changes go on a branch and wait for review
- No disabling, skipping or deleting tests
- No new packages without your approval

What you end up with: Flaky tests found, explained and fixed in a pull request you can review.

## Which agents can do it

- [Dots](https://agentdots.org/agents/dots/) Built for it
- [Claude](https://agentdots.org/agents/claude/) Can do it
- [OpenClaw](https://agentdots.org/agents/openclaw/) Can do it

Matching rule sheet

Software developer

[Rules →](https://agentdots.org/rules/?t=software-developer)

## More from this area

- [Pull request digest](https://agentdots.org/playbooks/pull-request-digest/)
