TsukiNi22/ai-utils / skills/cpp/cpp-class
cpp-class
UnverifiedGenerate C++ (C++20) .hpp/.cpp files and class architectures in Tsukini's style (Xartania header, indented include guards, INCLUDE/CLASS sections, Pre-Function/Function/Operator/Constructor/Destructor blocks, libutils attributes or standard [[...]]), with empty bodies only (never the logic), then register the .cpp in the CMakeLists.txt. Also creates the main.cpp entry point in the same style. Use whenever the user asks to create, scaffold or add a C++ class, a main / entry point, interface (I*), abstract class (A*), template, struct/Type or Define header, module or set of .hpp/.cpp files.
C++ files in Tsukini's style
<name> (a skill) = the folder of that skill: ~/.claude/skills/<name> (setup.sh) or ${CLAUDE_SKILL_DIR}/../../*/<name> (plugin of the marketplace).
Read before writing the first file:
reference/layout.md: file/class layout, header, includes, attributes, empty bodies rule;- the
cpp-styleskill (SKILL_DIR/../cpp-style/SKILL.md): naming, formatting, spacing; - the
cpp-commentsskill (SKILL_DIR/../cpp-comments/SKILL.md): comments. The files ofexamples/(real libutils code) are the ground truth for the layout.SKILL_DIRbelow = the directory of this file.
libutils freshness
First, once per conversation: the freshness check of the libutils skill (bash <libutils skill>/scripts/check.sh,
section "Freshness check" of libutils/SKILL.md). Outdated -> reuse the answer already given in this conversation,
else ask once (continue / update the installed libutils with libutils-install / the project's requirement with
libutils-setup / the skills reference) and remember it.
Architecture only: never write the content/logic of a function. Every body is
/* Nothing */(+ the minimalreturn {};when non-void), even if the user describes the behavior: it goes in a trailing comment of the declaration. The user writes the logic. Allowed:= default/= delete/= 0, init lists forwarding the parameters, one-member accessors, a public wrapper forwarding to itsname_implementation. Details inreference/layout.md.
1. Understand the request
- Name(s), module/folder, kind of each file:
kind files template class X.hpp+X.cpptemplates/class.hpp,templates/class.cpptemplate / header-only X.hpptemplates/template.hppinterface IX.hpptemplates/interface.hppabstract AX.hpp(+AX.cppif it has Pre-Functions)templates/abstract.hpptypes XType.hpptemplates/type.hppdefines / enums XDefine.hpptemplates/define.hppfamily / umbrella X.hpp(includes the family, no namespace)templates/family.hppentry point src/<root>/main.cpp+ the core class (Coreor the project class)templates/main.cpp(main-std.cppinstdmode) - Entry point (new project, or when asked for a
main):src/<root>/main.cppfromtemplates/main.cpp(the same in context-forge, virtual-os, cpp_project_template): it only creates the core class, callsinit(argc, argv)thenrun(), catchesutils::exception::IException(Exitcode ->OK, otherwise printformated()and returnKO) thenstd::exception(printwhat(), returnKO), and returnscore.exit()(return OK;when the core class has noexit). Signature_cold int main(int argc, char* argv[])(never_nodiscard, neverconst char*argv: not a standardmainform). This wiring is the only body written by the skill. Create the core class with it if it doesn't exist:void init(int argc, const char *const argv[]);,void run(void);,int exit(void) const;as Pre-Functions with empty bodies. Registermain.cppfirst inSRC, under# Entry(cmake_add.py ... --group Entry).stdmode:templates/main-std.cpp(std::exception,EXIT_FAILURE). - An "architecture" (ex: "a socket with an interface, an abstract and a TCP impl") = several of the above,
chained
IX->AX: public IX->X: public AX. - Project layout: find the project root (closest
CMakeLists.txt) and follow the existing tree. Default:include/<root>/<section>/X.hppandsrc/<root>/<section>/X.cpp. - Namespaces: apply the "Namespaces" section of
reference/layout.md(root = project name, one level per section folder, grouping folders skipped, a familyI/A/implfolder stays in the parent namespace, internals in a nested namespace, family umbrella headertemplates/family.hpp). Write the planned treeinclude/<path>/X.hpp -> namespacebefore generating.
2. Ask (one AskUserQuestion call, before writing anything)
Always ask the header question, in French, and add in the same call any missing info from step 1 (name, module, kind, namespace when ambiguous). Header question:
- Xartania (Recommandé): default
XARTANIAbanner. - Nom personnalisé: banner with another name (the user types it with "Other", or ask it right after).
- Sans bandeau: header box (Edition / File Name / File Description) without the ascii banner.
- Aucun header: no header at all.
Ask it once per request, even when many files are generated.
3. Detect the attributes mode
bash SKILL_DIR/scripts/detect_libutils.sh <project_root>
internal-> libutils macros, Attribute include relative in headers.libutils-> libutils macros, everything from libutils through#include <utils/utils.hpp>(never a libutils header one by one, except the onesutils.hppdoes not give like the observers; see "libutils includes" inreference/layout.md).std-> standard[[...]]attributes (mapping table incpp-style), no Attribute include. Same logic for errors: libutils exceptions only ininternal/libutilsmode. Any attribute (alignment_alignas(std::hardware_destructive_interference_size)included) follows the lookup order ofcpp-style"Attributes": libutils default macros, then the ones really available in the project / system (bash SKILL_DIR/scripts/list_attributes.sh <project_root>), then only the standard[[...]]form.
4. Generate each file
- Header (skip if "Aucun header"):
python3 SKILL_DIR/scripts/header.py --file X.hpp --banner xartania|none|"<NAME>" --desc "<one line>".hpp: a real one-line description..cpp: omit--desc(default sentence) unless asked. - Start from the matching template, replace the placeholders:
{{HEADER}}header output,{{GUARD}}upper-cased name without separators,{{NAMESPACE}},{{CLASS}}/{{NAME}},{{UTILS_SECTIONS}}(libutilsmode: one#define _Sectionline per libutils section used by the file, indented like the includes in a header, table inreference/layout.md"libutils includes"; removed ininternal/stdmode),{{UTILS_INCLUDE}}(with its delimiters:<utils/utils.hpp>inlibutilsmode,"../attribute/Attribute.hpp"relative ininternalmode),{{UTILS_INCLUDE_ROOT}}(.cpp:<utils/utils.hpp>, or"utils/attribute/Attribute.hpp"ininternalmode),{{HPP_INCLUDE_ROOT}}(path frominclude/),{{KIND}}(group label of the implementations in a family header). The template members/methods are placeholders: replace them by the real API asked by the user (keep the block order and comments style), remove the include lines that become unused, and keep the include comments aligned. - In
stdmode, convert every macro (_hot->[[gnu::hot]], ...) and drop the Attribute include. - Bodies: always empty (
/* Nothing */+ minimal return), never logic, see the rule at the top; an empty constructor / destructor / operator defined in its class on one line:Name(...): _a{a} { /* Nothing */ }; // comment(:glued to the)). - Remove every section with nothing linked to it (class blocks
// --- X --- //, file sections/* DEFINE */,/* PROTOTYPE */..., empty visibilities and/* group */labels): the template blocks are not mandatory, only the ones holding a declaration are kept. - Short functions (getters, setters, accessors,
name_forwarders, any single-statement body) go in theFunctionblock of the.hppwithinlineafter the attributes, not in the .cpp, when it can help the compiler inline them (not onvirtualmethods). Rules inreference/layout.md. - Private / protected / internal functions are named
<name>(<Name>)*_(camelCase + trailing_:allocate_,computeHash_), public methods plain camelCase (cpp-stylenaming table).
5. Register the sources in CMake
For each new .cpp:
python3 SKILL_DIR/scripts/cmake_add.py <project_root>/CMakeLists.txt src/<path>/X.cpp
It inserts the file next to the files of the same folder (or in a new ## Module (sub-part: x) block),
does nothing if already listed or if sources are collected with file(GLOB ...). Exit code 2 = no
source list found: add it by hand in the right add_executable/add_library/target_sources.
6. Check
- Syntax check every new
.cpp(and header-only.hpp) when a compiler is available:clang++ -std=c++20 -Wall -Wextra -Wno-unused-parameter -fsyntax-only -I<project_root>/include <file>(g++as fallback). Fix every error/warning caused by the generated code (the unused parameters of the empty bodies are expected, never silence them in the code). - When
xstyleis installed (command -v xstyle):xstyle --rtk <created files>(always--rtk: compact output made for the assistant),xstyle --rtk --fix [CODES] <files>for the fixable ones; what it can't see (logic in a body,inline, names ending with_) is still checked by hand below. - Re-read the files against
reference/layout.mdandcpp-style(braces,(void),this->,;after one-liners, one-liner bodies aligned tight (longest signature + 1 space), aligned include comments, section separators, guard name, namespace comments) and check that no body contains logic, that no section separator is left empty and that the short non-virtual functions areinlinein the header, and that every non-public function ends with_. - Report the created files, the attribute mode used and the CMake change.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 192k | Updated | Claude CodeCodex | Verified | Install |