meaningful-identifiers

Enforces descriptive naming for callback parameters and local variables in TypeScript code.

1.6k|122|Updated Jul 15, 2019
One-click install
npx skills add https://github.com/hashintel/hash --skill meaningful-identifiers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: meaningful-identifiers
Source: https://github.com/hashintel/hash/tree/main/.agents/skills/meaningful-identifiers
Command: npx skills add https://github.com/hashintel/hash --skill meaningful-identifiers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript codebases often accumulate vague variable names like step, left, or column in callbacks and loops, making code harder to read and review. This Skill provides clear naming rules so callback parameters and local variables describe the values they actually hold.

Core Features & Use Cases

  • Callback Parameter Naming: Ensures array callback parameters in map, filter, and find are named after the element's domain type, such as batches.map((batch) => ...).
  • Accumulator Naming: Requires reduce accumulators to be named after what they accumulate, like sum or total, instead of generic names like step.
  • Correct-Use Preservation: Leaves legitimate names untouched, such as (left, right) in sort comparators or column over a real .columns array.
  • Use Case: When refactoring a data-processing module, apply these rules to rename misleading identifiers in loops and callbacks without breaking correct existing conventions.

Quick Start

Review my TypeScript file and rename any callback parameters or local variables that do not describe the values they hold.

Frequently Asked Questions about meaningful-identifiers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I name array callback parameters in TypeScript?

Name array callback parameters after the element's domain type, such as `batches.map((batch) => ...)` or `checkpoints.find((checkpoint) => ...)`. Avoid reusing names like `right`, `left`, or `column` for values that are not sort operands or table columns.

What should I name a reduce accumulator in JavaScript?

Name a reduce accumulator after what it accumulates, such as `sum` or `total` for a running total. Generic names like `step` hide the accumulator's purpose and make the reduction logic harder to follow.

When is it acceptable to use left and right as variable names?

Using `left` and `right` is correct in sort comparators like `(left, right) => left - right`, where they genuinely represent sort operands. They should not be reused for unrelated values in other callbacks.

Does this naming guidance apply to all loop variables?

No, correct existing uses are left untouched. For example, `for (const row of ...Rows)` is fine when items are genuinely rows, and `(column) => column.key` is fine over a real `.columns` array.

Why are vague variable names a problem in code reviews?

Vague names like `step` or misused domain nouns force reviewers to trace values back to their source to understand intent. Descriptive identifiers make callback and loop logic self-explanatory, reducing review time and misunderstanding.