kotlin-ktor-patterns

Generate Ktor server patterns for REST routing, JWT auth, Koin DI, and testApplication tests.

Updated Sep 13, 2025
One-click install
npx skills add https://github.com/llmh333/employee_management_spring --skill kotlin-ktor-patterns-llmh333
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-ktor-patterns
Source: https://github.com/llmh333/employee_management_spring/tree/main/.gemini/skills/kotlin-ktor-patterns
Command: npx skills add https://github.com/llmh333/employee_management_spring --skill kotlin-ktor-patterns-llmh333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reduces the time and guesswork needed to set up a production-ready Ktor HTTP server by providing ready-to-adapt patterns for routing, plugins, authentication, DI, serialization, WebSockets, and integration testing.

Core Features & Use Cases

  • Routing DSL & Route Organization: Structure REST endpoints cleanly with route grouping and authenticated sub-routes.
  • Ktor Plugin Configuration: Apply consistent behaviors for JSON serialization, CORS, and centralized error handling via StatusPages.
  • Authentication & Testing: Integrate JWT authentication and validate behavior end-to-end using testApplication, including protected-route scenarios.
  • Koin DI Patterns: Wire services and repositories with Koin so routes stay thin and business logic remains testable.
  • WebSockets Support: Add real-time communication with WebSockets and safe connection broadcasting.

Quick Start

Use the kotlin-ktor-patterns skill to generate a Ktor application module that includes serialization, JWT authentication, StatusPages error handling, CORS, Koin-based DI, REST routing, and testApplication-based integration tests.

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 REST routing and organize routes in a Ktor server?

Ktor REST routing is structured using the routing DSL to group endpoints cleanly, supporting authenticated sub-routes and thin route declarations to keep business logic testable and maintainable.

What's the best way to configure JWT authentication and test protected routes in Ktor?

JWT authentication in Ktor is configured via authentication plugins, and protected routes are validated end-to-end using testApplication integration testing to verify token handling and access control.

How do I wire Koin dependency injection into Ktor routes?

Koin dependency injection is wired into Ktor by configuring modules for services and repositories, ensuring routes stay thin while keeping business logic independently testable outside the server framework.

Can I add WebSocket message broadcasting to a Ktor HTTP server?

WebSocket message broadcasting is supported in Ktor, allowing you to add real-time communication channels with safe connection management and message distribution across connected clients.

How do I set up Ktor plugins for JSON serialization, CORS, and error handling?

Ktor plugins are configured to apply consistent behaviors across the server, handling JSON serialization via kotlinx.serialization, CORS for cross-origin requests, and centralized error handling via StatusPages.