fix-flaky-tests
Что он делает
Этот скилл расследует нестабильные автоматические тесты, которые проходят и падают без изменений в коде, и исправляет их. Он нужен разработчикам, которые хотят, чтобы их набор тестов был надёжным.
Когда использовать
- ✓Когда Tuist отметил тест как нестабильный и вы хотите его исправить.
- ✓Когда много тестов случайно падают и вы хотите найти общую причину.
- ✓Когда вы хотите найти и исправить все нестабильные тесты в проекте.
Ссылка на скилл
https://github.com/tuist/tuist/blob/main/skills/skills/fix-flaky-tests/SKILL.mdСкопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.
Как использовать
Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.
Готовое сообщение для вставки
Для Claude Code, Codex или Cursor: запустите в папке проекта, и скилл установится.
Скачайте SKILL.md и положите его в папку скиллов вашего агента.
Пример запроса к вашему ИИ
“Найди нестабильные тесты в моём проекте и исправь тот, который падает чаще всего.”
5 новых скиллов в неделю. 1 минута чтения.
Как это работает
Агент читает надёжность и данные о падениях каждого нестабильного теста, открывает его исходный код на указанной строке, определяет шаблон, который делает тест нестабильным, исправляет его и запускает тест несколько раз, чтобы проверить результат.
Технический текст (оригинальный SKILL.md)
Оригинальный текст автора на английском, прямо с GitHub.
Fix Flaky Tests
Quick Start
You'll typically receive a Tuist test case URL or identifier. Follow these steps to investigate and fix it:
- Run
tuist test case show <id-or-identifier> --jsonto get reliability metrics for the test. - Run
tuist test case run list Module/Suite/TestCase --flaky --jsonto see flaky run patterns. - Run
tuist test case run show <test-case-run-id> --jsonon failing flaky runs to get failure messages and file paths. - Read the test source at the reported path and line, identify the flaky pattern, and fix it.
- Verify by running the test multiple times to confirm it passes consistently.
If no specific test is provided, start with the Discovery section below.
Discovery
When no specific test case is provided, find all flaky tests in the project:
tuist test case list --flaky --json --page-size 50
This returns all test cases currently flagged as flaky. Key fields:
module.name/suite.name/name— the test identifieravg_duration— helps prioritize (fix fast unit tests first)is_quarantined— whether the test is already quarantined
Triage strategy:
- Group tests by suite — multiple flaky tests in the same suite often share a root cause.
- Check if failures share a
test_run_id— tests that all failed in the same run may have been killed by a process crash, not individual test bugs. - Look at failure messages to categorize: test logic bugs vs infrastructure issues (network errors, server 502s, conflicts on retry).
Investigation
1. Get test case metrics
You can pass either the UUID or the Module/Suite/TestCase identifier:
tuist test case show <id> --json
tuist test case show Module/Suite/TestCase --json
Key fields:
reliability_rate— percentage of successful runs (higher is better)flakiness_rate— percentage of runs marked flaky in the last 30 daystotal_runs/failed_runs— volume contextlast_status— current state
2. View flaky run history
tuist test case run list Module/Suite/TestCase --flaky --json
The identifier uses the format ModuleName/SuiteName/TestCaseName or ModuleName/TestCaseName when there is no suite. This returns only runs that were detected as flaky.
3. View full run history
tuist test case run list Module/Suite/TestCase --json --page-size 20
Look for patterns:
- Does it fail on specific branches?
- Does it fail only on CI (
is_ci: true) or also locally? - Are failures clustered around specific commits?
4. Get failure details
tuist test case run show <test-case-run-id> --json
Key fields:
failures[].message— the assertion or error messagefailures[].path— source file pathfailures[].line_number— exact line of failurefailures[].issue_type— type of issue (assertion_failure, etc.)repetitions— if present, shows retry behavior (pass/fail sequence)test_run_id— the broader test run this execution belongs tocrash_report— crash report data (present when the test runner crashed); containsexception_type,signal,exception_subtype, andtriggered_thread_frames
Code Analysis
- Open the file at
failures[0].pathand go tofailures[0].line_number. - Read the full test function and its setup/teardown.
- Identify which of the common flaky patterns below applies.
- Check if the test shares state with other tests in the same suite.
Common Flaky Patterns
Timing and async issues
- Missing waits: Test checks a result before an async operation completes. Fix: use
await, expectations with timeouts, or polling. - Race conditions: Multiple concurrent operations access shared state. Fix: synchronize access or use serial queues.
- Hardcoded timeouts:
sleep(1)or fixed delays that are too short on CI. Fix: use condition-based waits instead of fixed delays.
Shared state
- Test pollution: One test modifies global/static state that another test depends on. Fix: reset state in setUp/tearDown or use unique instances per test.
- Singleton contamination: Shared singletons carry state between tests. Fix: inject dependencies or reset singletons.
- File system leftovers: Tests leave files that affect subsequent runs. Fix: use temporary directories and clean up.
Environment dependencies
- Network calls: Tests hit real services that may be slow or unavailable. Fix: mock network calls.
- Date/time sensitivity: Tests depend on current time or tim
Частые вопросы
Как он находит нестабильные тесты?
Он перечисляет тесты, отмеченные как нестабильные, в аналитике тестов Tuist.
Что будет, если тест не указан?
Он находит нестабильные тесты в проекте и группирует их по наборам.
Как он проверяет исправление?
Он запускает тест несколько раз, чтобы убедиться, что тот стабильно проходит.
Подробности
Оригинальное описание автора
Fixes flaky tests by analyzing failure patterns from Tuist test insights, identifying root causes, and applying targeted corrections. Can be invoked with a specific test case URL (e.g. `https://tuist.dev/{account}/{project}/tests/test-cases/{id}`) or without arguments to discover and fix all flaky tests in the project.
repo: tuist/tuist
Популярность
- Звёзды на GitHub
- 5.9k
- Место в рейтинге
- #14544
- Лицензия
- —
- Обновлён
- 02.11.2026
Комментарии
- …
Другие скиллы из этого репозитория
analyze-selective-testing
5.9kПомогает агенту проверить, какие тестовые цели Xcode пропустило при избирательном тестировании, и понять, почему пропуски изменились между запусками.
compare-builds
5.9kПомогает агенту сравнить два запуска сборки Xcode, чтобы найти замедления, изменения в использовании кэша и новые проблемы.
compare-bundles
5.9kПомогает агенту сравнить два бандла приложения, чтобы найти изменения размера, добавленные и удалённые файлы и различия между платформами.
compare-cache-runs
5.9kПомогает агенту сравнить два запуска кэша, чтобы найти изменения в доле попаданий в кэш и объяснить, почему кэш был сброшен.
Похожие скиллы
test-driven-development
311kУчит агента сначала писать падающий тест, увидеть, что он падает, и только затем писать минимальный код, который его проходит, прежде чем создавать любую функцию или исправление.
verification-before-completion
311kУчит агента запускать настоящие проверки и читать их вывод, прежде чем утверждать, что задача, исправление или сборка готовы или проходят.
migrate-to-shoehorn
310kЗаменяет рискованные приведения типов в тестовых файлах на библиотеку shoehorn, чтобы тесты могли использовать неполные данные и проходить проверку типов.