{"data":{"slug":"github-donchitos-claude-code-game-studios-claude-skills-test-flakiness-6a4045e92021","title":"Detect Flaky Tests in CI Logs","summary":"Identify flaky tests by analyzing CI logs and test result history from multiple runs. This skill aggregates pass rates, spots intermittent failures, and recommends quarantine or fixes based on flakiness thresholds.","url":"https:\/\/skillshunter.net\/skills\/github-donchitos-claude-code-game-studios-claude-skills-test-flakiness-6a4045e92021","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-donchitos-claude-code-game-studios-claude-skills-test-flakiness-6a4045e92021","markdown_url":"https:\/\/skillshunter.net\/skills\/github-donchitos-claude-code-game-studios-claude-skills-test-flakiness-6a4045e92021.md","download_url":"https:\/\/skillshunter.net\/skills\/github-donchitos-claude-code-game-studios-claude-skills-test-flakiness-6a4045e92021\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"If fewer than 3 runs are available, every finding is labeled as *suspected* and quarantine is not recommended. Ensure at least 3 runs are available for accurate flakiness detection.","instructions":"---\nname: test-flakiness\ndescription: \"Find flaky tests from CI logs \u2014 aggregates pass rates, spots intermittent failures, recommends quarantine. After multiple runs.\"\nargument-hint: \"[ci-log-path | scan | registry]\"\nuser-invocable: true\nallowed-tools: Read, Glob, Grep, Write, Edit, Bash(ls -t *), Bash(bash \"*\/.claude\/skills\/test-flakiness\/..\/..\/hooks\/yaml-helper.sh\" resolve_config *)\nmodel: sonnet\n---\n\n!`bash \"${CLAUDE_SKILL_DIR}\/..\/..\/hooks\/yaml-helper.sh\" resolve_config --keys automation`\n\n**Automation mode**: Resolve `modes.automation` (`project.local.yaml` \u2192\n`project.yaml` \u2192 default `collaborative`). Every `AskUserQuestion` call and\nevery file write follows `.claude\/docs\/automation-modes.md`\n(collaborative asks always \u00b7 guided major-only \u00b7 autonomous logs and proceeds;\n`automation_always_ask` categories always prompt).\n\n# Test Flakiness Detection\n\nA flaky test is one that sometimes passes and sometimes fails without any code\nchange. Flaky tests are worse than no tests in some ways \u2014 they train the team\nto ignore red CI runs, masking genuine failures. This skill identifies them,\nexplains likely causes, and recommends whether to quarantine or fix each one.\n\n**Output:** Updated `tests\/regression-suite.md` quarantine section + optional\n`production\/qa\/flakiness-report-[date].md`\n\n**When to run:**\n- Polish phase (tests have had many runs; statistical signal is reliable)\n- When developers start dismissing CI failures as \"probably flaky\"\n- After `\/regression-suite` identifies quarantined tests that need diagnosis\n\n---\n\n## 1. Parse Arguments\n\n**Modes:**\n- `\/test-flakiness [ci-log-path]` \u2014 analyse a specific CI run log file\n- `\/test-flakiness scan` \u2014 scan all available CI logs in `.github\/` or\n  standard log output directories\n- `\/test-flakiness registry` \u2014 read existing regression-suite.md quarantine\n  section and provide remediation guidance for already-known flaky tests\n- No argument \u2014 auto-detect: run `scan` if CI logs are accessible, else\n  `registry`\n\n---\n\n## 2. Locate CI Log Data\n\n### Option A \u2014 GitHub Actions (preferred)\n\nCheck for test result artifacts:\n```bash\nls -t .github\/ 2>\/dev\/null\nls -t test-results\/ 2>\/dev\/null\n```\n\nFor Godot projects: GdUnit4 outputs XML results compatible with JUnit format,\nunder `reports\/` (its default report folder, `res:\/\/reports\/`). Check `reports\/`,\nand any `test-results\/` you saved runs into, for `.xml` files.\n\nFor Unity projects: game-ci test runner outputs NUnit XML to `test-results\/`\nby default.\n\nFor Unreal projects: automation logs go to `Saved\/Logs\/`. Grep for\n`Result={Success}` and `Result={Fail}` \u2014 each test prints\n`Test Completed. Result={<status>}`\n(`docs\/engine-reference\/unreal\/current-best-practices.md`, \"Command Line\").\n\n### Option B \u2014 Local log files\n\nIf a path argument is provided, read that file directly.\n\n### Option C \u2014 No log data available\n\nIf no logs found:\n> \"No CI log data found. To detect flaky tests, this skill needs test result\n> history from multiple runs. Options:\n> 1. Run the test suite at least 3 times and collect the output logs\n> 2. Check CI pipeline output and save a log to `test-results\/`\n> 3. Run `\/test-flakiness registry` to review tests already flagged as flaky\n>    in `tests\/regression-suite.md`\"\n\nStop and ask the user which option to pursue.\n\n---\n\n## 3. Parse Test Results\n\nFor each CI log or result file found, parse:\n\n**JUnit XML format** (GdUnit4):\n- Grep for `<testcase name=` to get test names\n- Grep for `<failure` or `<error` to identify failures\n- Parse `classname` and `name` attributes for full test identifiers\n\n**NUnit XML format** (Unity \u2014 the file whose `<test-run>` element `\/smoke-check`\nreads):\n- Each test is a `<test-case` element; its `fullname` attribute is the identifier\n- Its `result` attribute is `Passed`, `Failed`, `Inconclusive` or `Skipped`\n  (`docs\/engine-reference\/unity\/current-best-practices.md`, \"Command Line\");\n  only `Passed` and `Failed` enter the history\n\n**Plain text logs**:\n- Grep for pass\/fail patterns:\n  - Godot: `PASSED` \/ `FAILED` adjacent to test names\n  - Unreal: `Result={Success}` \/ `Result={Fail}`\n  - Unity: `Test passed` \/ `Test failed`\n\nBuild a table: `test_id \u2192 [run1_result, run2_result, run3_result, ...]`\n\n---\n\n## 4. Identify Flaky Tests\n\nA test is **flaky** if it appears in the result history with both PASS and\nFAIL outcomes across runs with no code changes between them.\n\nFlakiness thresholds:\n- **High flakiness**: Fails in >25% of runs \u2014 quarantine immediately\n- **Moderate flakiness**: Fails in 5\u201325% of runs \u2014 investigate and fix soon\n- **Low\/suspected flakiness**: Fails in 1\u20135% of runs \u2014 monitor; may be\n  genuinely rare failure\n\n**With fewer than 3 runs, every finding is *suspected*, whatever its fail rate.**\nOne failure in two runs reads as 50%, but it is one data point: do not\nquarantine it, label it suspected, and ask whether more run data is available.\nThe tiers above, and quarantine, apply from 3 runs up.\n\nFor each flaky test, classify the likely cause:\n\n### Cause classification\n\n| Cause | Symptoms | Fix direction |\n|-------|----------|---------------|\n| **Timing \/ async** | Fails after awaiting signals or timers; pass rate correlates with system load | Add explicit await\/synchronisation; avoid time-based delays |\n| **Order dependency** | Fails when run after specific other tests; passes in isolation | Add proper setup\/teardown; ensure test isolation |\n| **Random seed** | Fails intermittently with no pattern; involves RNG | Pass explicit seed; don't use `randf()` in tests |\n| **Resource leak** | Fails more often later in a test run | Fix cleanup in teardown; check orphan nodes (Godot) or object disposal (Unity) |\n| **External state** | Fails when a file, scene, or global exists from a prior test | Isolate test from file system; use in-memory mocks |\n| **Floating point** | Fails on comparisons like `== 0.5` | Use epsilon comparison (`is_equal_approx`, `Assert.AreApproximately`) |\n| **Scene\/prefab load race** | Fails when scenes are not yet ready | Await one frame after instantiation; use `await get_tree().process_frame` |\n\nUse Grep to check the test file for timing calls, randf, global state access,\nor equality comparisons on floats to narrow down the cause.\n\n---\n\n## 5. Recommend Action\n\nFor each flaky test:\n\n**Quarantine (High flakiness):**\n> \"Quarantine this test immediately. Skip it with the engine's own mechanism,\n> log it in the `tests\/regression-suite.md` quarantine section, and fix the root\n> cause before removing quarantine.\"\n\nSkip mechanisms, by engine \u2014 name only the one for the project's engine:\n- **Godot (gdUnit4), GDScript**: a skip parameter on the test function \u2014\n  `func test_x(_do_skip := true, _skip_reason := \"flaky: [cause]\")`. gdUnit4 reads\n  the argument names `do_skip` and `skip_reason` (a leading `_` is allowed) in\n  `addons\/gdUnit4\/src\/core\/GdUnitTestSuiteScanner.gd`, as of gdUnit4 6.2.2;\n  confirm them there for the installed version.\n- **Godot (gdUnit4), C#**: **NOT SOURCEABLE** \u2014 gdUnit4's C# test attributes are\n  not in the `addons\/gdUnit4\/` source, and `docs\/engine-reference\/godot\/` does not\n  cover them. Log it in the quarantine section and ask the user how their C#\n  tests are skipped; do not invent an attribute.\n- **Unity (NUnit)**: `[Ignore(\"flaky: [cause]\")]` \u2014 NUnit 3 requires the reason\n- **Unreal**: **NOT SOURCEABLE** \u2014 `docs\/engine-reference\/unreal\/` documents no way\n  to skip an automation test. Log it in the quarantine section and ask the user\n  how their CI excludes a test; do not invent a flag.\n\n**Investigate and fix soon (Moderate):**\n> \"This test is intermittently unreliable. Root cause appears to be [cause].\n> Suggested fix: [specific fix based on cause classification]. Do not quarantine\n> yet \u2014 fix the test directly.\"\n\n**Monitor (Low\/suspected):**\n> \"This test shows suspected flakiness. Collect more run data before\n> quarantining. Note it as 'suspected' in the regression suite.\"\n\n---\n\n## 6. Generate Reports\n\n### In-conversation summary\n\n```\n## Flakiness Detection Results\n\n**Runs analysed**: [N]\n**Tests tracked**: [N]\n\n### Flaky Tests Found\n\n| Test | System | Fail Rate | Confidence | Likely Cause | Recommendation |\n|------|--------|-----------|------------|--------------|----------------|\n| [test_name] | [system] | [N]% | confirmed | Timing | Quarantine + fix async |\n| [test_name] | [system] | [N]% | confirmed | Float comparison | Fix: use epsilon compare |\n| [test_name] | [system] | [N]% | suspected (fewer than 3 runs) | Order dependency | Collect more runs before acting |\n\n### Clean Tests (no flakiness detected)\n\n[N] tests ran across [N] runs with consistent results \u2014 no flakiness detected.\n\n### Data Limitations\n\n[Note if fewer than 5 runs were available \u2014 fewer runs = less statistical confidence]\n```\n\n---\n\n## 7. Update Regression Suite + Optional Report File\n\nAsk: \"May I update the quarantine section of `tests\/regression-suite.md`\nwith the flaky tests found?\"\n\nIf yes: use `Edit` to append entries to the Quarantined Tests table.\nNever remove existing quarantine entries \u2014 only add new ones.\n\nAsk (separately): \"May I write a full flakiness report to\n`production\/qa\/flakiness-report-[date].md`?\"\n\nThe full report includes per-test analysis with cause details and\nengine-specific fix snippets.\n\nAfter writing:\n\n- For each quarantined test: \"Add the engine-specific skip annotation to\n  disable this test in CI. Re-enable after the root cause is fixed.\"\n- For fix-eligible tests: \"The fix for [test] is straightforward \u2014\n  change the equality comparison on line [N] to use `is_equal_approx`.\"\n- Summary: \"Once all quarantine annotations are applied, CI should run green.\n  Schedule fix work for the [N] quarantined tests before the release gate.\"\n\n---\n\n## Collaborative Protocol\n\n- **Never delete test files** \u2014 quarantine means annotate + list, not remove\n- **Statistical confidence matters** \u2014 with < 3 runs, flag findings as\n  \"suspected\" not \"confirmed\"; ask if more run data is available\n- **Fix is always the goal** \u2014 quarantine is temporary; surface the fix\n  direction even when recommending quarantine\n- **Ask before writing** \u2014 both the regression-suite update and the report\n  file require explicit approval. On write: Verdict: **COMPLETE** \u2014 flakiness report written. On decline: Verdict: **BLOCKED** \u2014 user declined write.\n- **Flakiness in CI is a team problem** \u2014 surface the list and recommended\n  actions clearly; do not just silently quarantine without the team knowing\n","use_cases":["Analyze a specific CI log file for flaky tests","Scan all available CI logs in the project directory","Review existing flaky tests in the regression-suite.md file"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/Donchitos\/Claude-Code-Game-Studios\/blob\/abc0de79d6ceb0b5d7aa693945849b3937afbe6a\/.claude\/skills\/test-flakiness\/SKILL.md","source_commit":"abc0de79d6ceb0b5d7aa693945849b3937afbe6a","license":null,"version":null,"listing_approved_at":"2026-11-18","created_at":"2026-11-17T20:56:19.000000Z","updated_at":"2026-11-18T18:54:36.000000Z","seo_title":"Detect Flaky Tests in CI Logs","seo_description":"Find flaky tests from CI logs by aggregating pass rates and identifying intermittent failures. Get recommendations for quarantine or fixes based on flakiness thresholds.","seo_keywords":["detect flaky tests","analyze CI logs","find intermittent failures","quarantine flaky tests","test reliability analysis"]}}