
Kotlin Springboot
Apply idiomatic Kotlin patterns—DI, JPA entities, config, and feature-first packages—while building Spring Boot services.
Overview
Kotlin-springboot is an agent skill for the Build phase that teaches idiomatic Spring Boot application structure, DI, configuration, and Kotlin-JPA patterns for backend services.
Install
npx skills add https://github.com/github/awesome-copilot --skill kotlin-springbootWhat is this skill?
- Maven/Gradle Kotlin plugins and Spring Boot starters setup
- Primary-constructor injection with private val dependencies
- kotlin-jpa plugin for open entities without manual boilerplate
- Feature/domain package layout instead of layer-only folders
- Type-safe @ConfigurationProperties using immutable data classes
Adoption & trust: 9.1k installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Spring Boot Kotlin code drifts toward Java-translated patterns and messy layering instead of concise, immutable, feature-oriented services.
Who is it for?
Indie builders shipping JVM backends who want Spring Boot conventions without fighting Kotlin’s defaults.
Skip if: Greenfield projects choosing non-JVM stacks, or teams needing only frontend or DevOps runbooks with no Kotlin server code.
When should I use this skill?
Developing applications with Spring Boot and Kotlin; user asks for Spring Boot Kotlin best practices.
What do I get? / Deliverables
You align build files, package structure, injection, and configuration properties with Kotlin-first Spring Boot practices suitable for production APIs.
- Refactored package-by-feature layout
- Kotlin-idiomatic services and configuration property classes
Recommended Skills
Journey fit
How it compares
Backend style guide for Spring + Kotlin—not a CLI generator, test runner, or Copilot SDK embedding skill.
Common Questions / FAQ
Who is kotlin-springboot for?
Solo and small-team developers building REST or service-layer apps with Spring Boot and Kotlin who want idiomatic structure and DI.
When should I use kotlin-springboot?
During Build/backend while scaffolding modules, wiring starters, defining entities and controllers, or refactoring packages toward feature-based layout.
Is kotlin-springboot safe to install?
It is editorial guidance only; confirm trust via the Security Audits panel on this page before letting an agent modify build files or dependencies.
SKILL.md
READMESKILL.md - Kotlin Springboot
# Spring Boot with Kotlin Best Practices Your goal is to help me write high-quality, idiomatic Spring Boot applications using Kotlin. ## Project Setup & Structure - **Build Tool:** Use Maven (`pom.xml`) or Gradle (`build.gradle`) with the Kotlin plugins (`kotlin-maven-plugin` or `org.jetbrains.kotlin.jvm`). - **Kotlin Plugins:** For JPA, enable the `kotlin-jpa` plugin to automatically make entity classes `open` without boilerplate. - **Starters:** Use Spring Boot starters (e.g., `spring-boot-starter-web`, `spring-boot-starter-data-jpa`) as usual. - **Package Structure:** Organize code by feature/domain (e.g., `com.example.app.order`, `com.example.app.user`) rather than by layer. ## Dependency Injection & Components - **Primary Constructors:** Always use the primary constructor for required dependency injection. It's the most idiomatic and concise approach in Kotlin. - **Immutability:** Declare dependencies as `private val` in the primary constructor. Prefer `val` over `var` everywhere to promote immutability. - **Component Stereotypes:** Use `@Service`, `@Repository`, and `@RestController` annotations just as you would in Java. ## Configuration - **Externalized Configuration:** Use `application.yml` for its readability and hierarchical structure. - **Type-Safe Properties:** Use `@ConfigurationProperties` with `data class` to create immutable, type-safe configuration objects. - **Profiles:** Use Spring Profiles (`application-dev.yml`, `application-prod.yml`) to manage environment-specific configurations. - **Secrets Management:** Never hardcode secrets. Use environment variables or a dedicated secret management tool like HashiCorp Vault or AWS Secrets Manager. ## Web Layer (Controllers) - **RESTful APIs:** Design clear and consistent RESTful endpoints. - **Data Classes for DTOs:** Use Kotlin `data class` for all DTOs. This provides `equals()`, `hashCode()`, `toString()`, and `copy()` for free and promotes immutability. - **Validation:** Use Java Bean Validation (JSR 380) with annotations (`@Valid`, `@NotNull`, `@Size`) on your DTO data classes. - **Error Handling:** Implement a global exception handler using `@ControllerAdvice` and `@ExceptionHandler` for consistent error responses. ## Service Layer - **Business Logic:** Encapsulate business logic within `@Service` classes. - **Statelessness:** Services should be stateless. - **Transaction Management:** Use `@Transactional` on service methods. In Kotlin, this can be applied to class or function level. ## Data Layer (Repositories) - **JPA Entities:** Define entities as classes. Remember they must be `open`. It's highly recommended to use the `kotlin-jpa` compiler plugin to handle this automatically. - **Null Safety:** Leverage Kotlin's null-safety (`?`) to clearly define which entity fields are optional or required at the type level. - **Spring Data JPA:** Use Spring Data JPA repositories by extending `JpaRepository` or `CrudRepository`. - **Coroutines:** For reactive applications, leverage Spring Boot's support for Kotlin Coroutines in the data layer. ## Logging - **Companion Object Logger:** The idiomatic way to declare a logger is in a companion object. ```kotlin companion object { private val logger = LoggerFactory.getLogger(MyClass::class.java) } ``` - **Parameterized Logging:** Use parameterized messages (`logger.info("Processing user {}...", userId)`) for performance and clarity. ## Testing - **JUnit 5:** JUnit 5 is the default and works seamlessly with Kotlin. - **Idiomatic Testing Libraries:** For more fluent and idiomatic tests, consider using **Kotest** for assertions and **MockK** for mocking. They are designed for Kotlin and offer a more expressive syntax. - **Test Slices:** Use test slice annotations like `@WebMvcTest` or `@DataJpaTest` to test specific parts of the application. - **Testcontainers:** Use Testcont