NetFabric/intelligentium / plugins/dotnet-rx/.apm/skills/dotnet-rx
dotnet-rx
VerifiedDesign, implement, debug, review, and test Reactive Extensions for .NET (Rx.NET) pipelines with System.Reactive. USE FOR: IObservable<T>/IObserver<T>; Observable creation and adapters; LINQ-style operator selection; hot/cold/connectable streams; Subjects; Publish/Replay/RefCount/AutoConnect; schedulers and concurrency; disposal and cancellation; errors/retry; backpressure limits; Task/event/IAsyncEnumerable interop; virtual-time TestScheduler tests; Rx.NET 7 migration and UI packages. DO NOT USE FOR: ReactiveUI application architecture; RxJS/RxJava syntax; simple .NET events with no stream composition; producer-consumer workloads requiring built-in backpressure (prefer Channels or IAsyncEnumerable).
.NET Reactive Extensions (Rx.NET)
Use System.Reactive for composable push-based streams whose values, timing, completion, and errors all matter. Treat ReactiveX documentation as conceptual; verify names and behavior against Rx.NET because implementations differ.
Anatomy
| File | Purpose | Target Size |
|---|---|---|
SKILL.md | Routing, workflow, invariants, and minimum safe pattern | <100 lines |
references/*.md | Rx.NET-specific semantics, examples, edge cases, and review checks | <200 lines each |
Workflow
- Inspect the project target, installed Rx version, and framework-specific packages; load packages-and-versioning.md for Rx.NET 7 migrations.
- Classify each source by temperature, cardinality, finiteness, producer pace, subscription side effects, owner, terminal behavior, and notification context.
- Confirm Rx is the right abstraction; prefer
Task<T>for one result,IAsyncEnumerable<T>for async pull, events for simple notification, orChannel<T>for bounded producer-consumer flow. - Compose built-in factories and operators before writing a subject, custom source, or custom operator.
- Make ordering and overlap explicit with
Concat,Merge,Switch,Zip, orCombineLatest; operator order changes behavior. - Put scheduling decisions at the subscription boundary, inject schedulers used for time, and preserve serialized notifications.
- Define error, cancellation, and disposal behavior; bound every replay, grouping, queue, retry, and concurrency surface that can grow.
- Test values, terminal notifications, subscription windows, and disposal with virtual time; never make timing tests sleep.
Contract
| Concern | Required model |
|---|---|
| Grammar | Zero or more OnNext, then at most one OnError or OnCompleted: (OnNext)*(OnError|OnCompleted)? |
| Serialization | A source must not overlap callbacks for one subscription, including reentrant terminal calls |
| Termination | No notification follows OnError or OnCompleted; either terminal signal ends the sequence |
| Disposal | Dispose requests unsubscription; it does not emit OnCompleted; no callbacks may occur after Dispose returns |
| Evaluation | Most factories and operators are lazy and create one upstream subscription per downstream subscription unless explicitly shared |
| Flow control | Rx.NET has no general cross-thread demand protocol; queued scheduler boundaries and adapters can grow without bound |
Canonical Pattern
IObservable<SearchResult> results = searchTerms
.Throttle(TimeSpan.FromMilliseconds(250), timerScheduler)
.DistinctUntilChanged()
.Select(term => Observable.FromAsync(
cancellationToken => SearchAsync(term, cancellationToken)))
.Switch()
.ObserveOn(resultScheduler);
IDisposable subscription = results.Subscribe(
onNext: Render,
onError: ReportFailure);
Throttle waits for inactivity, FromAsync starts per subscription and observes disposal through its token, Switch keeps only the newest inner subscription, and ObserveOn controls downstream notification context.
Guardrails
- Always provide an error path at the final subscription boundary.
- Never pass an
asynclambda to anAction<T>-basedSubscribe; model async work withFromAsyncand flatten it. - Avoid blocking
First,Last,Single,ForEach,Wait, andToEnumerable; use their observable or awaitable alternatives. - Prefer
Observable.Create,Defer,Using, and operator composition over hand-writtenIObservable<T>implementations. - Expose
IObservable<T>, not a mutable subject; useAsObservablewhen the implementation must contain a subject. ObserveOnqueues every notification. When only the newest scheduled value matters, schedule cancellable inner observables andSwitch; test the exact scheduler behavior.- Carry owner or generation identity through queued session-sensitive work and revalidate it after asynchronous boundaries.
- Bound
Replay,Distinct,GroupBy,Buffer,ObserveOn, and concurrent inner sequences according to source lifetime and rate.
Reference Files
| File | Load When |
|---|---|
| references/model-and-lifetimes.md | Defining contracts; reasoning about hot/cold/connectable sources, subscription side effects, serialization, completion, and disposal |
| references/creating-and-interop.md | Creating sources; adapting events, tasks, enumerables, async streams, cancellation, and await boundaries |
| references/operator-selection.md | Choosing Rx.NET operators and distinguishing flattening, pairing, temporal, filtering, partitioning, and aggregation semantics |
| references/scheduling-and-concurrency.md | Selecting schedulers; placing SubscribeOn/ObserveOn; handling UI affinity, reentrancy, synchronization, and deadlocks |
| references/subjects-and-multicasting.md | Choosing subject types or replacing them; sharing subscriptions with Publish, Replay, RefCount, and AutoConnect |
| references/errors-resources-and-flow.md | Designing error recovery, retries, cancellation, disposable ownership, resource lifetime, and overload protection |
| references/testing.md | Writing deterministic tests with TestScheduler, hot/cold observables, recorded notifications, and subscription assertions |
| references/custom-operators-and-review.md | Implementing unavoidable custom sources/operators and reviewing Rx code for contract, lifetime, concurrency, and memory defects |
| references/packages-and-versioning.md | Selecting packages/namespaces, migrating to Rx.NET 7, and distinguishing Rx.NET, Ix, async LINQ, and experimental AsyncRx.NET |
| references/sources.md | Rechecking claims against official Rx.NET, ReactiveX, NuGet, and Microsoft documentation |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |