kotlin-functional-dsl

Design type-safe Kotlin DSLs using lambdas with receivers.

Updated Mar 20, 2026
One-click install
npx skills add https://github.com/ClankerGuru/skills --skill kotlin-functional-dsl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-functional-dsl
Source: https://github.com/ClankerGuru/skills/tree/main/kotlin-dsl
Command: npx skills add https://github.com/ClankerGuru/skills --skill kotlin-functional-dsl

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing and building expressive, type-safe Kotlin DSLs using lambdas with receivers to enable clean, declarative APIs, from Gradle extensions to Compose-style configurations.

Core Features & Use Cases

  • Builder DSL patterns: mutable builders yielding immutable results.
  • Nested DSLs: composition of complex configurations via hierarchical builders.
  • Collection DSLs: building tables, routes, or configurations fluently.
  • Type-safe pipelines: composing steps with strong type guarantees.
  • Gradle-style extensions: ergonomic DSLs for plugin and project configuration.

Quick Start

Define a simple builder with a lambda-with-receiver and use it to construct a small DSL-based configuration.

Frequently Asked Questions about kotlin-functional-dsl

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a type-safe Kotlin DSL using lambda with receiver?

To create a type-safe Kotlin DSL, use lambdas with receivers to build hierarchical configurations, applying @DslMarker to prevent scope leakage and ensure clean nested declarative syntax.

What is the best way to build a Gradle extension DSL in Kotlin?

The best way to build a Gradle extension DSL in Kotlin is using builder patterns with mutable builders that yield immutable results, enabling ergonomic plugin and project configuration.

How do @DslMarker annotations prevent scope leakage in nested Kotlin DSLs?

@DslMarker annotations prevent scope leakage in nested Kotlin DSLs by restricting implicit receiver access, ensuring that only the innermost builder's methods are callable within their specific scope.

Can I build type-safe configuration pipelines with Kotlin DSLs?

Yes, you can build type-safe pipelines with Kotlin DSLs by composing sequential steps with strong type guarantees, allowing fluent collection building for routes, tables, or configurations.

How do Kotlin DSL builders ensure immutable results from mutable configurations?

Kotlin DSL builders ensure immutable results by allowing mutable state during the configuration phase, then producing a final immutable data object when the build process completes.

Does Kotlin DSL design require build-time validation for configuration rules?

Yes, Kotlin DSL design incorporates build-time validation to enforce sensible defaults and structural rules, ensuring that the generated declarative APIs fail fast during the configuration process.