cpp-style
SkillDev toolsC++ naming, formatting, static analysis, and RTTI rules for LuisaCompute.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the cpp-style skill
What this skill tells your AI
The instructions your AI receives, as published by luisagroup/luisacompute in .agents/skills/cpp-style/SKILL.md and read by ahel’s review.
Naming
- Classes / structs / enums:
CamelCase(MyClass,RenderPipeline) - Functions & public vars:
snake_case(get_value,process_data) - Private/protected members & functions:
_snake_case(_private_var,_internal_helper()) - Constants:
kCamelCaseorUPPER_SNAKE_CASEfor macros - Template params:
CamelCase - Namespaces:
luisa,luisa::compute,vstd, etc. Keep compact.
Syntax Check
Use the project C++ syntax checker:
python scripts/check_cpp_syntax.py <file>.cpp
It runs clangd with the project's compile_commands.json and .clang-tidy. Skip files not in compile_commands.json.
Formatting
Format with the project .clang-format (bundled in this skill; the project root copy is authoritative).
Base: LLVM style. Key overrides:
- Indent: 4 spaces, no tabs. Continuation indent 4. Case labels indented. Preprocessor indent 2.
- Braces: K&R (attach). No break before braces. Indent braces off.
- Line width: unlimited (
ColumnLimit: 0). - Pointers/refs: right-aligned (
int *p,int &r). - Access modifiers: indent offset
-4(flush withclass). Empty lines before/after left as-is. - Short constructs: allow single-line for short blocks, functions, ifs, loops, lambdas, enums, case labels.
- Constructor init: not forced one-per-line; no break before comma.
- Templates / concepts: break declarations only when multiline; indent requires clause.
- Spaces: before
=, ctor-initializer:, inheritance:, range-for:. No space after C-style casts,!,templatekeyword, before braced lists. No space in empty parens or before trailing comments. - Alignment: after open brackets & operands; don't align consecutive assignments.
- Includes/using: never auto-sort.
- Namespaces: compact single-line when short; no indentation inside (
ShortNamespaceLines: 0). - Strings/comments: break string literals; don't reflow comments.
- Macros: control-flow-like (
$if,$elif,$else,$for,$while,$loop,$switch,$case,$default) get space before(. Function-like macros don't. Special lists:ForEachMacros:LUISA_STRUCT,LUISA_BINDING_GROUP,LUISA_BINDING_GROUP_TEMPLATEIfMacros:$if,$elif,$else,$for,$while,$loop,$switch,$case,$defaultStatementMacros:LUISA_MAP
Static Analysis
Run .clang-tidy (bundled in this skill; the project root copy is authoritative).
All checks disabled (-*), then enabled by category:
- bugprone-*
- cert-*
- cppcoreguidelines-*
- google-* (default-arguments, explicit-constructor, runtime-operator)
- hicpp-*
- misc-*
- modernize-*
- mpi-, openmp-
- performance-*
- portability-*
- readability-*
See the bundled .clang-tidy for the exact check list.
No RTTI
RTTI is disabled for project code. Do not use:
dynamic_cast— usestatic_castwhen type is knowntypeidstd::type_info
Prefer virtual dispatch or explicit type tags for type-safe downcasting. Third-party code under src/ext is exempt.
Integer Types
Prefer fixed-width integer types:
- Use:
int32_t,uint32_t,int64_t,uint64_t,int16_t,uint16_t,int8_t,uint8_t size_tis acceptable for sizes/indices per STL convention.- Prefer
std::bytefor raw byte data. - Avoid
unsigned int,long long,unsigned long,short, andcharfor arithmetic. Some platform/system headers may define aliases such asuint; avoid introducing new uses in project code.
Verification
After editing C++ files:
# Check syntax / tidy diagnostics
python scripts/check_cpp_syntax.py src/foo.cpp
# Check formatting (dry run; replace --dry-run with -i to apply)
clang-format --dry-run --Werror src/foo.cpp
# Run clang-tidy on a specific file
clang-tidy -p build src/foo.cpp
When changing build-affecting files, configure and build a relevant target:
xmake f -m debug -c
xmake build <target>
Resources
.clang-format— bundled copy of the project formatter config..clang-tidy— bundled copy of the project static-analysis config..clangd— project root configuration for clangd diagnostics (not bundled; see project root).
Signals
- GitHub stars
- 1k
- Forks
- 108
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
cpp-style-luisagroup- Source
- github.com/luisagroup/luisacompute