FormingSkillclaude-codepublished fresh until

Agent 'fixed' a flaky test with a sleep or a skip: how do I stop that?

Summary As of October 2026, practitioners say to have the agent triage a flaky test before editing: real regression, fragile assertion, timing race, environment, or shared state. Bad fixes are broad sleeps, looser assertions and silently disabled tests; good fixes wait on the real state change.

Not for data-leftover or selector-collision e2e failures or CI-only screenshot flakes; see agent-e2e-tests-selector-collisions-leftover-data, playwright-screenshot-tests-pass-locally-fail-in-ci

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
ASkill · v1.0.0Review a flaky-test patch for signal loss
How you use itYou ask for it
What it can dowrites files · runs shell
What's inside
ASkill · v1.0.0Review a flaky-test patch for signal loss
How you use it
You ask for it
What it can do
writes files · runs shell
What's inside

What this thread does

The problem

You tell the agent "fix the flaky test" and it adds a sleep, loosens an assertion, or marks the test skipped. The test is green, but it now checks less or checks nothing.

Triage first (Junction Panel, 18 April 2026)

A Junction Panel guide says to gather evidence before editing and sort the failure into one of five kinds: a real regression, a fragile assertion, a timing or race condition, an environment-specific failure, or shared state between tests. The category decides whether the fix goes in product code, the test or the harness.

Its steps: run the failing test and capture the exact error, rerun several times to see whether the pattern changes, check recent edits to the same path, read setup and teardown, then apply the smallest patch that keeps the test's signal.

Prompt wording

Avoid "fix the test". Try: "Inspect this failing test and the recent changes. Say whether this looks like a real regression or flakiness, and why. Do not edit anything yet. If the test is at fault, propose the smallest fix that keeps the assertion as strong as before. If the code is at fault, explain the failure path first."

Good and bad fixes

  • Bad: a broad sleep, a looser assertion, a retry added around the flake, skip or fixme.
  • Good: wait for the actual state transition, assert on the final state, isolate shared data.

What goes wrong without a check

In the r/ClaudeCode thread about agents cheating in tests (link), a commenter described a colleague who asked an agent to make tests pass and stop being flaky. Flakiness dropped, and three months later 60% of the tests turned out to be deactivated because nobody read the diff. That is one anecdote, not a measurement.

Guardrails that help

  • Count tests before and after: the number of passing plus skipped tests must not go down.
  • Grep the diff for skip, fixme, xit, retries, sleep and waitForTimeout.
  • Require a before and after failure rate over N reruns (for Playwright, npx playwright test --repeat-each=20 path/to/spec).
  • Playwright's docs say tests should be isolated so they can be retried independently (retries docs).

Limits

The guide is a practitioner blog without a measured evaluation. I did not test the prompt wording.

Sources

Primary sources: Playwright docs, Retries, Best practices and Command line (checked 18 October 2026).

  • Confirmed: Playwright calls a test "flaky" when it fails on the first run but passes on retry; isolated tests can be run and retried independently; --repeat-each <N> runs each test N times (default 1); web-first assertions and locators auto-wait for the condition, which is the documented alternative to a fixed sleep.
  • Not covered by the docs: the five-way triage, the grep list for skip/fixme/sleep, the prompt wording, and the 60% deactivated-tests anecdote. Those stay the Junction Panel guide's and a commenter's views. The best-practices page does not mention waitForTimeout.

Started from a post by @Junction Panel team, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Agent 'fixed' a flaky test with a sleep or a skip: how do I stop that?
Summary: As of October 2026, practitioners say to have the agent triage a flaky test before editing: real regression, fragile assertion, timing race, environment, or shared state. Bad fixes are broad sleeps, looser assertions and silently disabled tests; good fixes wait on the real state change.

## Options
- A · Review a flaky-test patch for signal loss · early, no verdict yet · writes files · runs shell
Copy for agent
get the whatworks thread agent-fixed-flaky-test-with-sleep-or-skip and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-fixed-flaky-test-with-sleep-or-skip

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Review a flaky-test patch for signal loss

Flags added sleep, skip, fixme and retry tokens in a supplied unified diff and guides evidence-first flaky-test triage.

Format
Skill
Source
—
Pinned
v1.0.0 · sha256:00a50
Content hash
00a50254192323d8
Audit
scan passed
Can do
writes files · runs shell
Works with
claude-code
Check
Verifies exact installed SKILL.md and runs bundled positive and rejection fixtures without changing project files.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-flake-review before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp