stack-kotlin
Kotlin language guidelines — idioms, coroutines and flows, Ktor servers, Exposed ORM, and testing with Kotest and MockK
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- stack-kotlin
- license
- Apache-2.0
- metadata
- { "author": "manuel-retamozo-garcia", "version": "1.0" }
- description
- Kotlin language guidelines — idioms, coroutines and flows, Ktor servers, Exposed ORM, and testing with Kotest and MockK
- capabilities
- [ "kotlin" ]
02 资源文件 8
- 参考文档references/coroutines-flows.md7.4 KB
- 参考文档references/exposed-patterns.md18.7 KB
- 参考文档references/exposed.md1.5 KB
- 参考文档references/ktor-patterns.md16.3 KB
- 参考文档references/ktor.md1.5 KB
- 参考文档references/patterns.md16.5 KB
- 参考文档references/testing-patterns.md8.6 KB
- 参考文档references/testing.md1.4 KB
03 SKILL.md 正文
Kotlin Development Patterns
Idiomatic Kotlin patterns and best practices for building robust, efficient, and maintainable applications.
When to Use
- Writing new Kotlin code
- Reviewing Kotlin code
- Refactoring existing Kotlin code
- Designing Kotlin modules or libraries
- Configuring Gradle Kotlin DSL builds
- Writing coroutines, flows, Ktor routes, Exposed queries, or Kotlin tests
Core Rules
- Null Safety: Leverage Kotlin's type system (non-nullable by default). Use safe-call (
?.) and Elvis (?:) operators; never use force-unwarp (!!). - Immutability by Default: Use
valfor variables, immutable collections, and data classcopy()for transformations. - Sealed Types: Model restricted hierarchies and results with
sealed classorsealed interfacefor exhaustivewhenexpressions. - Structured Concurrency: Scope async calls using
coroutineScopeorsupervisorScope. Respect coroutine cancellation viaensureActive(). - DSL Builders: Implement type-safe builders using
@DslMarkerand lambda receivers. - Coroutines and Flows (
references/coroutines-flows.md): NeverGlobalScope;Dispatchers.IOfor blocking I/O,Defaultfor CPU work; exposeStateFlowfor state andSharedFlowfor one-time events; never catchCancellationException. - Ktor (
references/ktor.md): Thin routes asRouteextensions delegating to services; errors mapped centrally inStatusPages; protected routes insideauthenticate("jwt"). - Exposed (
references/exposed.md): Every query insidenewSuspendedTransaction; HikariCP withisAutoCommit = false; schema through Flyway migrations. - Testing (
references/testing.md): Failing test first; Kotest specs, MockKcoEvery/coVerifyfor suspend functions (never mock data classes);runTestwith virtual time.
References
Load on demand, only the file the task needs:
- Kotlin Coding Patterns & Examples
- Coroutines and Flows — scopes, dispatchers, flow operators, cancellation, Turbine
- Ktor Server — routing, content negotiation, auth, Koin; examples in ktor-patterns.md
- Exposed ORM — DSL vs DAO, transactions, pooling, migrations; examples in exposed-patterns.md
- Testing — Kotest, MockK, coroutine tests, Kover; examples in testing-patterns.md
04 同仓库更多 Skills
work-unit-commits
Plan commits as reviewable work units. Trigger: implementation, commit splitting, chained PRs, or keeping tests and docs with code.
stack-webmcp
Trigger: WebMCP, document.modelContext, web tools, AI browser agent. Web Model Context Protocol client-side tool standard.
stack-vite
Vite frontend build tool — configuration, plugins, asset loading
stack-starlight
Astro Starlight documentation framework — setup, sidebar navigation, frontmatter, built-in components, asides, theming, i18n, search
stack-sqlserver
Microsoft SQL Server database — indexing, RCSI, set-based operations, SARGable queries, transaction scopes
stack-springboot
Spring Boot architecture patterns — REST API design, layered services, JPA, caching, Spring Security, TDD with MockMvc and Testcontainers, and pre-release verification