fix-flaky-tests — Claude Code skill: fix flaky tests
The skill reads a test's failure history in Tuist, works out the root cause and patches the test. Useful when a test passes and fails at random.
npx skills add tuist/agent-skills --skill fix-flaky-tests -a claude-codeWhat fix-flaky-tests does
Everything runs through the Tuist CLI. The skill pulls reliability metrics with tuist test case show <id-or-identifier> --json, lists flaky runs with tuist test case run list Module/Suite/TestCase --flaky --json, then reads the failure message, file path and line number from tuist test case run show <test-case-run-id> --json. It opens the source at that path and edits it.
With no test given, it discovers them itself: tuist test case list --flaky --json --page-size 50. Tests are grouped by suite, since several flaky cases in one suite often share a cause. It also checks whether failures share a test_run_id — those may come from a process crash rather than a bug in the test.
The skill carries a catalogue of usual suspects: missing waits and race conditions, shared state between tests, dependence on network, time or hardcoded paths, and ordering. Crashes are read from crash_report, including EXC_BREAKPOINT, EXC_BAD_ACCESS and EXC_CRASH. Fixes are meant to be the smallest change that removes the cause, with no refactoring around it. Verification is a repeated run through xcodebuild test with -test-iterations and -run-tests-until-failure; the skill suggests starting at 50–100 iterations for fast unit tests and 2–5 for slower integration ones. One caveat: a race or a CI-only timing issue may not reproduce locally, and then the skill works from logs and code analysis instead.
What it helps with
- find the cause of a test that fails intermittently
- tell a test bug apart from a process crash on CI
- remove a test's dependence on current time or timezone
- untangle tests that share global state
- confirm a fix with repeated test runs
Example prompts for the agent
- Investigate the failures of Module/Suite/TestCase and fix it
- Find every flaky test in the project and fix them
- Why does this test only fail on CI? Check the run history
How to install fix-flaky-tests
1Skills CLI (Vercel)
npx skills add tuist/agent-skills --skill fix-flaky-tests -a claude-code2Manually: put the files in place
~/.claude/skills/fix-flaky-tests/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/fix-flaky-tests/
1Skills CLI (Vercel)
npx skills add tuist/agent-skills --skill fix-flaky-tests -a codex2Manually: put the files in place
.agents/skills/fix-flaky-tests/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add tuist/agent-skills --skill fix-flaky-tests -a cursor2Manually: put the files in place
.cursor/skills/fix-flaky-tests/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install tuist/agent-skills fix-flaky-tests2Manually: put the files in place
.github/skills/fix-flaky-tests/SKILL.md1Skills CLI (Vercel)
npx skills add tuist/agent-skills --skill fix-flaky-tests -a gemini-cli2Platform CLI
gemini skills install https://github.com/tuist/agent-skills --path skills/fix-flaky-testsManually: put the files in place
.devin/skills/fix-flaky-tests/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add tuist/agent-skills --skill fix-flaky-tests -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about fix-flaky-tests
How do I install fix-flaky-tests in Claude?
Run npx skills add tuist/agent-skills --skill fix-flaky-tests -a claude-code. The skill lands in ~/.claude/skills/fix-flaky-tests/SKILL.md.
What does fix-flaky-tests do?
It reads a test's metrics and run history in Tuist, traces the flakiness to a failure message and source line, and applies a targeted fix to the test.
Does fix-flaky-tests need Tuist?
Yes. Every step goes through the Tuist CLI — metrics, the list of flaky runs and failure details all come from its data.