agentleFS
anhtesteranhtester/codex-testing-kit/.agents/skills/flaky-test-analyzer/SKILL.md

flaky-test-analyzer

Skill28 starsChanged 4 months agoMITView on GitHub

Skill phân tích và khắc phục các automation test không ổn định (flaky tests), xác định root cause và đề xuất fix.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Distinctive:

    Test results are inconsistent across runs

    line 17
  3. Distinctive:

    Test data conflicts (shared data between parallel tests)

    line 30
  4. Very specific:

    Fix: Use smart waits as defined in .agents/rules/selenium_rules.md and .agents/rules/playwright_rules.md:

    line 67
  5. Distinctive:

    Fix: Use unique, traceable random data:

    line 83
  6. Distinctive:

    After fixing a flaky test, verify:

    line 92

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flaky Test Analyzer

Purpose: Identify and resolve unstable automation tests.


When to Use

Use this skill when:

  • A test passes and fails intermittently
  • Test results are inconsistent across runs
  • CI/CD pipeline has unreliable test results

Responsibilities

Detect flaky tests caused by:

  • Unstable locators (dynamic classes, positional xpath)
  • Timing issues (race conditions, slow page loads)
  • Incorrect waits (hard sleep instead of smart waits)
  • Environment dependency (data not cleaned up, external service down)
  • Test data conflicts (shared data between parallel tests)

Analysis Workflow

  1. Detect — Identify the failing test and reproduce the failure
  2. Inspect — Read error logs, stack traces, and screenshots
  3. Classify — Categorize the root cause (locator / timing / data / environment)
  4. Fix — Apply the appropriate fix strategy
  5. Verify — Re-run test multiple times to confirm stability

Common Flaky Causes & Fixes

Unstable Locator

Problem:

//div[3]/button
.css-1n2xyz-btn

Fix: Replace with stable locator following priority in .agents/rules/locator_strategy.md:

  • id, data-testid, name, css selector (stable), xpath (relative)

Timing Issues

Problem:

Thread.sleep(3000);       // Hard sleep — BAD
page.waitForTimeout(2000); // Fixed delay — BAD

Fix: Use smart waits as defined in .agents/rules/selenium_rules.md and .agents/rules/playwright_rules.md:

// Selenium
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("result")));

// Playwright
await expect(page.getByRole('button', { name: 'Submit' })).toBeVisible();

Test Data Conflicts

Problem: Tests share mutable data → parallel runs conflict.

Fix: Use unique, traceable random data:

<testName>_<timestamp>@test.com

Stability Checklist

After fixing a flaky test, verify:

  • Locator is unique and stable across reloads
  • No hard sleep or fixed delays
  • Test data is unique and deterministic
  • Test is independent (no dependency on other tests)
  • Test passes 5+ consecutive runs

Rules References

The agent MUST follow these rules when analyzing flaky tests:

  • .agents/rules/locator_strategy.md — Locator stability rules
  • .agents/rules/automation_rules.md — General automation best practices
  • .agents/rules/selenium_rules.md — Selenium wait strategy
  • .agents/rules/playwright_rules.md — Playwright auto-waiting

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.