cpp-style
БесплатноБез исполняемых скриптовНе проверенkotatsu C++ coding conventions — redundancy elimination (the rule we care most about), file organization, macro.h isolation, dual-mode exception policy…
от clice-io★ 37 звёзд на GitHubОб этом скилле
kotatsu C++ Coding Style
Redundancy Is a Defect
This is the convention we care most about. Redundant code is not a style nit — it actively misleads: every guard implies the guarded state can occur, every branch implies it can be taken, every parameter implies a caller needs it. When that implication is false, the reader wastes time defending against ghosts.
- Every branch must be reachable. Before adding a guard or fallback, prove the state can actually occur — construct the input that hits it. If you can't, don't write it.
- No speculative generality. No parameters, options, hooks, or abstraction layers for hypothetical future callers. Add them when the second real caller arrives.
- One way to do each thing. Don't leave an old path alive next to its replacement "just in case" — migrate all callers and delete it in the same change.
- Re-read after every change. Edits leave residue: conditions that
became constant, variables read once, branches that now collapse,
elseafterreturn, a helper with one remaining caller. Fold them before you're done — simplification that removes a concept beats one that merely shortens lines. - Delete, don't comment out. Git history is the archive.
Files & Organization
- Headers are
.hwith#pragma once— never include guards. Public headers live underinclude/kotatsu/<module>/. - Source extensions are mixed across modules (
.cppin some,.ccin others) — match the module you are editing. - File names are
snake_case. - File-local helpers: a single one is
static; a cluster of them goes in one anonymous namespace.
Module Boundaries & macro.h
- Libraries with user-facing declaration macros keep them in a
dedicated
macro.h(today:codec,zest) instead of exporting them from regular headers. Iron rule: such amacro.hcontains zero#includedirectives — not even standard headers. It must stay a pure macro sheet a consumer can include from anywhere with no transitive cost. - This rule covers only those dedicated macro sheets. Configuration and
implementation macros that ordinary headers legitimately define —
e.g.
KOTATSU_THROWand the platform feature macros inkotatsu/support/config.h— stay where they are.
Data & Types
structby default, even for types with methods.classonly when there is a real invariant that private access protects.enum classwith an explicit underlying type (e.g.: std::uint8_t); document each enumerator with///when its meaning is not obvious.- Prefer designated initializers (
{.field = value}) for aggregate construction. - West const:
const T&, neverT const&.
Errors, Exceptions & Defense
- kotatsu is a library that builds both with and without exceptions
(
KOTATSU_ENABLE_EXCEPTIONS). Library code never writes barethrow/try/catch— use theKOTATSU_THROW/KOTATSU_TRY/KOTATSU_CATCH_ALL/KOTATSU_RETHROWmacros fromkotatsu/support/config.h, which degrade tostd::abort()in the no-exceptions build. - Fallible synchronous operations return
std::expected<T, E>; async code uses kotatsu's outcome types. assertpins preconditions; impossible branches end instd::unreachable().- Defend only against states that can occur (the redundancy rule) — graceful degradation is not scattered null checks. The ASan/TSan build trees are the safety net.
Error Handling (control flow)
- Prefer
ifwith init-statements to tightly scope error variables, but avoid them when they compromise code readability or flatten control flow. - Omit redundant conditions: If the error type provides an
operator boolor evaluates implicitly (e.g., standard error codes, custom error wrappers), omit the redundant condition check. - Avoid forced
elsebranches: If scoping the variable inside theifrequires you to introduce anelseblock for the success path (especially when returning early on error), declare the variable in the local scope instead to keep the control flow flat.
// Good: Omit redundant condition when the type has operator bool
if (auto err = foo()) {
/* handle error */
}
// Bad: Redundant condition check
if (auto err = foo(); err) {
/* handle error */
}
// Good: Use init-statement when a custom condition is required,
// AND the variable isn't needed outside the if-statement
if (auto result = foo(); !result.has_value()) {
/* handle error */
}
// Bad: Using init-statement forces an 'else' block because 'result'
// goes out of scope, leading to nested/redundant code.
if (auto result = get_data(); !result.has_value()) {
return result.error();
} else {
process(result.value()); // Success path is forced into a nested block
}
// Good: Declare as a regular local variable to allow early exit
// and keep the success path un-nested (flat control flow).
auto result = get_data();
if (!result.has_value()) {
return result.error();
}
process(result
Установить cpp-style в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cpp-style?
kotatsu C++ coding conventions — redundancy elimination (the rule we care most about), file organization, macro.h isolation, dual-mode exception policy, template deduction and type-trait rules, naming, modern C++ preferences. Read BEFORE writing or modifying any C++ code.
Как установить скилл cpp-style?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cpp-style запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop 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…
от Anthropicinternal-comms
A 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…
от Anthropicskill-development
This 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…
от Anthropic