CLI tool that fixes grammar, spelling, and syntax errors in Markdown files using a local LLM (LMStudio).
Shows a colored diff of proposed changes and asks for your approval before applying them.
- Fix grammar, spelling, and syntax in Markdown without changing meaning
- Colored diff display for reviewing changes
- Interactive approve/skip/quit workflow per file
--automode for batch processing without prompts- Supports single files, multiple files, and directories (recursive
*.mddiscovery) - Uses local LMStudio (OpenAI-compatible API) - your data stays on your machine
- Go 1.21+
- LMStudio running locally with a model loaded
go install github.com/glebnaz/markdown-refactor/cmd/mdrefactor@latestOr build from source:
git clone https://github.com/glebnaz/markdown-refactor.git
cd markdown-refactor
go build -o mdrefactor ./cmd/mdrefactor- Download and install LMStudio
- Download a model (any instruction-following model works, e.g. Llama 3, Mistral, Qwen)
- Load the model in LMStudio
- Start the local server - by default it runs on
http://localhost:1234 - Run
mdrefactoragainst your Markdown files
mdrefactor [flags] <file|dir> [file|dir...]
| Flag | Default | Description |
|---|---|---|
--auto |
false |
Apply all changes without asking for approval |
--endpoint |
http://localhost:1234 |
LMStudio API endpoint |
Fix a single file (interactive):
mdrefactor README.mdFix multiple files:
mdrefactor docs/guide.md docs/api.mdFix all Markdown files in a directory recursively:
mdrefactor docs/Auto-apply all changes without prompts:
mdrefactor --auto docs/Use a custom LMStudio endpoint:
mdrefactor --endpoint http://192.168.1.100:1234 README.mdFor each file with changes, mdrefactor will:
- Show a colored diff (green = additions, red = removals)
- Prompt you to approve:
- Y - Apply changes to the file
- N - Skip this file
- Q - Quit processing
After all files are processed, a summary is displayed:
3 file(s) fixed, 1 skipped, 1 unchanged
cmd/mdrefactor/main.go - Entry point, CLI parsing, orchestration
internal/llm/client.go - LMStudio API client
internal/files/reader.go - File discovery and reading
internal/files/writer.go - File writing
internal/diff/diff.go - Diff computation
internal/tui/diffview.go - Colored diff viewer (Bubble Tea)
internal/tui/approve.go - Approval prompt (Bubble Tea)
MIT