kp-type-safe-builders
Installation
SKILL.md
One-line summary
Build a fluent, type-safe DSL using lambdas with receivers — letting callers write html { head { title("hi") } } while the compiler enforces what's valid inside each block.
When to use this skill
- Configuration that reads better as a recipe than as constructor arguments: Gradle build scripts, Compose UI trees, Ktor routing.
- Domain-specific construction that benefits from a structural shape (HTML, SVG, query builders).
- Test fixtures and seed data where readability matters.
When NOT to use this skill
- Construction would be just as clear with named arguments + default values — a DSL adds learning cost; reach for it only when the structural shape genuinely helps.
- The "DSL" is one level deep and has no nested scopes — that's just a function with a builder parameter, not really a DSL.
- The grammar you're inventing is complex enough to deserve a real parser — a DSL hides the complexity instead of solving it.
Core content
Lambda with receiver. A function whose last parameter is T.() -> Unit makes T's methods and properties available as if you were inside T: