Why Grammar Checkers Shouldn't Touch Your Code
A rant about AI tools that "helpfully" rename variables, break SQL queries, and generally make developers' lives harder. Plus: what to look for in code-aware tools.
I have a simple test for any AI writing tool that claims to work with code:
Does it change your variable names?
If the answer is yes, throw it out. Here’s why.
The Variable Name Problem
You write this JavaScript:
const u = users.find(u => u.id === id);
A grammar checker “helpfully” rewrites it to:
const user = users.find(user => user.id === id);
Seems fine, right? Until you remember that u is referenced in seventeen other files in your codebase. Now you have a bug to track down.
Or maybe you have:
SELECT u.id, u.name FROM users u WHERE u.active = 1;
Some AI says “this is hard to read” and rewrites it as:
SELECT users.id, users.name FROM users WHERE users.active = 1;
Now your query is ambiguous (which users table if there are joins?) and slower (full table names vs aliases).
The Real Issue
These tools don’t understand that code is not prose. In prose, clarity means longer, more descriptive words. In code, clarity often means shorter, more established patterns.
Consider:
// Prose: "The user object contains their personal information"
// Code: const u = getUser(id);
The short form is clearer in context. The variable name u carries implicit meaning: it’s a user, it’s local, it’s being defined now.
Variable names in code serve a different purpose than words in prose. AI tools that treat code as text will break your code.
What Code-Aware Tools Actually Do
A tool that’s actually aware of code will:
- Only modify comments and documentation — Never touch function names, variable names, or logic
- Preserve formatting — Keep indentation, line breaks, and spacing
- Understand syntax — Know that
//starts a comment and/* */is a different syntax - Respect domain conventions — Keep
ias a loop counter,erras an error variable
Our Code Comment Sanitizer does exactly this:
// Input
// fn get usr data - Brokne!!!
// Output
// Retrieve user data
// Handles connection failures gracefully
Notice: the comment is improved, but the function signature getUserData(userId) stays exactly as-is.
The Checklists
Before using any “AI for code” tool, ask:
- Does it preserve variable names?
- Does it preserve function signatures?
- Does it only modify comments/documentation?
- Does it understand the language’s comment syntax?
If the answer to any of these is “no” or “I don’t know,” find a different tool.
The Bottom Line
Code is not prose. Writing tools that don’t understand this will cause bugs. Your AI writing assistant should enhance your documentation without touching your logic.
If it “improves” your code, it’s probably breaking it.
This post is a simplified version of a longer rant I almost published called “In Defense of Single-Letter Variables.” Maybe next time.