Reusable AI capability

Isolate and Stabilize Flaky Automated Test Failures

Diagnose intermittent CI or local test failures, identify the supported nondeterministic cause, and define a cause-specific stabilization plan with reliability evidence instead of hiding product defects.

This Skill is a reusable set of instructions based on the linked Amo.ng Prompt or Workflow. It tells you what to provide, how to apply the method and how to know when the task is complete. It does not run automatically.

Skill ID
AMO-S-000049
Based on
Prompt
Published

Copy Skill copies the full Skill instructions. Use with AI copies those instructions with a short guide for your chosen AI tool. Both actions only copy text—they do not send anything to an AI provider or run the Skill.

Purpose

Apply a repeatable flakiness investigation method that reproduces intermittent failures, separates product defects from test defects, traces timing, ordering, concurrency, isolation, fixture, environment, and data-dependency causes, and produces a minimal stabilization and verification plan.

Required inputs

Have these details available before following the usage instructions.

  • Failing test names, file paths, and relevant assertions or stack traces.
  • CI run history or local run evidence showing pass/fail frequency, timing, environment, commit range, and any correlated changes.
  • Relevant test code, fixtures, setup/teardown, mocks, clocks, seeds, network or database dependencies, and shared-state behavior.
  • Repository test commands and constraints, including whether repeated runs, sharding, randomization, or stress runs are authorized.
  • Any prior attempted fixes, quarantines, skips, or known product defects related to the test.

How to use this Skill

When to use:
- A test fails intermittently in CI or locally and the team needs evidence before quarantining, rewriting, or trusting it.
- A recent change appears unrelated but correlates with sporadic test failures.
- A test suite has order dependencies, shared state, timing assumptions, race conditions, external service variance, or environment-specific failures.
- A team needs a reliability measurement plan after a proposed flaky-test repair.

When not to use:
- The failure is deterministic and already has a clear root cause; use ordinary debugging instead.
- The goal is to suppress, delete, or quarantine failing tests without investigating whether they reveal a real product defect.
- No failure logs, run history, test code, environment details, or reproduction attempts are available.
- The issue is a production incident rather than a test-suite reliability problem.

Instructions:
1. Open AMO-P-000236, supply its required inputs, and run the complete source Prompt in Codex. Review its evidence register and limitations before using the result. Use the authorized repository environment; a text-provider relay cannot inspect or change the repository for you. Inspect repository instructions and existing changes first, preserve unrelated work, and keep edits, commands and external actions within explicit authorization.
2. Separate supplied facts, observed run evidence, assumptions, inferences, missing information, and uncertainty before recommending a fix.
3. Build a hypothesis table covering likely nondeterministic causes such as timing, concurrency, async waits, test ordering, shared mutable state, stale fixtures, external dependencies, random data, clocks, retries, and environment differences.
4. Distinguish product behavior regressions from test harness defects; do not label a test flaky merely because it fails intermittently.
5. Define the smallest cause-specific repair or test-design change, plus any product-code investigation needed if the test is exposing a real defect.
6. Specify verification runs proportionate to risk, such as repeated local runs, CI reruns, randomized order, stress loops, affected-suite execution, and regression checks for nearby behavior.
7. For merge, quarantine, deletion, or CI policy changes, present evidence and options for human review rather than treating the AI recommendation as authorization.

Expected output:
A flakiness investigation brief containing reproduction evidence, ranked root-cause hypotheses, product-defect versus test-defect assessment, proposed minimal stabilization, test/CI verification plan, residual risks, and a human-reviewed merge or quarantine recommendation where applicable.

Constraints and boundaries:
- Do not claim tests were run, failures reproduced, or code changed unless execution evidence is supplied.
- Do not recommend weakening assertions, adding arbitrary sleeps, or broad retries unless tied to a supported cause and verified as safe.
- Do not hide suspected product defects by changing only the test.
- Require human authorization for merge decisions, test quarantine, CI policy changes, or production-impacting code changes.
- Preserve privacy and secrets in logs; redact tokens, credentials, customer data, and sensitive environment values.

Based on an Amo.ng Prompt

Test Flakiness Reproduction and Stabilization Workflow

Open the linked Prompt to read the instructions this Skill is based on.

Open prompt

Completion criteria

Complete when:
- The output cites concrete failure evidence, run IDs, logs, files, commands, or supplied excerpts for each material finding.
- At least one root-cause hypothesis is falsifiable and mapped to a specific reproduction or discrimination check.
- The proposed stabilization directly addresses the supported cause rather than masking symptoms.
- Reliability criteria and the repetition budget are supplied or human-approved, with exact commands and comparable before/after cohorts. Report first-attempt failures separately from retries; zero observed failures is not proof of zero residual flakiness. Unknown thresholds remain unresolved.
- Remaining uncertainty, missing evidence, and human decision points are explicit.

Was this useful?

Browse Prompts