On this page
  1. The problem: AI copies your naming chaos
  2. The naming system
    1. Descriptive: say what it does
    2. Searchable: make it findable
    3. Consistent: pick one pattern and stick to it
    4. Nouns for data, verbs for functions
    5. Booleans: is_*, has_*, should_*
  3. Renaming existing code
  4. Related topics
how-to

How to Name Things So AI Assistants Generate Better Code

AI assistants pattern-match on your existing names. Inconsistent naming produces inconsistent AI-generated code. Here's the naming system — descriptive, searchable, consistent — that makes AI assistants generate code that fits your project.

Quick answer

  • AI assistants learn naming patterns from your existing code. Be consistent or the AI picks randomly.
  • Names should be descriptive (what it does), searchable (grep-friendly), and consistent (one pattern across the codebase).
  • create_user is better than make. calculate_order_total is better than process.
  • Full guide: How to Make Your Codebase AI-Friendly

The problem: AI copies your naming chaos

You write get_user() in one file, fetch_order() in another, and retrieve_product() in a third. Then you ask the AI to add a new function. It generates get_customer() — or fetch_customer() — or retrieve_customer(). It picks randomly because your codebase has no pattern.

The AI is a pattern-matcher. If your codebase has a clear naming pattern, the AI follows it. If it has three different patterns, the AI picks one at random and your codebase gets more inconsistent.

The naming system

Descriptive: say what it does

# Bad: ambiguous — AI generates more ambiguous names
def process(x):
    return handle(x)

def do_stuff(data):
    return transform(data)

# Good: descriptive — AI generates matching descriptive names
def create_user(email: str, name: str) -> User:
    ...

def calculate_order_total(items: list[OrderItem]) -> float:
    ...

def validate_email_address(email: str) -> bool:
    ...

Every function name should answer: “What does this do, and to what?” The AI reads create_user and generates create_order. It reads process and generates… process2.

Searchable: make it findable

# Unsearchable — grep "make" matches hundreds of lines
def make(x): ...
def build(x): ...
def setup(x): ...
def init(x): ...

# Searchable — each name is unique and grep-pable
def create_subscription(user_id, plan): ...
def build_docker_image(tag): ...
def initialize_database(): ...
def configure_logging(level): ...

If you can’t grep for it, the AI can’t reliably reference it. Searchable names also make it possible to find every caller when you refactor.

Consistent: pick one pattern and stick to it

For each operation type, pick one verb:

OperationPatternDon’t use
Createcreate_*make, new, build, add
Readget_*fetch, retrieve, find, load
Updateupdate_*set, modify, change, edit
Deletedelete_*remove, destroy, drop, clear
Calculatecalculate_*compute, process, determine
Validatevalidate_*check, verify, ensure, assert
Formatformat_*render, display, show, print
Handle eventshandle_* or on_*process_event, do_thing

When the AI sees create_user, create_order, create_session, it generates create_payment. When it sees make_user, new_order, add_session, it guesses.

# Consistent (AI follows the pattern)
def create_user(...): ...
def create_order(...): ...
def create_session(...): ...
# AI generates: def create_payment(...): ...

# Inconsistent (AI guesses)
def make_user(...): ...
def new_order(...): ...
def add_session(...): ...
# AI generates: def build_payment(...): ... (wrong pattern)

Nouns for data, verbs for functions

# Functions: verb_noun
def get_active_users(): ...
def calculate_shipping_cost(): ...
def validate_email_address(): ...

# Variables: descriptive nouns
active_users = get_active_users()
shipping_cost = calculate_shipping_cost()
is_valid_email = validate_email_address(email)

Booleans: is_*, has_*, should_*

# AI reads this pattern and generates matching booleans
is_active = True
has_orders = len(orders) > 0
should_retry = attempt_count < max_retries
can_delete = user.is_admin and order.status == "pending"

# Not:
active = True         # is it a noun or a boolean?
orders = len(o) > 0   # shadows the actual orders list
retry = count < max   # ambiguous

Renaming existing code

When you find inconsistent names, rename them. The AI picks up the new pattern immediately.

# Find all similar-but-different patterns
grep -r "def make_" src/
grep -r "def new_" src/
grep -r "def add_" src/

# Standardize on create_*
# (use your editor's rename refactor, not sed)

One rename session — standardizing 20 functions — produces better AI output forever.

Where this bites vibecoders

The vibecoder names things quickly: data, result, temp, x. The AI reads these and generates more of the same. Six months of AI-assisted coding produces a codebase where every variable is named data and every function is named process. Standardizing names early — 10 minutes of renaming — prevents the AI from amplifying the chaos.


Share: