Flaky Test Stabilizer
Testing & Qualityflaky-test-stabilizerFlaky Test Stabilizer is an Agent Skill for testing & quality published in the ShaftHQ/SHAFT_ENGINE repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Diagnose and stabilize intermittent SHAFT tests, especially TestNG parallelism, shared state, files, drivers, timing, and external dependencies.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/ShaftHQ/SHAFT_ENGINE/blob/HEAD/.github/skills/flaky-test-stabilizer/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/flaky-test-stabilizer, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Flaky Test Stabilizer
Use this playbook for intermittent, retry-only, parallel-only, or environment-sensitive failures.
Workflow
- Gather the exact failure, runner mode, retry history, affected test, and setup/teardown code. Do not begin with broad refactoring.
- Check high-probability causes in this order:
- per-method state stored in shared instance or static fields;
ThreadLocalvalues not removed;- one method deleting another method's files;
- global SHAFT properties or static services shared across classes;
- fixed sleeps or missing readiness polling;
- unordered/random assertions or external-service dependencies;
- browser sessions created accidentally by unit-test constructors.
- Remember that TestNG
singleThreadedisolates methods in one class, not static state shared with other classes. Use a cross-class lock where a static service genuinely cannot run concurrently. - Preserve the
allure-resultsroot during cleanup. Inspect retried/skipped result JSON when the final report is green. - Fix the ownership or synchronization defect without changing what the test
validates. Prefer local variables,
ThreadLocal, explicit locks, readiness polling, deterministic fixtures, and mocked external dependencies. - Run the focused test once. Repeat it or enable method parallelism only when repetition directly tests the suspected flake mechanism; stop after enough evidence establishes stability.
Output
State the failure signature, root cause and confidence, minimal fix, focused commands run, repetition/parallel evidence if applicable, and residual risk.