Agent skill · software engineering · affaan-m

kotlin-ktor-patterns

Ktor server patterns including routing DSL, plugins, authentication, Koin DI, kotlinx.serialization, WebSockets, and testApplication testing. Use when building a Ktor server — routing, plugins, auth, DI, serialization, or tests.

Why this skill is useful

Provides specific Ktor server patterns and integration examples that the AI wouldn't reliably generate on its own.

What it needs

Requires kotlin, ktor installed locally. About 7k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

Ktor Server Patterns Comprehensive Ktor patterns for building robust, maintainable HTTP servers with Kotlin coroutines. When to Activate Building Ktor HTTP servers Configuring Ktor plugins (Auth, CORS, ContentNegotiation, StatusPages) Implementing REST APIs with Ktor Setting up dependency injection with Koin Writing Ktor integration tests with testApplication Working with WebSockets in Ktor Application Structure Standard Ktor Project Layout Application Entry Point Routing DSL Basic Routes Route Organization with Authenticated Routes Content Negotiation & Serialization kotlinx.serialization Setup Serializable Models Custom Serializers Authentication JWT Authentication Auth Routes Status Pages (Error Handling) CORS Configuration Koin Dependency Injection Module Definition Using Koin in Routes Koin for Testing Request Validation WebSockets testApplication Testing Basic Route Testing Testing Authenticated Routes Configuration application.yaml Reading Config Quick Reference: Ktor Patterns Pattern Description --------- ------------- route("/path") { get { } } Route grouping with DSL call.receive<T>() Deserialize request body call.respond(status, body) Send response with status call.parameters["id"] Read path parameters call.request.queryParameters["q"] Read query parameters install(Plugin) { } Install and configure plugin authenticate("name") { } Protect routes with auth by inject<T>() Koin dependency injection testApplication { } Integration testing Remember: Ktor is designed around Kotlin coroutines and DSLs. Keep routes thin, push logic to services, and use Koin for dependency injection. Test with testApplication for full integration coverage.

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/kotlin-ktor-patterns--6701d9

View the source on GitHub

Browse the @skills marketplace