m05-type-driven/SKILL.md
Mastering C++ Type-Driven Design. Triggers: strong types, phantom types, type state pattern, builder pattern, invalid state unrepresentable.
npx skillsauth add 13eholder/modern-cpp-skills m05-type-drivenInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Can I make this bug a compile error?
int for IDs, double for Money. Bad.struct UserId, struct Money. Good.Connection<OFF> vs Connection<ON>.| Issue | Design Question |
| --------------------- | ------------------------------------------------------------- |
| Swapped arguments | Did you pass width to height? (Use Strong Types). |
| Invalid State | Did you call read() on closed file? (Use Type State). |
| Unit confusion | Did you mix Meters and Feet? (Use std::chrono style units). |
Is this int unique?
struct.struct UserId { int val; }; prevents process(OrderId).Does valid usage depend on order?
Builder::port() returns BuilderWithPort.Are units compatible?
Dist<Meters> + Dist<Feet>.Trace Up:
double calculate_trajectory(double dist) accepted any number.Dist<Meters> calculate(Dist<Meters> d). Compilation fails if you pass Feet.Trace Down:
File<Open> f = File<Closed>().open(); f.read();| Pattern | Cost | Use When |
| ------------------ | ---- | --------------------------------------- |
| Struct Wrapper | Zero | Distinct IDs, coordinates. |
| Enum Class | Zero | Type-safe flags (no implicit int conv). |
| Phantom Type | Zero | Tracking state without storage. |
| User Literal | Zero | 10_m, 50_s. |
tools
Common C++ Anti-Patterns. Triggers: global variables, new/delete, C-style cast, macros, void*.
data-ai
C++ Mental Models: Pointer vs Reference, Initialization, Undefined Behavior.
data-ai
Mastering C++ Domain Errors: Exception Hierarchies, System Errors, and Expected.
data-ai
Mastering C++ Lifecycle: RAII, Destructors, Static Initialization, Rule of 5.