hoc-coding-styles
Coding style conventions for how code is laid out across lines, and the forms literals are written in. Use when writing or reviewing the layout of any…
от openreachtech★ 17 звёзд на GitHub
Установить hoc-coding-styles в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Coding Styles
Conventions related to coding style.
Chop down immediately before a binary operator
- When a line contains multiple expressions, chop down immediately before the binary operator (place the operator at the start of the next line).
- Literals are not considered expressions here. Therefore, when one of the operands is a literal (e.g.,
length + 1), do not chop down.
// NG
const total = alpha + beta + gamma
// OK
const total = alpha
+ beta
+ gamma
Chop down ?? as a branch
- Strictly speaking,
??is syntactic sugar for anifstatement / ternary operator (a branch). Therefore, the literal exception for binary operators does not apply, and it is always chopped down as a branch (placing??at the start of the next line). - In other words, even when the right operand is a literal (such as
null),?? nullis not placed on the same line — it is wrapped onto a new line.
// NG: applying the literal exception and keeping it on the same line
const author = this.entity.comment?.author ?? null
// OK: chop down immediately before `??` as a branch
const author = this.entity.comment
?.author
?? null
When an if statement's condition spans multiple lines, apply consistency chopping down to ()
- When an if statement's condition spans multiple lines, apply consistency chopping down to the condition's
(). (Break the line immediately after(, place each condition on its own line, and place)on its own line.)
// NG
if (!Number.isInteger(length)
|| length < 0) {
// ...
}
// OK
if (
!Number.isInteger(length)
|| length < 0
) {
// ...
}
Write one method per line in a method chain
- Write one method per line.
- When writing a method chain, allow at most one receiver per line, and at most one method per line.
thisanditdo not count as receivers. They are the context variables:thisnames the object the code is already inside, anditis the fixed name/hoc-higher-order-functionsgives the current item of a higher-order callback. Neither carries information of its own, so counting either would chop a line that states one receiver and one member —this.converter.toFixed({ value })andit.name.toUpperCase()each say one thing, and each stays on one line.Every other identifier is a receiver, including the inner item a nested callback names by meaning.
manifest.env.isProduction()is two receivers on one line, and chopping it is not the fix — see the next bullet.Where a line would otherwise carry two receivers, the outer one answers for itself. It grows the member that reaches what is behind it, so the line names one receiver and nothing has to be chopped. Destructuring the inner object out is not the fix: an instance is never taken apart — see
/hoc-statements.// Two receivers .filter(it => it.account.isActive()) // One: the item answers for itself .filter(it => it.hasActiveAccount())Two receivers on a line is usually the Law of Demeter showing through. Reaching a property of a property is yours to do only inside the top-receiver, which is why
this.reaches one further and a named object does not. Where the line ismanifest.env.isProduction(), what the count is reporting belongs to/hoc-manifest-pattern.- Destructuring answers the count, not the design. Taking
{ manifest: { env } }states the same knowledge of the manifest's insides thatmanifest.envdid, one line higher up. An item that can only be taken apart, because it has no member to answer with, is a plain object — and why that narrows the design belongs to/hoc-classes-principles. - Passing the count is not a clearance.
itis excluded from it, so a reach through a callback item's field never shows up there at all. What the count catches is a subset; the design conventions judge the rest.
- Destructuring answers the count, not the design. Taking
- Unless instructed to chop down, place the first method of a method chain on the same line as the receiver.
- Counting receivers and methods does not settle a chain on its own. The count of complex expressions on the line governs it too, and a chain can pass this rule while failing that one. Read both before deciding where a chain breaks.
// NG
const ids = this.extractSamples().filter(it => it).map(it => it.id)
// NG (not one method per line)
const ids = this.extractSamples()
.filter(
it => it
).map(
it => it.id
)
// OK
const ids = this.extractSamples()
.filter(it => it)
.map(it => it.id)
Where the chain itself carries the complex expressions, chop it
A receiver derived by a call, or reached through a computed key, is a complex expression of its own — and the method called on it is a second. One receiver and one method sit within the count this section states, so this rule permits the line; the rule against two
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл hoc-coding-styles?
Coding style conventions for how code is laid out across lines, and the forms literals are written in. Use when writing or reviewing the layout of any expression or statement. Which statements may be written belongs to the statements convention; the layout of a JSDoc block, to the JSDoc convention.
Как установить скилл hoc-coding-styles?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл hoc-coding-styles запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…