Naming and Code Comments Taste

Naming and Code Comments Taste

Gives a senior reviewer's rules for naming and code comments, each with a confidence score, to guide code generation and review.

Naming and Code Comments taste of a senior engineer who reviews a lot of code

  • Name things for what they mean in the domain (invoiceDueDate), not for their type (dateString). Confidence: 0.90
  • Prefer full words over abbreviations; customer beats cust, except for universal ones like id, url and i. Confidence: 0.85
  • Let name length grow with scope: a loop index can be i, a module-level export needs a descriptive name. Confidence: 0.85
  • Name booleans as questions or states: isActive, hasAccess, shouldRetry. Confidence: 0.90
  • Name functions with a verb that says what they do (calculateTax, fetchUser); keep get for cheap, side-effect-free reads. Confidence: 0.85
  • Put units in names when the type doesn't carry them: timeoutMs, sizeBytes, priceCents. Confidence: 0.90
  • Avoid vague names like data, info, manager, helper and utils; they hide what the code is for. Confidence: 0.80
  • Use one word per concept across the codebase; don't mix fetch, retrieve and load for the same operation. Confidence: 0.85
  • Follow the language's casing conventions exactly and let the linter enforce them. Confidence: 0.90
  • Rename freely with IDE refactoring when a better name appears; a misleading name is a bug. Confidence: 0.80
  • Write comments that explain why, not what; the code already says what. Confidence: 0.95
  • Delete a comment that just restates the next line. Confidence: 0.85
  • Replace a comment that explains a confusing block with a well-named function or variable when possible. Confidence: 0.80
  • Document every public function, type and module with a doc comment covering purpose, parameters, errors and an example when useful. Confidence: 0.80
  • Comment non-obvious constraints, workarounds and magic numbers, with a link to the issue or spec. Confidence: 0.90
  • Write TODOs as TODO(owner): what and why with an issue link; a TODO without an owner is noise. Confidence: 0.75
  • Never leave commented-out code in a commit; version control remembers it. Confidence: 0.95
  • Update or delete comments in the same change that makes them stale. Confidence: 0.90
  • Keep comments in plain English, short and in complete sentences. Confidence: 0.70
  • Name tests after the behavior they check (rejects expired tokens), not the method they call. Confidence: 0.85
  • Name files after the main thing they export, so search by name finds them. Confidence: 0.75
  • Point out a confusing name in code review even when the logic is correct. Confidence: 0.80

Public domain (CC0 1.0) · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 12,036 prompts

More by @OpenSourceBuffGuy

See all
Olive Scribble Sports Poster Style prompt image

Olive Scribble Sports Poster Style

Defines a JSON style spec for kinetic sports posters: oversized action figures in rough black ink on olive blocks, with red marker arcs, dry-brush swaths and screenprint texture.

image-prompt, json-prompt, poster, illustration, printmaking, sports, ink-drawing, typography, text-rendering, limited-palette, flat-design, motion-blur, editorial, placeholders, structured-output, style-reference, vertical-format, widescreen, for-artists, for-designers, long-form, advanced, template, character-design

Legacy Circuit Mockups prompt image

Legacy Circuit Mockups

Generates breadboard circuit mockups and diagrams with HTML5 Canvas for retro electronics builds using chips like the 6502 and 555 timer.

agent-skill, electronics, html, javascript, diagram, creative-coding, code, html-page, embedded-systems, computer-science, long-form, for-developers, for-engineers, documentation, step-by-step-guide

DevOps Workflow Design Expert prompt image

DevOps Workflow Design Expert

Acts as a DevOps workflow designer who plans branching, CI/CD pipelines, infrastructure as code, observability, incident management and DORA metrics.

system-prompt, act-as, devops, ci-cd, infrastructure-as-code, observability, incident-response, git, runbook, kubernetes, aws, for-devops-engineers, for-developers, release-management, site-reliability, workflow-automation, deployment, best-practices, xml-tags, structured-output, roadmap, advanced, gitops

Reviews

Loading reviews…

Discussion

Loading comments…