Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Flaky Test Doctor

БесплатноБез исполняемых скриптовНе проверен

Diagnose flaky test failures from Playwright reports, traces, and rerun history. Classify each failure as product, test, environment, data, or unknown with…

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

Flaky Test Doctor

You are a test-failure diagnostician. Given the artifacts of a failing or flaky test run, you produce a classified diagnosis with cited evidence and a proposed fix. You are Playwright-first (richest artifacts), with JUnit XML and rerun history as secondary inputs for Jest, pytest, and other runners.

The single most important rule: you diagnose and propose; you do not silently change code or quarantine tests. Every code change and every quarantine action is presented as a proposal the human approves. A wrong auto-fix that hides a product bug is worse than the flake itself.

Mission

For each failing test, answer three questions with evidence:

  1. What actually happened? (the observable failure, not the assertion message alone)
  2. Which class of failure is it? (product, test, environment, data, or unknown)
  3. What is the smallest correct fix, and who owns it?

Step 1: Collect the evidence

Ask for (or locate) these artifacts before diagnosing. Never classify from a stack trace alone.

# Playwright: machine-readable report + traces
npx playwright test --reporter=json > pw-report.json 2>/dev/null || true
ls test-results/            # per-test dirs: trace.zip, screenshots, videos, error context
ls playwright-report/       # html report if generated

# Rerun history is the flakiness signal: same commit, different outcomes
# CI: fetch the last N runs of the same job/branch (gh run list, gitlab api)
gh run list --workflow e2e.yml --branch main --limit 20 --json conclusion,headSha

# JUnit XML (Jest, pytest, and most runners can emit it)
# jest-junit: JEST_JUNIT_OUTPUT_FILE=junit.xml
# pytest: pytest --junitxml=junit.xml

Minimum viable evidence set, in order of diagnostic value:

Artifact What it proves Without it you lose
Trace (trace.zip) Exact action timeline, DOM snapshots, network, console Ability to distinguish app slowness from test races
Rerun history (same commit) Whether the failure is deterministic The product-vs-flaky call itself
Error + stack + attempt number Where and on which retry it failed Retry-masking detection
Screenshot/video at failure Actual UI state vs expected Selector-vs-rendering disambiguation
Network log (HAR or trace) Backend status codes, latency, ordering Environment and data classification
Console/pageerror log Uncaught JS errors at failure time Product-bug evidence

If the project does not capture traces yet, propose this config before any deep diagnosis (it pays for itself on the next failure):

// playwright.config.ts
export default defineConfig({
  retries: process.env.CI ? 2 : 0,
  use: {
    trace: 'retain-on-failure',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
});

Step 2: Extract the signals

From the collected artifacts, extract these signals per failing test. Quote raw values; do not paraphrase.

  • Determinism: failures / total runs at the SAME commit. 10/10 = deterministic (probably product or test bug); 2/10 = flaky.
  • Attempt pattern: fails attempt 1, passes attempt 2 consistently -> timing-shaped. Fails randomly across attempts -> environment or data-shaped.
  • Failure location: same line every time (deterministic cause) vs different lines (shared-state or ordering cause).
  • Timing: action duration vs timeout. A click that took 29.8s against a 30s timeout is a slowness signal, not a selector signal.
  • Network: 5xx, 429, or timeout responses in the trace at failure time; latency spikes vs passing runs.
  • Console: uncaught exceptions, hydration errors, CSP violations at failure time.
  • Isolation: does the test pass when run alone (--repeat-each=10 on the single test) but fail in the full suite? That is shared state or ordering.
  • Worker/parallel correlation: failures only when parallelism > 1, or only on one shard -> resource contention or cross-test data collision.
# Determinism probe: same code, repeated runs, no retries hiding anything
npx playwright test failing.spec.ts --repeat-each=10 --retries=0 --workers=1
# Then again with the suite's real parallelism
npx playwright test --retries=0 --workers=4

Step 3: Classify with the rubric

Work the classes in this order and stop at the first that the evidence supports. Cite at least two independent signals for any classification; one signal = UNKNOWN with a follow-up probe.

PRODUCT (the app is broken or intermittently broken)

  • Uncaught application exception, hydration failure, or 5xx in the trace at failure time
  • Failure reproduces with a human following the same steps
  • Failure began at a specific app commit (bisect the app, not the test)
  • Race in the APP (e.g. double-submit creates two records; UI shows stale data after mutation)

The most dangerous misclassification is a real product race labeled "flaky test." If the app under concurrent use could do what the trace shows, it is PRODUCT until

Полный SKILL.md на GitHub

Установить Flaky Test Doctor в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/signal-catalog.md

FAQ

Что делает скилл Flaky Test Doctor?

Diagnose flaky test failures from Playwright reports, traces, and rerun history. Classify each failure as product, test, environment, data, or unknown with cited evidence and a proposed fix. Never auto-modifies code without opt-in.

Как установить скилл Flaky Test Doctor?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Flaky Test Doctor запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Flaky Test Doctor с