# Self-Healing CI: Containing Flaky Tests Without Hiding Real Bugs

> Flaky tests fail intermittently with no code change. Learn how to identify them and how self-healing CI retries the right failures without masking genuine bugs.

Source: https://latchkey.dev/learn/self-healing-ci/self-heal-flaky-test-retry  
Updated: 2026-06-25

A flaky test passes and fails on the same commit. The art of automating around it is retrying the genuinely-transient failure without ever hiding a real regression.

## What makes a failure safely retryable

Automatic retry is only correct for failures that are genuinely transient. Retrying a deterministic failure wastes minutes and hides a real defect, so the classification matters more than the retry mechanism.

- Safe to retry: network timeouts, registry 5xx, transient DNS failures, a service container that was not ready, a spot instance reclaimed mid-run.
- Not safe to retry: assertion failures, compile errors, lint violations, anything that fails identically on every attempt.
- Ambiguous, and worth investigating rather than retrying: out-of-memory kills, disk exhaustion, and flaky tests. These repeat under load and a retry only hides the trend.
- Always record that a retry happened. A pipeline that silently retries is a pipeline whose real failure rate you do not know.

## FAQ

### What causes Self-Healing CI: containing flaky tests without hiding real bugs?

A test suite fails on a test that passes when re-run, with no code change. Timing, ordering, shared state, or an external dependency made it nondeterministic. Teams re-run the job and it goes green.

### How do I fix Self-Healing CI: containing flaky tests without hiding real bugs manually?

[object Object]

### Can Self-Healing CI: containing flaky tests without hiding real bugs be fixed automatically?

Self-healing CI treats flakiness conservatively: it identifies failures that match a transient, non-deterministic signature and retries those specifically, while leaving consistent, reproducible failures to surface as real.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
