| name | clean-code-naming |
| description | Use when choosing names for variables, functions, classes, or modules — applies Clean Code naming principles for clear, intention-revealing identifiers |
Clean Code: Naming
Based on Robert C. Martin's Clean Code, Chapter 2: Meaningful Names.
When to Use This Skill
Trigger on:
- Naming or renaming variables, functions, classes, modules
- Code review flagging unclear identifiers
- Debates about naming conventions
- "What should I call this?" questions
Rules
1. Use Intention-Revealing Names
A name should tell you why it exists, what it does, and how it is used.
d = 86400
elapsed_time_in_days = 86400
SECONDS_PER_DAY = 86400
2. Avoid Disinformation
Don't use names that mean something subtly different than what they represent.
account_list = get_accounts()
accounts = get_accounts()
3. Make Meaningful Distinctions
Don't use noise words that don't add meaning.
def copy(a, b): ...
def copy1(source, destination): ...
def copy(source, destination): ...
4. Use Pronounceable Names
If you can't say it, you can't discuss it.
genymdhms = datetime.now()
generation_timestamp = datetime.now()
5. Use Searchable Names
Single-letter names are hard to search. The length of a name should correspond to its scope.
for j in range(len(users)):
if users[j].age > 18:
...
for user in users:
if user.age > 18:
...
6. Avoid Encodings
Don't prefix names with type information (Hungarian notation) or member prefixes.
m_dsc = "description"
str_name = "Alice"
description = "description"
name = "Alice"
7. Class Names
Classes and objects should have noun or noun-phrase names. Avoid Manager, Processor, Data, Info.
8. Method Names
Methods should have verb or verb-phrase names. Accessors use get/set, predicates use is/has/can.
9. Don't Be Cute
Choose clarity over humor. whack() < delete(). holy_hand_grenade() < fast_delete().
10. Pick One Word Per Concept
Don't use fetch, retrieve, and get for the same concept. Pick one and stick with it.
11. Add Meaningful Context
Group related variables in a class or prefix consistently when context isn't available from scope alone.
Quick Checklist
Source
Distilled from Clean Code by Robert C. Martin, Chapter 2: Meaningful Names.