Command Palette

Search for a command to run...

Назад к скиллам
скилл № 70744

hoc-naming

Naming conventions for the identifiers in code — classes, members, variables and parameters. Use when choosing or reviewing a name. The super-prefix a method…

БесплатноБез исполняемых скриптов
openreachtechот openreachtech★ 17 звёзд на GitHub

Установить hoc-naming в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Shared: Naming

Summarizes naming conventions.

Class names

  • Class names are written in UpperCamelCase.
  • Use the singular form of a noun.
  • Reason: if a plural noun is used, you cannot define a variable name for "an array holding instances of that class." This is because there is no way to express "the plural of instances of a plural-named class."
  • When no specific class name is dictated, name the class to describe the logic it encapsulates.
// NG
class Users {}
const users = [new Users(), new Users()] // Cannot express "plural of instances of a plural class"

// OK
class User {}
const users = [new User(), new User()]

Name variables and properties holding arrays as plural nouns

  • A variable or property that holds an array (a value with multiple elements) is always named with "the plural form of the noun denoting its element."
  • This is the counterpart of the "class names are singular" rule (see "Class names"). If the element's class is the singular User, its array is the plural users.
  • Do not express plurality with a List suffix (see list in references/prohibited-words.md).
// NG: named singular despite holding an array / expressing plurality with a List suffix
const user = users.filter(it => it.enabled) // holds an array yet named singular
const paymentList = payments.filter(it => it.completed)

// OK: plural form of the noun denoting the element
const enabledUsers = users.filter(it => it.enabled)
const completedPayments = payments.filter(it => it.completed)

A variable holding constructors starts with a capital

  • A variable or property that holds an array of constructors starts with a capital, as a class name does (MiddlewareCtors): its elements are classes, and Ctor is the word for a class held as a value.
  • A variable that holds a plain object starts lowercase, however it was imported. A capital initial tells the reader that the value is made of classes.
import MiddlewareCtors from './middleware-ctors.js' // an array of classes
import middlewareHash from './middleware-hash.js' // a plain object

The parameters of a higher-order function's callback

  • How a callback's parameters are named — it, and the accumulator of reduce() — belongs to /hoc-higher-order-functions.

Naming abstract classes and derived classes

  • Prefix abstract classes with Base~.
  • When extending BaseSample for a specific application, add App as in BaseAppSample.
  • The Base~ and App~ in BaseAppSample are called "super prefixes."
  • When naming a derived class, remove the super prefix (Base~ / App~), keep the suffix, and replace it with a distinguishing prefix.
// Abstract class
class BaseSample {}

// Abstract class extended for the application
class BaseAppSample extends BaseSample {}

// Derived classes (super prefix removed and replaced with a distinguishing prefix; suffix "Sample" is kept)
class AlphaSample extends BaseSample {}
class BetaSample extends BaseAppSample {}

An interface name carries no distinguishing prefix

  • Where a module accepts a set from its caller and also holds a set of its own, the name on the side the caller sees is the plain one (MiddlewareCtors), and the distinguishing word goes to the module's own side (BundledMiddlewareCtors).
  • A word such as extra on the caller's side leaks the module's internal split into every call site. The module is the one that knows it holds two sets, so the module is the one that names the difference.

Method names are "predicates," not "complete sentences"

  • A method call receiver.method() has a structure resembling a sentence: "subject (receiver) + predicate (method)."
  • Therefore, a method name should be named as a predicate with the receiver as the subject, not as a "complete sentence with both subject and predicate."
// NG: named as a complete sentence (object.isStatusValid() reads as "object is status valid?", which is unnatural)
isStatusValid () {
  return this.status !== null
}

// OK: named as a predicate (object.isValidStatus() reads as "object is valid status")
isValidStatus () {
  return this.status !== null
}

Property syntax and "messages to the receiver"

  • In the property syntax object.alpha, each token is called: object = receiver, . = dot operator, alpha = property.
  • A method is a property in the broad sense. It is a property whose value is a function, invoked with (); object.methodName is property access, and object.methodName() is the notation for executing that value "as a function."
  • Hence a method call is a message where "receiver = subject, method name = predicate," and follows a sentence-like structure such as object.doSomething() (object does something) / object.isValid() (object is valid).
  • #isStatusValid() is wrong because it treats the method name as "a complete sentence with subject and predicate combined (Is st
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/abbreviations.md
  • references/antonyms.md
  • references/prohibited-words.md
  • references/spelling.md
  • references/verbs.md

FAQ

Что делает скилл hoc-naming?

Naming conventions for the identifiers in code — classes, members, variables and parameters. Use when choosing or reviewing a name. The super-prefix a method name carries belongs to the method super-prefix convention; constants, to the constants convention; a skill's name, to the skill-updating convention; commit verbs, to the git commit convention.

Как установить скилл hoc-naming?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл hoc-naming запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить hoc-naming с