kotlin-ktor-patterns

Apply Kotlin Ktor patterns for routing, DI, authentication, and WebSockets.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/TruCol270/salty-pickle --skill kotlin-ktor-patterns-trucol270
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-ktor-patterns
Source: https://github.com/TruCol270/salty-pickle/tree/main/.claude-skills/kotlin-ktor-patterns
Command: npx skills add https://github.com/TruCol270/salty-pickle --skill kotlin-ktor-patterns-trucol270

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin backend development with Ktor often requires assembling many patterns (routing, DI, authentication, serialization, WebSockets, and testing) to build robust HTTP servers. This skill consolidates those patterns into a cohesive blueprint, reducing setup time and ensuring consistent architecture across projects.

Core Features & Use Cases

  • Routing DSL templates and module organization for common endpoints (e.g., users, auth, health)
  • Content negotiation and serialization setup with kotlinx.serialization
  • JWT authentication wiring and protected routes
  • Dependency injection patterns using Koin and test wiring
  • StatusPages, CORS, and error handling for resilient APIs
  • WebSockets example and chatRoutes pattern for real-time communication
  • Integration tests scaffolding using testApplication for end-to-end coverage

Quick Start

Set up a Kotlin Ktor project and apply the routing, DI, authentication, status pages, and WebSocket patterns described to scaffold a production-ready HTTP server.

Frequently Asked Questions about kotlin-ktor-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a scalable Kotlin Ktor backend with routing and dependency injection?

You structure a scalable Ktor backend by applying modular project organization, routing DSL templates for endpoints, and explicit dependency injection wiring using Koin to ensure a production-ready server.

How do I set up JWT authentication in a Ktor server?

You set up JWT authentication in a Ktor server by wiring authentication plugins to protect specific routes, ensuring secure access control within your Kotlin web API.

Can I use WebSockets for real-time communication in a Kotlin Ktor application?

Yes, you can use WebSockets in a Kotlin Ktor application by applying the chatRoutes pattern to enable real-time communication endpoints alongside your standard HTTP routes.

What's the best way to handle errors and configure CORS in Ktor?

The best way to handle errors and configure CORS in Ktor is by applying the StatusPages plugin for resilient error handling and configuring CORS plugins to manage cross-origin requests safely.

How do I write integration tests for a Ktor web API?

You write integration tests for a Ktor web API by using the testApplication scaffolding to achieve end-to-end test coverage for your routing, DI, and authentication setup.

Does this Ktor pattern support kotlinx.serialization for content negotiation?

Yes, these Ktor patterns support kotlinx.serialization for content negotiation, providing the setup needed to serialize and deserialize JSON payloads across your HTTP server endpoints.