Claude defaults to names that are conventionally correct but semantically thin. A function checking if a subscription expired becomes checkSubscription() instead of isSubscriptionExpired(). A list of users with unpaid invoices becomes users instead of usersWithUnpaidInvoices.
The safe names pass review. They also make code harder to read six months later.
Why this happens
Claude names things based on what they are, not what they do in context. Without knowing how a function is used, it picks the safest generic label.
The fix: ask explicitly
Adding "use names that describe what the function does, not just what it operates on" changes output noticeably. Or more directly, ask before writing the code:
"This function checks if a user's subscription has expired. What should it be called?"
Evaluate the options, pick one, then write the code. Names decided upfront stick better than names changed after.
Questions that produce better names
- "What does this return — boolean, object, ID?" (return type guides naming)
- "What's the caller doing with this result?" (use case informs the name)
- "What would make this name misleading?" (constraints sharpen it)
isAccountLocked() is fine. hasExceededLoginAttemptLimit() tells you why it's locked. Which level of specificity is right depends on how many callers need to understand the distinction.
Variable names: context over type
Claude names variables after their types: user, order, response. Fine at declaration, ambiguous when multiple users or orders are in scope.
Ask for context: "Name variables to reflect what they represent in this function, not just their type."
pendingOrder vs completedOrder. originalUser vs updatedUser. These carry information that order1, order2 don't.
The comment test
If you find yourself writing a comment to explain what a variable does, that's usually a sign the name should be better. The comment is compensating.
Fix the name, delete the comment.
You can ask Claude: "Here's a function with this name. Suggest a better name that makes this comment unnecessary." Works well.
More Claude Code patterns: builtbyzac.com/blog.html
Top comments (0)