Back to .md Directory

instead of: tmp = make_payload(); send(tmp)

Defines a rule against pointless renames and aliases, requiring every new name to add semantic value.

May 2, 2026
0 downloads
0 views
ai
View source

What this file does

Defines a rule against pointless renames and aliases, requiring every new name to add semantic value.

When to use it

  • Enforcing naming discipline in a codebase review checklist
  • Onboarding new developers to project naming conventions
  • Auditing existing code for unnecessary aliases or terminology drift
  • Writing a style guide section on import and variable naming

title: Renames must pay rent (no random renames) kind: outcome

Do not introduce aliases or new names unless they add clear value (disambiguation, collision avoidance, or stronger semantics). Prefer one obvious name per concept and reuse it consistently.

Acceptance criteria (checklist)

  • No import aliasing without a concrete reason:
    • Disallowed: import json as j used only to shorten json.
    • Allowed with rationale: name collision (from httpx import Response as HttpxResponse), contextual disambiguation (from foo.api import Response as FooApiResponse), or to avoid overshadowing a local symbol.
  • No pass‑through aliases (one‑off renames) that add no semantics:
    • Disallowed: x2 = x; process(x2) when process(x) suffices.
    • Prefer inlining trivial values: process(make_value()) when readability is unchanged. See also: No one‑off vars.
  • Consistent terminology: do not refer to the same thing by multiple different names in the same scope/module (e.g., calling a MyServer() instance http_server in one place and processor elsewhere) unless the roles truly differ and are documented.
  • Contextual renames must strengthen meaning and then be used consistently:
    • Good: renaming a generic value to a domain‑specific one at the point its meaning becomes clear; drop the old name and continue with the precise one.
    • If the reason is non‑obvious, include a short inline comment (e.g., “avoid import cycle”, “disambiguate two Response types”). Misleading justifications violate Truthfulness.
  • Avoid introducing parallel synonyms for the same concept (e.g., interface vs protocol vs facade) unless they represent distinct, well‑defined abstractions.

Positive examples

Context adds semantics; new name replaces the old one:

unsanitized_input = url_query.get("i")
if our_command_mode == Command.BUY:
    phone_number = unsanitized_input  # domain meaning becomes clear here
    # ... use phone_number from here on; do not keep using unsanitized_input

Disambiguate two Response types:

from httpx import Response as HttpxResponse
from my_sdk.types import Response as MySdkResponse

def handle_http(r: HttpxResponse) -> MySdkResponse: ...

Avoid pass‑through alias; inline when simple:

# instead of: tmp = make_payload(); send(tmp)
send(make_payload())

Negative examples

Import alias without value:

import json as j  # ❌ pointless alias

data = j.loads(text)
# prefer: import json; data = json.loads(text)

One‑off alias adds no meaning:

x = foo()
x2 = x          # ❌ useless alias
process(x2)     # prefer: process(x)

Terminology drift for the same object:

server = MyServer()
http_server = server     # ❌ duplicate name for same instance
processor = server       # ❌ misleading name; not a processor

Notes

  • Renames should “pay rent”: resolve a collision, remove ambiguity, or increase semantic precision. Otherwise, keep the original name.
  • When you must rename for semantics, migrate fully to the new name in that scope; do not keep both alive.
  • Cross‑refs: No one‑off vars, Self‑describing names, and Truthfulness.

What's inside

4 acceptance criteria, 3 positive examples, 4 negative examples, 2 notes, 3 cross-references

Change this for your project

  • Replace ./no-oneoff-vars-and-trivial-wrappers.md with your own cross-reference path
  • Replace ./self-describing-names.md with your own cross-reference path
  • Replace ./truthfulness.md with your own cross-reference path

Where it goes

Keep in docs/ or alongside the feature. Agents read it to implement against a defined contract.

Worth borrowing

  • Require a comment for any non-obvious rename, preventing silent justifications
  • Prefer inlining trivial values over one-off variables to reduce indirection

Related Documents