cpp-oop-style
High-quality C++ OOP coding style (archibate / parallel101 lineage) that overrides sloppy AI-default C++. Use this skill WHENEVER writing, editing…
от archibate★ 42 звезды на GitHub
Установить cpp-oop-style в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
archibate C++ OOP Style
A skill that makes you write C++ the way a senior systems engineer who loves design patterns writes it — not the way an autocompleter does. When this skill is loaded, it overrides your default C++ instincts.
The one rule
"Abstract class, data class, or value type. Nothing else."
Every type you introduce is one of these three kinds — never the muddy middle:
- Abstract class — behavior only. A pure-virtual interface with no data
members of its own; any injected collaborators live in its concrete
…Impl, not in the interface. Always hasvirtual ~T() = default;. This is the unit of polymorphism and dependency injection. - Data class — data only. A plain
structwith public fields, built with designated initializers. No business logic, no getters/setters wrapping plain fields. This is the unit of value passing and configuration. - Value / resource type — a concrete, value-semantic type that either owns a
resource (an RAII wrapper) or enforces one invariant (a strong type:
Money,EmailAddress, a mathVector3, a C-handle wrapper). It has a small, total interface and behaves like a built-in — the Regular type. This is the one concrete-class-with-methods that earns its keep.
Reject the muddy middle that models reach for by default: a concrete class that mixes private fields, a grab-bag of public methods, and a scatter of free helper functions — neither a clean interface, nor plain data, nor a focused value type. That shape is the single biggest tell of AI-slop C++.
So a concrete class with methods is allowed only when it is (a) the
implementation of an abstract class (struct FooImpl final : Foo, defined
in a .cpp, never a header), or (b) a value/resource type as above.
Everything else is behavior behind an interface, or data in a struct.
What you are overriding
| AI-slop default | This skill |
|---|---|
Free functions dep1DoX(), dep2DoX() |
One abstract interface Dep, injected |
| Concrete class with public mutable fields + methods | Abstract class (behavior) or data struct (data) |
Dog dog; dog.doThing(globalThing); |
Inject the collaborator: dog.doThing(dep) |
void f(string n, int a, int p, int addr) |
void f(FooConfig const &cfg) (designated init) |
new T / delete / new T[] |
make_unique / make_shared / vector<T> |
int parseInt() returning -1 on failure |
optional<int> parseInt() |
enum Mode + switch dispatch |
inject a strategy / functor, or a state class |
pair<bool, It> / tuple<...> returns |
named result struct |
const T& x, const T* p |
East const: T const &x, T const *p |
Named anti-patterns (real smells this overrides)
These are the concrete shapes that mark sloppy or dated C++ — name them and refuse them:
- God-base interface — one abstract class fusing data and behavior, with a pile of public mutable members (e.g. a node base every node both reads state from and overrides). Split it: behavior → interface, state → data struct.
- Global object + free functions — a global instance poked by a scatter of free helpers. Make it a class with a clear owner and inject it.
- Stringly-typed API —
setParam("mode", "fast"), sockets/params keyed by string. Useenum class, strong types, and named fields so the compiler checks them. Relatedly, fetch an abstract handle once rather than re-passing a string key on every call:auto *dev = api->getDevice("CD"); dev->play();, notapi->playDevice("CD")thenapi->stopDevice("CD"). - Sentinel returns —
(size_t)-1,-1, empty string, or null on failure. Useoptional/expectedor a result struct (seereferences/error-handling.md).
The canonical shape
// Dep.h — interface only. Pure virtual. Lives in a small header.
struct MethodConfig {
Point position{};
float size{};
};
struct Dep {
virtual ~Dep() = default;
virtual std::string someQuery() const = 0;
virtual void someMethod(MethodConfig const &config) = 0;
};
// Animal.h
struct Animal {
virtual ~Animal() = default;
virtual void someInterface(Dep *dep) = 0; // collaborator injected, not owned
};
// Dog.h — concrete impl, declared minimally, defined in .cpp
struct Dog final : Animal {
void someInterface(Dep *dep) override;
private:
int somePrivate{};
};
// Dog.cpp
void Dog::someInterface(Dep *dep) {
auto answer = dep->someQuery(); // reuse, don't reimplement per concrete dep
// ...
}
// callSite.cpp — the composition root wires concrete to abstract
auto dog = Dog{};
auto dep1 = std::make_unique<Dep1>(someOptions);
dog.someInterface(dep1.get());
Class design
Virtual functions are a backbone of this style — reach for them. They do two distinct jobs, and both are worth an interface:
- Dispatch / dependency injection — one shared caller works across subtypes it doesn't know. This is what replaces *branching
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- agents/openai.yaml
- references/cmake-first-projects.md
- references/debug-harnesses.md
- references/debug-instrumentation.md
- references/decoupled-modules.md
- references/dependencies/binary-abi.md
- references/dependencies/installed-and-manual.md
- references/dependencies/router.md
- references/dependencies/source-vendoring.md
- references/dependencies/string9811.md
- references/deployment/cmake-installable-projects.md
- references/deployment/cpp-app-deployment.md
- references/deployment/pybind11-packaging.md
- references/deployment/router.md
- references/error-handling.md
- references/functors-callbacks.md
- references/generics-compile-time.md
- references/ownership-lifetime.md
- references/sources.md
- references/text-encoding.md
- references/type-erasure.md
- references/undefined-behavior.md
- references/wrapping-c-resources.md
FAQ
Что делает скилл cpp-oop-style?
High-quality C++ OOP coding style (archibate / parallel101 lineage) that overrides sloppy AI-default C++. Use this skill WHENEVER writing, editing, refactoring, or reviewing C++ code (.cpp / .h / .hpp / .cc / .cxx), designing C++ classes, interfaces, APIs, or libraries, or when the user mentions C++ design, OOP, design patterns, dependency injection, RAII, or "clean / modern C++". Also use it for CMake-first C++ project layout, module targets, usage requirements, third-party dependency acquisition and integration, binary ABI compatibility, installation, packaging, and application deployment. Apply it even when the user does not explicitly ask for a style: the default way models write C++ leans on free functions, public mutable state, raw new/delete, sentinel return codes, and long loose parameter lists — this skill replaces all of that with abstract-class-or-data-class design, dependency injection, type-rich APIs, value-based error handling, and RAII ownership.
Как установить скилл cpp-oop-style?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cpp-oop-style запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…