F# — 144 Operations for AI Agents

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze F# code through the act MCP server. 144 operations available: 70 refactor, 18 query, 42 analysis, 14 verification. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.

18Query
70Refactor
42Analysis
14Verify

Worked F# examples

act101 rewrites F# expressions at the syntax-tree level: it can add a when guard to a pattern-match case, insert an open declaration for a module, collapse two consecutive List.map stages of a pipeline into one, and collapse nested function calls into a |> pipeline. Each operation locates its target — a match arm, an if expression, an insertion point, a call chain — by walking the parsed source, so the same edit applies regardless of how the surrounding code is formatted. Because F# favors expressions over statements, act101's conversions rewrite one expression form into an equivalent one rather than inserting imperative scaffolding. Each example below is the verbatim output of the command shown, run against the file shown.

Add a guard to a pattern-match case

option.fs matches x with Some n -> n and None -> 0, with no condition on n.

$ act refactor-lang add_guards_to_pattern --file option.fs --params '{"guard_condition":"x > 0","line":2,"column":3}'

Before

match x with
| Some n -> n
| None -> 0

After

match x with
| Some n when x > 0 -> n
| None -> 0

The Some n -> n arm becomes Some n when x > 0 -> n, so that arm only matches when the guard holds.

Add an open declaration for a module

classify.fs uses List functions but opens no modules.

$ act refactor-lang add_module_open --file classify.fs --params '{"module_name":"System.IO","line":1,"column":1}'

Before

let x = List.map (fun n -> n * 2) [1..10]

After

open System.IO
let x = List.map (fun n -> n * 2) [1..10]

open System.IO is inserted as the first line; the existing binding is left as written.

Collapse two pipeline stages into one

shapes.fs pipes a list through two consecutive List.map calls.

$ act refactor-lang simplify_pipeline --file shapes.fs --params '{"line":1,"column":12}'

Before

let data = list |> List.map (fun x -> x + 1) |> List.map (fun x -> x * 2)

After

let data = list |> List.map (fun x -> (x + 1) * 2)

The two maps fuse into a single List.map whose lambda applies both transformations, (x + 1) * 2, so the list is traversed once.

Convert nested calls to a pipeline

trim.fs computes result by nesting String.length (String.trim input), reading right-to-left.

$ act refactor-lang convert_to_pipeline --file trim.fs --params '{"line":1,"column":14}'

Before

let result = String.length (String.trim input)

After

let result = input |> String.trim |> String.length

The nested calls become input |> String.trim |> String.length, the same two calls applied left-to-right through |>.

Query

18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.

callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch

Refactor

Operation Description
add-computation-expression Convert sequence of operations to computation expression
add-guards-to-pattern Add when guards to pattern match cases
add-let-binding Convert expression to named let binding
add-list-operation Add list/array operation (map, filter, fold)
add-module-declaration Add module declaration to file
add-module-open Add open statement for namespace/module
add-mutable-keyword Add mutable keyword for ref-type binding
add-option-unwrap Add |> Option.value or pattern match for Option
add-pattern-match Convert if-else to pattern match
add-record-field Add field to record definition
add-required-import Add missing open/module reference
add-result-unwrap Add error handling for Result type
add-string-interpolation Convert plain string to interpolated string
add-try-with Wrap risky operation in try-with
add-type-annotation Add explicit type annotation to parameter or return
add-underscore-binding Replace unused binding with _
add-union-case Add new case to discriminated union
add-wildcard-pattern Add wildcard (_) pattern to pattern match
add-xml-doc-comment Generate XML documentation comment for declaration
convert-exception-handling Convert try-catch to Result type
convert-from-pipeline Convert pipeline expression to nested calls
convert-if-to-match Convert simple if-then-else to pattern match
convert-imperative-to-functional Convert imperative loop to fold/map
convert-match-to-function Create function from match expression
convert-string-concat-to-interpolation Convert string concatenation to string interpolation
convert-to-list-comprehension Convert for loop to list comprehension syntax
convert-to-module-function Move nested function to module level
convert-to-option Convert None/null handling to Option<T>
convert-to-pipeline Convert nested function calls to pipeline (|>)
convert-to-record Convert tuple or class to record type
convert-to-result Convert error handling to Result<T, E>
convert-to-seq-expression Convert list to lazy seq expression
convert-try-to-result Convert try-with to Result/Option
expand-pattern-match Convert pattern match back to if-else
extract-constant Extract value to named constant
extract_function Extract a code selection into a new function — automatically infers parameters, return types, and inserts the call site. Use instead of manually cutting/pasting code. Works without LSP; LSP improves type inference. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool), receipt (bool)]
extract_variable Extract an expression into a named variable — inserts the declaration and replaces the expression with the variable name. Works without LSP. Params: file (string), new_name (string), start_line (u32), start_column (u32), end_line (u32), end_column (u32) [, preview (bool)]
generate-accessors Generate getters/setters for fields
generate-builder Generate builder pattern
generate-constructor Generate constructor from fields
generate-discriminated-union Create discriminated union from cases
generate-equals Generate equals/eq comparison method
generate-from-json Generate JSON deserialization
generate-function Create function skeleton with signature
generate-hash Generate hash/hashCode method
generate-match-expression Create match expression skeleton
generate-option-handler Create Option handling function
generate-pattern-match Create pattern match with all union cases
generate-property-getter Create property accessor function
generate-record-type Create record type from fields/examples
generate-result-handler Create Result error handling function
generate-test-function Create unit test function skeleton
generate-to-json Generate JSON serialization
generate-to-string Generate string representation
generate-type-annotation Create explicit type signature for function
generate-validation-function Generate validation function with Result/Option
inline Inline a variable, function, or method — replace every usage with its definition body, then remove the original. The inverse of extract. Works without LSP (single-file); LSP enables cross-file inlining. Params: file (string), symbol (string) [, line (u32), preview (bool), receipt (bool)]
insert_body Replace a function's implementation body with new code. AST-validated — rejects if the result has parse errors, so you can't accidentally break syntax. Use instead of manual text editing for function rewrites. Params: file (string), symbol (string), code (string) [, commit (bool)]
move_symbol Move a function, class, or type to a different file and automatically update all imports across the codebase. Use instead of manually cut/paste + fixing imports. Works without LSP (single-file); LSP enables cross-file import updates. Params: file (string), symbol (string), destination (string) [, preview (bool), receipt (bool)]
normalize-whitespace Fix inconsistent indentation
recipe_run Run a codemod recipe: declarative match → transform → optional verify across modeled grammars. Preview lists matches; apply writes with optional E7 receipts and all-or-nothing rollback. Returns a per-site report.
remove-mutable-keyword Remove mutable and use immutable alternative
remove-record-field Remove unused field from record
remove-unused-binding Remove unused let binding
remove-unused-import Remove unused open/module statement
rename Rename a symbol and automatically update ALL references across the codebase. Safer and faster than find-and-replace — AST-aware, won't rename strings or comments. Works without LSP (single-file); LSP enables cross-file renames. Params: file (string), old_name (string), new_name (string) [, line (u32), column (u32), preview (bool), receipt (bool)]
simplify-boolean-logic Remove redundant boolean operations (&&, ||)
simplify-nested-conditionals Reduce nesting depth in if-then-else
simplify-nested-match Consolidate nested pattern matches
simplify-pipeline Optimize or consolidate pipeline steps

Analysis

42 analysis tools, the same on every supported language. Descriptions live in the shared reference: /docs/analysis-tools.

analyze_api_diff analyze_chokepoints analyze_clones analyze_clusters analyze_cohesion analyze_conformance analyze_coupling analyze_cycle_risk analyze_cycles analyze_dead_code analyze_depth analyze_entry_points analyze_export analyze_extraction analyze_fan_balance analyze_features analyze_hotspots analyze_impact analyze_inconsistencies analyze_inheritance analyze_interface_bloat analyze_interfaces analyze_layers analyze_orphan_types analyze_patterns analyze_platform_deps analyze_readiness analyze_roles analyze_seams analyze_stability analyze_surface analyze_test_gaps analyze_thickness analyze_type_completeness churn_hotspots co_change_clusters coverage_overlay ownership_map profile_overlay simulate split_module trace_overlay

Verify

14 verify tools, the same on every supported language. Descriptions live in the shared reference: /docs/verification.

bisect_regression gate generate_test_harness scan secret_surface summarize_pr taint_flow unsafe_surface verify_behavioral_equivalence verify_contract_preserved verify_diff_semantics verify_port_parity verify_side_effects verify_test_impact

← FortranGDScript →