Use when ktor server patterns including routing DSL, plugins, authentication, Koin DI, kotlinx.serialization, WebSockets, and testApplication testing. Only for Kotlin/Ktor — not for other frameworks. Triggers on \"kotlin-ktor-patterns\", \"kotlin ktor patterns\", \"patterns\".
Scanned 9/19/2026
Install to Claude Code
npx -y skills add majinmagros/magros.ai-skills --skill kotlin-ktor-patterns --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Kotlin Ktor Patterns?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/majinmagros-kotlin-ktor-patterns)More formats (shields.io, HTML) on the badges page.
---
name: kotlin-ktor-patterns
description: "Use when ktor server patterns including routing DSL, plugins, authentication, Koin DI, kotlinx.serialization, WebSockets, and testApplication testing. Only for Kotlin/Ktor — not for other frameworks. Triggers on \"kotlin-ktor-patterns\", \"kotlin ktor patterns\", \"patterns\"."
metadata:
origin: ECC
---
# 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
## When NOT to Use
- Other frameworks (use `kotlin-ktor-patterns` only for Ktor; Spring Boot → `springboot-patterns`)
- Kotlin idioms in general (use `kotlin-patterns`)
- Kotlin testing in general (use `kotlin-testing`)
## Contents
| Topic | Reference |
|---|---|
| Project layout, entry point, routing | `references/structure-routing.md` |
| Serialization (kotlinx.serialization) | `references/serialization.md` |
| JWT auth, auth routes, StatusPages | `references/auth-errors.md` |
| CORS, Koin DI, validation | `references/cors-koin.md` |
| WebSockets, testApplication | `references/websockets-testing.md` |
| application.yaml config | `references/config.md` |
## Example
```kotlin
// Thin route → service (idiomatic Ktor)
routing {
authenticate("auth-jwt") {
get("/orders") {
call.respond(orderService.listRecent())
}
}
}
```
## 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 |
## ReferênciasIs this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!