flaky-test-stabilizer
Flaky-test-stabilizer diagnoses and fixes intermittent test failures in SHAFT test suites, particularly those triggered by TestNG parallelism, shared state corruption, file system conflicts, timing issues, or external service dependencies. Use this skill when tests pass inconsistently, fail only under parallel execution, or succeed only on retry by systematically checking shared instance variables, ThreadLocal leaks, file deletions, static service contamination, hard-coded delays, and external API brittleness before applying targeted fixes that preserve test intent.
git clone --depth 1 https://github.com/ShaftHQ/SHAFT_ENGINE /tmp/flaky-test-stabilizer && cp -r /tmp/flaky-test-stabilizer/.github/skills/flaky-test-stabilizer ~/.claude/skills/flaky-test-stabilizerSKILL.md
# Flaky Test Stabilizer
Use this playbook for intermittent, retry-only, parallel-only, or
environment-sensitive failures.
## Workflow
1. Gather the exact failure, runner mode, retry history, affected test, and
setup/teardown code. Do not begin with broad refactoring.
2. Check high-probability causes in this order:
- per-method state stored in shared instance or static fields;
- `ThreadLocal` values 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.
3. Remember that TestNG `singleThreaded` isolates methods in one class, not
static state shared with other classes. Use a cross-class lock where a
static service genuinely cannot run concurrently.
4. Preserve the `allure-results` root during cleanup. Inspect retried/skipped
result JSON when the final report is green.
5. 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.
6. 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.Investigate GitHub Actions and SHAFT Allure failures from a run, PR, or job; separate code defects from infrastructure and provider failures.
Apply SHAFT production Java compatibility, API, properties, logging, Allure, and WebDriver rules when editing src/main Java files.
Apply SHAFT Java test lifecycle, parallelism, isolation, Allure, browser, and regression rules when editing src/test Java files.
Prepare or review a SHAFT release by checking reactor versions, metadata, examples, consumer fixtures, stable dependency updates, and Maven Central publication safeguards.
Archived historical SHAFT_ENGINE Gemma integration retained outside active skill discovery.