# FSharp.Refactor

Offline F# analyzer that strips parentheses, swaps slow constructs for fast ones, and makes agent-written or legacy code say what it means.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed · ★ 16
- Author: Thorium
- License: Unlicense · policy=link-only · description only; the file stays with the author
- Source: https://github.com/Thorium/fsharp-refactor
- Updated: 2026-10-22
- HTML: https://affpapa.org/en/nevibecode/mcp/fsharprefactor

## What it does

The tool runs from the command line: `fsharp-refactor Your.fsproj --dry-run --api-changes` prints every change with file and line, `fsharp-refactor Your.fsproj --api-changes` applies them. Drop `--api-changes` to leave public methods alone. Inside: 150+ rules that swap `new FileStream` for `use`, string `Contains "x"` for char `Contains 'x'`, `match b with | true -> 1 | false -> 0` for `if b then 1 else 0`, and strip `new` before `StringBuilder()` and `Attribute` suffix from attributes.

Your project must compile before you run it: broken source is rejected upfront, and any edit that breaks the build stops execution with an error. Ships as a global dotnet tool, VS Code extension, Visual Studio 2022–2026 plugin, and NuGet analyzer package. MCP support is baked into the CLI version. Unlicense license.

## Install

### Claude Code (native platform)

**Install**
- The MCP registry has no launch command for it: see the repository README

## When to use it
- remove parentheses and the `new` keyword where they add no meaning
- replace `raise (Exception "text")` with `failwith "text"`
- move `Seq.toList` after `Seq.map` so the full sequence is not copied before mapping
- replace `match` on a boolean with `if`
- add interpolation to `failwith` with variables that show what went wrong

## Example prompts
- Run `fsharp-refactor src/Main.fsproj --dry-run` and show me what would change
- Apply all fixes to `Core.fsproj` with `fsharp-refactor Core.fsproj --api-changes`
- Refactor every project in `src/` without touching public signatures

## Similar
- [Front-End Checklist](https://affpapa.org/en/nevibecode/mcp/front-end-checklist.md) — MCP server · ★ 74559
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [Serena MCP: the IDE for your agent](https://affpapa.org/en/nevibecode/mcp/serena-mcp-the-ide-for-your-agent.md) — MCP server · ★ 30677
- [Repomix](https://affpapa.org/en/nevibecode/mcp/repomix.md) — MCP server · ★ 29027
- [Repowise](https://affpapa.org/en/nevibecode/mcp/repowise.md) — MCP server · ★ 7891
- [sem](https://affpapa.org/en/nevibecode/mcp/sem.md) — MCP server · ★ 3422

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
