fix-flaky-tests
Was er macht
Dieser Skill untersucht unzuverlässige automatisierte Tests, die ohne Codeänderung mal bestehen und mal fehlschlagen, und behebt sie. Er ist für Entwickler, die eine verlässliche Testsuite wollen.
Wann du ihn nutzt
- ✓Wenn ein Test in Tuist als unzuverlässig markiert ist und du ihn beheben willst.
- ✓Wenn viele Tests zufällig fehlschlagen und du die gemeinsame Ursache finden willst.
- ✓Wenn du alle unzuverlässigen Tests eines Projekts finden und beheben willst.
Link zum Skill
https://github.com/tuist/tuist/blob/main/skills/skills/fix-flaky-tests/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Finde die unzuverlässigen Tests in meinem Projekt und behebe den, der am häufigsten fehlschlägt.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Agent liest die Zuverlässigkeit und Fehlerdetails jedes unzuverlässigen Tests, schaut sich den Quellcode an der gemeldeten Zeile an, erkennt das Muster, das die Unzuverlässigkeit verursacht, behebt es und führt den Test mehrmals aus, um es zu bestätigen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von 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
Häufige Fragen
Wie findet es unzuverlässige Tests?
Es listet Tests auf, die in den Testerkenntnissen von Tuist als unzuverlässig markiert sind.
Was ist, wenn kein Test angegeben wird?
Es findet die unzuverlässigen Tests im Projekt und gruppiert sie nach Suite.
Wie bestätigt es eine Korrektur?
Es führt den Test mehrmals aus, um zu prüfen, dass er konstant besteht.
Details
Originalbeschreibung des Autors
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
Beliebtheit
- GitHub-Sterne
- 5.9k
- Platz im Ranking
- #14544
- Lizenz
- —
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
analyze-selective-testing
5.9kHilft deinem Agenten zu prüfen, wie gut das selektive Testen von Xcode unveränderte Test-Targets übersprungen hat, und herauszufinden, warum sich das Überspringen zwischen Läufen geändert hat.
compare-builds
5.9kHilft deinem Agenten, zwei Xcode-Build-Läufe zu vergleichen, um langsamere Builds, Änderungen bei der Cache-Nutzung und neue Probleme zu finden.
compare-bundles
5.9kHilft deinem Agenten, zwei App-Bundles zu vergleichen, um Größenänderungen, hinzugefügte oder entfernte Dateien und Unterschiede zwischen Plattformen zu finden.
compare-cache-runs
5.9kHilft deinem Agenten, zwei Cache-Läufe zu vergleichen, um Änderungen der Cache-Trefferquote zu finden und zu erklären, warum der Cache ungültig wurde.
Ähnliche Skills
test-driven-development
311kBringt deinem Agenten bei, vor jedem Feature oder Fix zuerst einen fehlschlagenden Test zu schreiben, ihn fehlschlagen zu sehen und dann den kleinsten passenden Code zu schreiben.
verification-before-completion
311kBringt deinem Agenten bei, echte Prüfungen auszuführen und ihre Ausgabe zu lesen, bevor er behauptet, eine Aufgabe, ein Fix oder ein Build sei fertig oder bestehe.
migrate-to-shoehorn
310kErsetzt riskante Typumwandlungen in deinen Testdateien durch die Bibliothek shoehorn, damit Tests mit unvollständigen Daten arbeiten und trotzdem die Typprüfung bestehen.