Dev Tools

Prettier Got An AI Plugin And It Actually Works

All articles
🪄🧠

Local LLM-backed rename refactors on format — yes, really

Plot twist: Prettier — the most boring tool in your stack — just got an AI plugin. It formats your code AND suggests rename refactors based on what the variable actually does. Local LLM, no API key.

The Setup

`prettier-plugin-ai` uses a small local model (Qwen 2.5 Coder 1.5B by default) to analyse the AST and propose rename suggestions for badly-named identifiers. It runs after the format pass and writes suggestions as inline comments you can accept or ignore.

bun add -d prettier prettier-plugin-ai
# the plugin will pull the model on first run via ollama
ollama pull qwen2.5-coder:1.5b

The Money Pattern

Add it to your prettier config and behold — it's a one-liner:

{
  "semi": false,
  "singleQuote": true,
  "plugins": ["prettier-plugin-ai"],
  "ai": {
    "model": "qwen2.5-coder:1.5b",
    "mode": "suggest",
    "rules": ["rename-unclear", "rename-abbrev", "extract-magic-number"]
  }
}

Run `bun x prettier --write src/` and watch your `let x = data.map(d => d.t)` get a `// suggest: const titles = posts.map((post) => post.title)` comment above it.

The Catch

It's slow. Format-on-save goes from 20ms to 400-600ms on a typical file, which is enough to feel laggy in Cursor. Run it in `mode: suggest` rather than `apply`, and consider a pre-commit hook instead of save-on-format. Also: it occasionally suggests renaming `i` to `loopIndex` which is, you know, not it.

The Verdict

For a codebase you've inherited or a pile of vibe-coded Pipedrive scripts, this thing is a cleanup superpower. For your daily save-on-format loop, keep it off. Run it as a weekly hygiene pass and let Claude Code follow the suggestions. Try it once.

Let us make some quick suggestions?
Please provide your full name.
Please provide your phone number.
Please provide a valid phone number.
Please provide your email address.
Please provide a valid email address.
Please provide your brand name or website.
Please provide your brand name or website.