Works with the AI Agents you already use
flaky
Systematically diagnose and fix nondeterministic, racy, or timing-dependent .NET and Rx test failures.
$5
/moSubscription · cancel anytime
Secure checkout via Stripe
- Always the latest version
- Delivered live to your agent via MCP
- Cancel anytime, access ends at period end
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
- Run
for i in $(seq 1 20); do dotnet test --filter NameOfTest || echo "FAILED"; doneto verify. - Search for other instances of
Task.Delayfollowed by assertions in the same test assembly. - Check if
CurrentThreadSchedulercan be injected into theFlowGraphto remove the need for polling entirely.
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.Delaywith polling loops or switching to synchronousCurrentThreadSchedulerexecution. - 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
- Reproduce the failure using a
seqloop anddotnet testwith specific filters to establish a baseline failure rate. - Classify the defect by comparing the assertion message and stack trace against the ten defined failure shapes (A through J).
- Remediate by implementing the specific recommended fix, such as using
WaitUntilAsyncor adjusting theTestSchedulersharing logic. - 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
InvalidOperationExceptioncaused byList<T>modification during Rx subscriptions. - Fixing CI-only hangs in asynchronous tests that rely on virtual time vs wall-clock time.
- Resolving
ObjectDisposedExceptionduring 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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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
Permissions
Allowed Hosts
Needs to access to source code and its unit tests.