Command Palette

Search for a command to run...

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

hoc-classes-constructor

Conventions for class constructors. Constructor parameters must not have default values.

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

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

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

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

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

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

Classes: Constructor

Conventions related to class constructors.

Do not assign default values to parameters

  • Do not assign default values to constructor parameters.
  • The constructor's whole responsibility is to hold what its parameters receive. Each one is assigned to the property of the same name, and no value is decided here.
  • Deciding a value the caller did not supply belongs to the factory methods, static create (...) first among them. A default the constructor does not apply is applied there.
// NG: assigning a default value to a parameter
constructor ({
  delimiter = ',',
}) {
  this.delimiter = delimiter
}

// OK: no default value
constructor ({
  delimiter,
}) {
  this.delimiter = delimiter
}

Separate what goes up to the base from what this class keeps

Where a constructor hands part of its parameters to the base class and keeps the rest, a blank line divides the two in the parameter list. The reader then sees, without following super(), which of the properties this class is responsible for.

constructor ({
  ErrorCtor,

  maxDocumentDepth,
}) {
  super({
    ErrorCtor,
  })

  this.maxDocumentDepth = maxDocumentDepth
}
  • The factory methods repeat the same division, in their own parameter list and in the new this({ ... }) they assemble. A class states the split in one shape wherever the list appears, so a reader meeting .create() first learns the same thing.
  • A call that hands over the whole list carries no division: super({ ErrorCtor }) lists only the base's share, and nothing is separated inside it.
  • The JSDoc above it does not repeat the division. A JSDoc block has no blank line to divide with, and the *-only line that stands in for one is spent between the description and the first tag — see the JSDoc convention. The type literal stays a flat list of the same properties.
  • Tests do not repeat it either. A test assembling the constructor's argument is building a value, not declaring what the class is made of, so the argument object it writes carries no blank line.

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

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

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

FAQ

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

Conventions for class constructors. Constructor parameters must not have default values.

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

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

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

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

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

Сравнить hoc-classes-constructor с