# Axiom Analyze Test Failures

Use when the user mentions flaky tests, tests that pass locally but fail in CI, race...

- Repository: https://github.com/CharlesWiltgen/Axiom (1242 stars)
- Category: Testing
- License: MIT
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add CharlesWiltgen/Axiom --skill axiom-analyze-test-failures -g -a claude-code -y`
Codex: `npx skills add CharlesWiltgen/Axiom --skill axiom-analyze-test-failures -g -a codex -y`
Cursor: `npx skills add CharlesWiltgen/Axiom --skill axiom-analyze-test-failures -g -a cursor -y`
Gemini CLI: `npx skills add CharlesWiltgen/Axiom --skill axiom-analyze-test-failures -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add CharlesWiltgen/Axiom`

## Description

Use when the user mentions flaky tests, tests that pass locally but fail in CI, race conditions in tests, or needs to diagnose WHY a specific test fails.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Test Failure Analyzer Agent

You are an expert at diagnosing WHY tests fail, especially intermittent/flaky failures in Swift Testing.

## Your Mission

Analyze the codebase to find patterns that cause flaky tests, focusing on:
- Swift Testing async patterns (missing `confirmation`, wrong waits)
- Swift 6 concurrency issues (`@MainActor` missing)
- Parallel execution races (shared state, missing `.serialized`)
- Timing-dependent assertions

## Files to Scan

Include: `*Tests.swift`, `*Test.swift`, `**/*Tests/*.swift`
Skip: `*/Pods/*`, `*/Carthage/*`, `*/.build/*`, `*/DerivedData/*`, `*/scratch/*`, `*/docs/*`, `*/.claude/*`, `*/.claude-plugin/*`

## Flaky Test Patterns (iOS 18+ / Swift Testing Focus)

### Pattern 1: Missing `await confirmation` (CRITICAL)

**Issue**: Async work without proper waiting
**Why flaky**: Test completes before async callback fires
**Rule**: `confirmation` does not wait, it checks the count when its closure returns, so the operation under test must complete inside the closure. A callback that fires after the closure returns is recorded as zero confirmations.
**Detection**: Closures/callbacks without `confirmation {}`

```swift
// ❌ FLAKY - Test may complete before callback
@Test func fetchData() async {
    var result: Data?
    service.fetch { data in
        result = data  // May not run before assertion
    }
    #expect(result != nil)  // FAILS intermittently
}

// ✅ CORRECT - The callback completes inside the confirmation body
@Test func fetchData() async {
    await confirmation { confirm in
        await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in
            service.fetch { data in
                #expect(data != nil)
                confirm()
                continuation.resume()
            }
        }
    }
}
```

### Pattern 2: `@MainActor` Missing on UI Tests (CRITICAL)

The rest: https://github.com/CharlesWiltgen/Axiom/blob/HEAD/axiom-codex/skills/axiom-analyze-test-failures/SKILL.md
