Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    flaky

    2

    Systematically diagnose and fix nondeterministic, racy, or timing-dependent .NET and Rx test failures.

    $5

    /mo

    Subscription · cancel anytime

    Secure checkout via Stripe

    • Always the latest version
    • Delivered live to your agent via MCP
    • Cancel anytime, access ends at period end
    Security scanned
    flaky

    flaky

    Example session with this skill installed

    A test in IVI.Flow.CoreTests is failing in CI with 'The collection was empty' at an assertion following a Task.Delay(200). It passes locally. Fix this flake.

    • Read your context and instructions
    • Compiled the flaky

    The failure matches

    Shape A (assertion after a fixed delay). The 200ms delay is insufficient on a loaded CI runner, causing the assertion to fire before the pipeline settles. I will replace the fixed delay with a deterministic polling loop.

    Refactored Test Logic

    // Before: await Task.Delay(200, ct); Assert.Single(results);
    // After: Use WaitUntilAsync to poll for the expected state
    
    await WaitUntilAsync(
        () => results.Count > 0,
        "waiting for pipeline to emit at least one result",
        ct
    );
    
    Assert.Single(results);
    
    // ... existing WaitUntilAsync implementation ...
    private static async Task WaitUntilAsync(Func<bool> condition,
                                             string description,
                                             CancellationToken ct,
                                             int timeoutMs = 4000) {
      var stopwatch = Stopwatch.StartNew();
      while (!condition()) {
        Assert.True(stopwatch.ElapsedMilliseconds < timeoutMs, $"Timed out waiting for: {description}");
        await Task.Delay(20, ct);
      }
    }
    

    Next steps

    1. Run for i in $(seq 1 20); do dotnet test --filter NameOfTest || echo "FAILED"; done to verify.
    2. Search for other instances of Task.Delay followed by assertions in the same test assembly.
    3. Check if CurrentThreadScheduler can be injected into the FlowGraph to remove the need for polling entirely.
    $5/mo

    Subscription · always the latest version

    • Secure checkout via Stripe
    • Cancel anytime
    • Delivered live via MCP

    About this skill

    Intermittent test failures, race conditions, and CI timeouts slow down development cycles and erode trust in the build pipeline. This skill provides a systematic approach to diagnosing and fixing nondeterministic test failures in .NET and Reactive Extensions (Rx) environments by identifying specific failure "shapes" rather than applying arbitrary delays.

    What it does

    • Reproduces flakes using specific shell loops and project-level concurrency settings to flush out timing issues.
    • Classifies failures by matching logs to known patterns like fixed-delay assertions, thread pool starvation, and Rx subscription races.
    • Applies canonical fixes such as replacing Task.Delay with polling loops or switching to synchronous CurrentThreadScheduler execution.
    • Fixes production races by identifying where test failures actually signal disposal order defects or thread-safety issues in the application code.
    • Ensures thread safety by migrating vulnerable collections to concurrent types like ConcurrentQueue<T> to prevent modification exceptions.

    How it works

    1. Reproduce the failure using a seq loop and dotnet test with specific filters to establish a baseline failure rate.
    2. Classify the defect by comparing the assertion message and stack trace against the ten defined failure shapes (A through J).
    3. Remediate by implementing the specific recommended fix, such as using WaitUntilAsync or adjusting the TestScheduler sharing logic.
    4. Verify the solution with 20 consecutive successful runs and a full project test sweep.

    Frameworks & tools

    Specifically designed for .NET environments using xUnit, Reactive Extensions (Rx.NET), and custom TestScheduler implementations. It targets systems involving background event loops, dynamic port binding, and complex object disposal chains.

    Why this beats prompting it yourself

    Generic AI often suggests increasing timeouts or adding retries, which merely hides defects. This skill encodes tribal knowledge of deep Rx-specific race conditions and provides battle-tested code snippets that solve the underlying architectural synchronization issues.

    Use cases

    • Eliminating InvalidOperationException caused by List<T> modification during Rx subscriptions.
    • Fixing CI-only hangs in asynchronous tests that rely on virtual time vs wall-clock time.
    • Resolving ObjectDisposedException during test teardown in complex multi-threaded systems.

    Known limitations

    Requires access to the .NET CLI and xUnit runner configurations. It is optimized for Rx-heavy codebases and may not apply to simple, synchronous unit tests.

    Requires .NET CLI and xUnit. Specifically optimized for Rx.NET and TestScheduler logic; less effective for non-reactive race conditions.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 26 days ago

    Requires

    Microsoft
    Jetbrains
    Visualstudio
    dotnet

    Permissions

    Terminal / Shell
    Network Access

    Allowed Hosts

    dotnet.microsoft.com
    www.jetbrains.com
    code.visualstudio.com
    visualstudio.com

    Needs to access to source code and its unit tests.

    Listed26 days ago

    What's inside

    Frequently Asked Questions

    This skill identifies the root cause of intermittent failures—such as thread pool starvation or Rx subscription races—and applies permanent architectural fixes instead of simply increasing timeouts or adding flaky-test retries.

    The skill is purpose-built for the .NET ecosystem, specifically targeting xUnit, Reactive Extensions (Rx.NET), and asynchronous code utilizing the Task Parallel Library (TPL).

    You will receive the AI skill package ready for deployment to your agent, including the diagnostic logic for ten specific failure 'shapes' and the remediation library for common Rx synchronization issues.

    Yes, the skill requires access to your local or CI environment's .NET CLI and xUnit runner to execute reproduction loops and verify that the proposed fixes actually stabilize the build.

    While it excels at fixing test code, it is also designed to identify when a test failure is actually a symptom of a production race condition, such as unsafe collection modifications or improper disposal chains.

    New in Testing & Debugging