Naming code

How to name variables, keys and identifiers so related names group and grow predictably

Id general-naming-code Applies to any Status active Enforceable needs judgement Tags namingcode

Start generic, narrow to specific

By starting our names with generic ideas and narrowing to more specific, it’s easier to add adjacent code and ideas that follow the same pattern.

Prefer specific to vague

Specificity creates a natural growth path without needing to rename or rekey overly generic keys.

Use singular equivalent to plural in loops

By using the singular variant of a plural, it becomes clear what comes from what. It’s also preferred to avoid using data types as names; please put those in documentation.

❌ Avoid ✅ Preferred
for post in items for post in posts
for single in posts for post in posts
for object in objects for user in users