ReScript — 173 Operations for AI Agents
This page is the canonical reference an AI coding agent uses to refactor, query, and analyze ReScript code through the act MCP server. 173 operations available: 99 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.
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-error-handling-to-promise |
Add .catch() to a promise chain |
add-export-declaration |
Mark a symbol as exported (adds interface annotation comment) |
add-import |
Add an open statement for a module |
add-import-alias |
Add a module alias declaration: module Alias = ModulePath |
add-missing-cases |
Add missing switch cases |
add-missing-record-fields |
Add missing required fields to a record literal |
add-module-open |
Prepend an open statement at the top of the file |
add-option-annotation |
Add option<type> annotation to a binding |
add-result-annotation |
Add result<ok_type, err_type> annotation |
add-return-type-annotation |
Add return type annotation to a function |
add-try-catch-around-await |
Wrap async operation in try-catch |
add-type-annotation |
Add a type annotation to a let binding |
add-type-annotation-to-param |
Add type annotation to a function parameter |
convert-callback-to-promise |
Wrap callback-based function in a Promise |
convert-concat-to-template-literal |
Convert ++ string concatenation to a template literal |
convert-curried-to-uncurried |
Convert a curried function (a => b => body) to uncurried form (. a, b) => body |
convert-exception-to-result |
Wrap an exception-raising expression in a result type |
convert-for-loop-to-array-filter |
Convert a for-in loop to an Array.filter call |
convert-for-loop-to-array-map |
Convert a for-in loop to an Array.map call |
convert-for-loop-to-array-reduce |
Convert a for-in loop to an Array.reduce call |
convert-for-loop-to-list-map |
Convert for loop to List.map |
convert-if-else-to-switch |
Convert an if-else chain to a switch expression |
convert-if-to-ternary |
Convert an if-else expression to a ternary (cond ? a : b) |
convert-imperative-to-functional |
Convert imperative mutation to functional pipeline |
convert-let-to-ref |
Convert a let binding to a mutable ref cell |
convert-null-to-none |
Replace Js.null / null with None |
convert-nullable-to-option |
Wrap a nullable JS value in option |
convert-positional-to-labeled-args |
Convert positional function parameters to labeled (~param) form |
convert-promise-chain-to-async |
Convert .then() chain to async/await |
convert-record-to-variant |
Convert a record type definition to a variant |
convert-ref-to-let |
Convert a ref cell back to an immutable let binding |
convert-switch-to-if-else |
Convert a switch expression to an if-else chain |
convert-ternary-to-if |
Convert a ternary expression to an if-else block |
convert-to-option-pattern-match |
Generate a switch pattern match for an Option variable |
convert-to-result-for-safety |
Wrap a fallible expression in a result type |
convert-to-result-pattern-match |
Convert try-catch to pattern match on result |
convert-uncurried-to-curried |
Convert an uncurried function (. a, b) => body to curried form a => b => body |
convert-while-to-recursion |
Convert while loop to tail-recursive function |
extract-condition-to-variable |
Extract complex condition to named binding |
extract-constant |
Extract a literal or expression into a top-level constant binding |
extract-function |
Extract selected lines into a new named function |
extract-record-type |
Extract an inline record literal to a named type |
extract-variable |
Extract an expression into a new local let binding |
extract-variant-type |
Extract an inline variant to a named type |
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-accessor-functions |
Generate getter accessor functions for each record field |
generate-documentation-comment |
Generate a doc comment block above a binding |
generate-equality-function |
Generate a structural equality function for a type |
generate-external-binding |
Generate a @external binding |
generate-function-stub |
Generate a function stub with Js.log("TODO") body |
generate-impl-stubs |
Generate implementation stubs inside a module block |
generate-module-type |
Generate a module type signature block |
generate-option-wrapper |
Generate an option<'a> wrapper |
generate-record-constructor |
Generate a type declaration for a record type |
generate-record-creator |
Generate a maker function (makeRecord) for a record type |
generate-record-type |
Generate a record type definition from field descriptions |
generate-record-updater |
Generate an updater function for a record |
generate-result-wrapper |
Generate a result<'a, string> error wrapper function |
generate-send-binding |
Generate a @send method binding |
generate-string-representation |
Generate a typeToString conversion function |
generate-test-case |
Generate a single test(...) case with Arrange/Act/Assert comments |
generate-type-definition-docs |
Generate a doc comment for a type |
generate-unit-test-scaffold |
Generate a describe/test scaffold for a module |
generate-variant-matcher |
Generate a pattern match function for a variant |
generate-variant-type |
Generate a variant type definition |
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)] |
inline-constant |
Inline a named constant by replacing all references with its value |
inline-variable |
Inline a let-bound variable by replacing uses with its value |
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)] |
introduce-local-binding |
Insert a new let binding at the specified line |
introduce-named-constant |
Extract a literal expression into a named top-level constant |
introduce-parameter-from-local |
Promote a local binding to a function parameter |
invert-if-condition |
Invert the condition of an if-else |
join-adjacent-strings |
Merge adjacent string literals joined with ++ |
make-field-optional |
Make a record field optional (option<'a>) |
move-to-module |
Move a symbol into a qualified module path |
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)] |
organize-imports |
Sort and deduplicate open statements alphabetically |
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-dead-code |
Remove unused declarations |
remove-import |
Remove an open statement for a module |
remove-module-open |
Remove a specific open statement from the file |
remove-unnecessary-else |
Remove else branch after early return |
remove-unused-parameter |
Remove a parameter that is never used in the function body |
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)] |
rename-identifier |
Rename a variable, function, or binding across its scope |
rename-record-field |
Rename a field in a record type definition |
reorder-parameters |
Reorder the parameters of a function definition |
use-option-flat-map |
Convert nested option map to flatMap |
use-option-get-or |
Convert switch on option to Option.getOr |
use-option-instead-of-if |
Replace an Option null-check if-statement with Option.isSome / Option.isNone |
use-option-map |
Convert switch on option to Option.map |
use-record-shorthand |
Convert {x: x} to {x} shorthand |
use-result-flat-map |
Convert nested result map to flatMap |
use-result-map |
Convert switch on result to Result.map |
use-spread-operator |
Convert manual field copies to record spread |
wrap-in-option-for-safety |
Wrap a potentially-missing value binding in Option |
wrap-value-in-option |
Wrap an expression in Some(...) |
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