Use ManagedCode.Communication when a .NET application needs explicit result objects, structured errors, and predictable service or API boundaries instead of exception-driven…
F# for .NET
Write, review, or modernize F# code in .NET repositories with functional-first design, algebraic data types, pattern matching, pipelines, async workflows, project ordering, and C# interop. USE FOR: F# .fs/.fsproj code; discriminated unions, records, options, results, pattern matching, computation expressions, or functional domain modeling; strongly typed AI-generated .NET code. DO NOT USE FOR: C# language modernization; FSI-only exploratory scripts with no project changes. INVOKES: inspect .fsproj file order and SDK settings, edit F# source and project files, and run dotnet build/test or dotnet fsi validation commands when changes are made.
Trigger On
- the task touches
.fs,.fsx,.fsi, or.fsprojfiles - domain logic benefits from records, discriminated unions, options, results, or exhaustive pattern matching
- generated code needs a strongly typed functional model instead of nullable primitive state
- F# code must interoperate with C# or other .NET libraries
- the repository needs project setup, source ordering, or validation for F# code
Workflow
- Inspect the existing
.fsproj,.fs,.fsi, and.fsxfiles to determine compile order, public boundaries, and whether the code is F#-first or C#-facing. - Choose the smallest F# model that represents the invariant: records for named product data, discriminated unions for closed state,
optionfor absence, andResultfor expected failures. - Add or edit source files in dependency order, then update the
.fsprojcompile list before consumers reference the new code. - Review public API shape for .NET interop. Translate F#-specific internal models to DTOs, methods, or
Try*patterns when C# callers need a stable surface. - Run
dotnet build, targeted tests, and any relevantdotnet fsiprobes before returning the final result.
Validate
Run the narrowest relevant checks after changes:
dotnet build
dotnet test
dotnet fsi scripts/check.fsx
If adding a new F# file, also inspect the project file diff to confirm the compile order is deliberate.
Related skills
Use ManagedCode.MimeTypes when a .NET application needs consistent MIME type detection, extension mapping, and content-type decisions for uploads, downloads, or HTTP responses.
Use the Microsoft.Extensions stack correctly across Generic Host, dependency injection, configuration, logging, options, HttpClientFactory, and other shared infrastructure…