Build F# Project
Purpose
Implement or modify an F# .NET project in F#'s own shape.
The practical goal is readable domain modeling, explicit data flow, good module boundaries, correct file ordering, useful tests, and validation through the repository's .NET commands.
When To Use
- Use this skill when the chosen language is F#.
- Use this skill when an existing
.fsprojneeds new source, tests, or package-facing API. - Use this skill when a mixed solution needs an F# library or domain project.
- Use this skill when code looks like translated C# and should be made idiomatic F#.
Source Check
Use repo-local .NET files, checked-out dependency sources, Dash MCP or Dash HTTP for installed .NET docsets, and then official Microsoft documentation when Dash/local coverage is missing or stale:
Inspect the repository before editing:
rg --files -g '*.fs' -g '*.fsproj' -g '*.sln' -g '*.slnx' -g 'global.json'
Implementation Workflow
- Read the existing
.fsprojand source ordering. - Identify the domain values and transformations.
- Prefer small modules with explicit inputs and outputs.
- Use records for named product data.
- Use discriminated unions for closed sets of alternatives.
- Use options and results for expected absence or recoverable failure.
- Keep side effects at the edge of the workflow.
- Add or update tests around the behavior changed.
- Run the narrowest useful validation command.
File Ordering
F# compiles files in project order.
Before adding a new file:
- decide which later files depend on it
- place shared domain types before modules that use them
- place entry points after the implementation they call
- update
.fsprojdeliberately
Do not assume globbed source discovery unless the project already proves it.
API Shape
For library APIs:
- expose a small set of clear modules and functions
- keep constructors and helpers close to the types they create
- avoid leaking implementation-only records or unions into public API
- provide C#-friendly APIs only when there is a real C# consumer
For apps:
- keep parsing, IO, environment reads, and process exits at the edge
- keep core transformations testable without shelling out
- return values that describe what happened before printing or logging them
Async And Task Interop
Use the existing project style first.
When calling modern .NET APIs from F#, be explicit about whether a function returns Async<'T>, Task<'T>, or a plain value. Avoid hiding task conversion in unrelated helpers. Explain the boundary when a public API exposes tasks for C# consumers.
Testing
Use the repository's existing test framework and command if present.
When no convention exists yet, use xUnit as the recommended scaffold default and keep command guidance centered on dotnet test. Preserve existing repo choices instead of migrating test frameworks casually.
Output Shape
Return:
F# change: what module, type, function, or project behavior changed.Data flow: inputs, transformations, side effects, and outputs.Project ordering: any.fsprojordering changes.Tests: what behavior is covered.Validation: exactdotnetcommands and result.
Guardrails
- Do not translate C# examples line-by-line into F#.
- Do not hide mutation or IO inside broad helpers when a pure transformation would be clearer.
- Do not add compatibility APIs for C# unless a C# caller exists or the user asks for one.
- Do not ignore
.fsprojfile ordering. - Do not skip tests for behavior changes when the repo has a test surface.