kotlin-springboot — скилл для GitHub Copilot: установка
Скилл задаёт практики Spring Boot и Kotlin: от структуры проекта до тестов и корутин. Подходит, когда агент пишет или проверяет серверное приложение.
npx skills add github/awesome-copilot --skill kotlin-springboot -a claude-codeЧто делает kotlin-springboot
kotlin-springboot направляет GitHub Copilot при работе со Spring Boot на Kotlin. Он советует группировать код по доменам, внедрять обязательные зависимости через primary constructor и хранить их в private val. Для DTO предлагаются data class, а для конфигурации — application.yml и @ConfigurationProperties.
Скилл охватывает REST-контроллеры, глобальную обработку ошибок, @Transactional, Spring Data JPA и null-safety Kotlin. Для JPA он рекомендует плагин kotlin-jpa, чтобы сущности становились open автоматически. Есть подсказки по логированию через companion object, JUnit 5, Kotest, MockK, Testcontainers и suspend-функциям.
Ставьте его, если проект уже использует Kotlin и Spring Boot. Для приложения на Java эти правила не подойдут.
Какие задачи решает
- настроить структуру Spring Boot-проекта на Kotlin
- оформить DTO через Kotlin
data class - подключить JPA-сущности с плагином
kotlin-jpa - написать глобальный обработчик ошибок для REST API
- организовать тесты с JUnit 5 и Testcontainers
Примеры запросов агенту
- «Создай REST-контроллер на Kotlin с DTO и валидацией `@Valid`.»
- «Проверь JPA-сущности и настрой `kotlin-jpa` в `build.gradle`.»
- «Напиши интеграционный тест с Testcontainers для репозитория.»
Как установить kotlin-springboot
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill kotlin-springboot -a claude-code2Вручную: положить файлы
~/.claude/skills/kotlin-springboot/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/kotlin-springboot/
Вручную: положить файлы
.agents/skills/kotlin-springboot/SKILL.mdДля всех проектов — ~/.agents/skills/
Вручную: положить файлы
.cursor/skills/kotlin-springboot/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill kotlin-springboot2GitHub CLI
gh skill install github/awesome-copilot kotlin-springboot3Вручную: положить файлы
.github/skills/kotlin-springboot/SKILL.mdКомандой платформы
gemini skills install https://github.com/github/awesome-copilot --path skills/kotlin-springbootВручную: положить файлы
.devin/skills/kotlin-springboot/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Похожие
Вопросы о kotlin-springboot
Как установить kotlin-springboot в GitHub Copilot?
Запустите npx skills add github/awesome-copilot --skill kotlin-springboot. Также доступна команда gh skill install github/awesome-copilot kotlin-springboot.
Что делает скилл kotlin-springboot?
Он даёт GitHub Copilot правила для разработки Spring Boot-приложений на Kotlin. В них входят DI, конфигурация, REST API, JPA, тестирование, логирование и корутины.
Что нужно для работы с JPA-сущностями на Kotlin?
Скилл рекомендует включить kotlin-jpa, чтобы JPA-сущности автоматически были open. Репозитории предлагается строить на JpaRepository или CrudRepository.
Исходный текст
SKILL.md · MIT
---
name: kotlin-springboot
description: 'Get best practices for developing applications with Spring Boot and Kotlin.'
---
# 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 Testcontainers for reliable integration tests with real databases, message brokers, etc.
## Coroutines & Asynchronous Programming
- **`suspend` functions:** For non-blocking asynchronous code, use `suspend` functions in your controllers and services. Spring Boot has excellent support for coroutines.
- **Structured Concurrency:** Use `coroutineScope` or `supervisorScope` to manage the lifecycle of coroutines.
© github · MIT · github/awesome-copilot