fix-flaky-tests
O que ela faz
Esta skill investiga testes automatizados instáveis, que passam e falham sem mudança no código, e os corrige. É para desenvolvedores que querem que a suíte de testes seja confiável.
Quando usar
- ✓Quando um teste está marcado como instável no Tuist e você quer que ele seja corrigido.
- ✓Quando muitos testes falham aleatoriamente e você quer encontrar a causa comum.
- ✓Quando você quer descobrir e corrigir todos os testes instáveis de um projeto.
Link da skill
https://github.com/tuist/tuist/blob/main/skills/skills/fix-flaky-tests/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Encontre os testes instáveis do meu projeto e corrija o que mais falha.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente lê a confiabilidade e os detalhes de falha de cada teste instável, lê o código-fonte na linha informada, identifica o padrão que causa a instabilidade, faz a correção e roda o teste várias vezes para confirmar.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Como ela encontra testes instáveis?
Ela lista os testes marcados como instáveis nos insights de teste do Tuist.
E se nenhum teste for informado?
Ela descobre os testes instáveis do projeto e os agrupa por suíte.
Como ela confirma uma correção?
Ela roda o teste várias vezes para verificar se ele passa de forma consistente.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 5,9 mil
- Posição no ranking
- #14544
- Licença
- —
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
analyze-selective-testing
5,9 milAjuda seu agente a verificar o quanto a seleção de testes do Xcode pulou alvos de teste sem mudanças e descobrir por que o pulo mudou entre execuções.
compare-builds
5,9 milAjuda seu agente a comparar duas execuções de build do Xcode para encontrar builds mais lentos, mudanças no uso de cache e problemas novos.
compare-bundles
5,9 milAjuda seu agente a comparar dois bundles de app para encontrar mudanças de tamanho, arquivos adicionados ou removidos e diferenças entre plataformas.
compare-cache-runs
5,9 milAjuda seu agente a comparar duas execuções de cache para encontrar mudanças nas taxas de acerto e explicar por que o cache foi invalidado.
Skills parecidas
test-driven-development
311 milEnsina seu agente a escrever primeiro um teste que falha, ver a falha e depois escrever o menor código que passa, antes de criar qualquer funcionalidade ou correção.
verification-before-completion
311 milEnsina seu agente a rodar verificações reais e ler a saída antes de afirmar que uma tarefa, correção ou build está concluído ou passando.
migrate-to-shoehorn
310 milSubstitui conversões de tipo arriscadas nos seus arquivos de teste pela biblioteca shoehorn, para que os testes usem dados parciais e ainda passem na checagem de tipos.