🤖 The AI Prompt That Names Your Variables Better Than You Do
Naming is the part of writing code that has the least to do with logic and the most to do with communicating intent to the next reader, which is exactly the kind of judgment call that’s easy to rush through when you’re mid-flow on the actual problem.
🔎 The Problem
Prompt: "Here is a function [paste it]. For every variable, parameter, and private field whose name is generic, abbreviated, or doesn't convey what it holds (think: data, temp, x, val, obj, flag, list1), suggest a more specific name based on how it's actually used in this code, and explain in one line why the new name is clearer than the old one."
✅ Fix: Why This Prompt Works
- It scopes the request to names that are already flagged as vague (generic, abbreviated), so you get a short, high-signal list instead of a rename of every identifier in the file whether it needed it or not.
- Asking for a one-line reason per suggestion means you can accept or reject each rename on its own merits instead of taking an all-or-nothing batch of changes.
- Grounding the suggestion in ‘how it’s actually used in this code’ keeps the model from guessing at intent from the name alone and instead reading the real usage, which is where bad names usually get caught.
💡 Good to Know
- Run this on code you wrote under deadline pressure — that’s reliably where the worst names (
flag2,tempList) end up living.
A variable named for what it is instead of what it holds costs you nothing today and someone else an afternoon six months from now.





