Skip to content
Back to skills

Stack Kotlin

ASecurity

Kotlin language guidelines — idioms, coroutines and flows, Ktor servers, Exposed ORM, and testing with Kotest and MockK

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 6, 2026
ai-agentsgokotlinreactexpresstestingrefactoring

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned November 20, 2026

npx -y skills add Snakeblack/ospec-workflow --skill stack-kotlin --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stack Kotlin?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stack Kotlin
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/snakeblack-stack-kotlin/badge)](https://www.skillsdirectory.com/skills/snakeblack-stack-kotlin)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: stack-kotlin
description: "Kotlin language guidelines — idioms, coroutines and flows, Ktor servers, Exposed ORM, and testing with Kotest and MockK"
license: MIT AND Commons-Clause
metadata:
  author: "affaan-mustafa, manuel-retamozo-garcia"
  version: "1.0"
capabilities: [kotlin]
---

# 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

1. **Null Safety**: Leverage Kotlin's type system (non-nullable by default). Use safe-call (`?.`) and Elvis (`?:`) operators; never use force-unwarp (`!!`).
2. **Immutability by Default**: Use `val` for variables, immutable collections, and data class `copy()` for transformations.
3. **Sealed Types**: Model restricted hierarchies and results with `sealed class` or `sealed interface` for exhaustive `when` expressions.
4. **Structured Concurrency**: Scope async calls using `coroutineScope` or `supervisorScope`. Respect coroutine cancellation via `ensureActive()`.
5. **DSL Builders**: Implement type-safe builders using `@DslMarker` and lambda receivers.
6. **Coroutines and Flows** (`references/coroutines-flows.md`): Never `GlobalScope`; `Dispatchers.IO` for blocking I/O, `Default` for CPU work; expose `StateFlow` for state and `SharedFlow` for one-time events; never catch `CancellationException`.
7. **Ktor** (`references/ktor.md`): Thin routes as `Route` extensions delegating to services; errors mapped centrally in `StatusPages`; protected routes inside `authenticate("jwt")`.
8. **Exposed** (`references/exposed.md`): Every query inside `newSuspendedTransaction`; HikariCP with `isAutoCommit = false`; schema through Flyway migrations.
9. **Testing** (`references/testing.md`): Failing test first; Kotest specs, MockK `coEvery`/`coVerify` for suspend functions (never mock data classes); `runTest` with virtual time.

## References

Load on demand, only the file the task needs:
* [Kotlin Coding Patterns & Examples](references/patterns.md)
* [Coroutines and Flows](references/coroutines-flows.md) — scopes, dispatchers, flow operators, cancellation, Turbine
* [Ktor Server](references/ktor.md) — routing, content negotiation, auth, Koin; examples in [ktor-patterns.md](references/ktor-patterns.md)
* [Exposed ORM](references/exposed.md) — DSL vs DAO, transactions, pooling, migrations; examples in [exposed-patterns.md](references/exposed-patterns.md)
* [Testing](references/testing.md) — Kotest, MockK, coroutine tests, Kover; examples in [testing-patterns.md](references/testing-patterns.md)

Files in this skill

  • SKILL.md2.7 KB
  • 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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.