cpp
Installation
SKILL.md
C++
Use this skill for C++ code that needs clear ownership, strong type modeling, maintainable file boundaries, and predictable native integration. When the code is part of a Nitro Module, pair this with build-nitro-modules for generated specs, Promise mapping, CMake, and HybridObject constraints.
Workflow
- Read the generated headers, public API shape, and local ownership patterns before editing.
- Model valid states with types before implementing behavior.
- Keep headers small and stable; push implementation details into
.cppfiles. - Split helpers by responsibility instead of growing a primary implementation file.
- Make ownership, lifetime, threading, and async boundaries explicit.
Type-Safe API Design
- Represent state variants with
std::variant, inheritance, or separate concrete types. Do not encode variants as one struct with manystd::optionalfields. - Keep related values nonoptional on the variant where they are valid. If
barcodeandbarcodeTypemust exist together, put both onScannedBarcode. - Use
std::optionalfor real domain absence inside one state, not for "maybe this object is a different kind of thing". - Prefer compile-time flow over caller-side optional probing.