kmp-kotlin-rpc

Designs and scaffolds Kotlin RPC service contracts for Kotlin Multiplatform full-stack apps.

2|Updated Jun 6, 2026
One-click install
npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-kotlin-rpc-ronjunevaldoz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kmp-kotlin-rpc
Source: https://github.com/ronjunevaldoz/kmp-agent-skills/tree/main/skills/kmp-kotlin-rpc
Command: npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-kotlin-rpc-ronjunevaldoz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Choosing and wiring a transport layer between a Kotlin Multiplatform client and its Kotlin backend is error-prone: teams often duplicate HTTP calls alongside existing RPC services, misplace shared contracts, or pick REST when a typed Kotlin-to-Kotlin boundary would be simpler. This Skill provides decision guidance, module layout rules, and a scaffold script for kotlinx-rpc based architectures. ## Core Features & Use Cases - RPC vs REST vs gRPC decision guidance: Determines when Kotlin RPC fits (Kotlin-to-Kotlin boundaries) and when REST or gRPC is the better choice for public or cross-language APIs. - Shared contract architecture: Defines a clean split between shared service interfaces and DTOs, server-side Ktor wiring, and thin client stubs, with auth kept at the Ktor route boundary. - Streaming support: Documents kotlinx-rpc Flow streaming constraints (Flow only, non-suspending top-level return type) and the native gRPC/Protobuf option. - Scaffold script: Generates a starter shared/server/client RPC module layout with a single command. - Use Case: You are adding a data-layer call to a KMP app and need to know whether to extend an existing RPC service interface or create a new HTTP endpoint — the pre-implementation grep check and anti-pattern list prevent parallel transports from diverging. ## Quick Start Ask the agent to scaffold a Kotlin RPC layout for package com.example.app and design a GreetingService contract with shared request and response models.

Frequently Asked Questions about kmp-kotlin-rpc

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

FAQPage Schema
When should I use Kotlin RPC instead of REST in a KMP app?▼

Use Kotlin RPC when both the client and server are Kotlin-first and procedure-style calls fit better than resource-oriented REST. Choose REST when the API is public, consumed by non-Kotlin clients, or needs standard HTTP tooling for inspection.

How do I structure a kotlinx-rpc project in Kotlin Multiplatform?▼

Place service interfaces and request/response DTOs in a shared module, install the RPC implementation in a Ktor server module behind authenticated routes, and keep transport setup plus generated stubs in the client module. The included scaffold script generates this layout.

Does kotlinx-rpc support streaming with Flow?▼

Yes, kotlinx-rpc supports Flow-returning streaming methods over the same Ktor transport. The method must be non-suspending with Flow as the top-level return type; StateFlow and SharedFlow are not supported and must be converted on the client.

Kotlin RPC vs gRPC for Kotlin Multiplatform backends?▼

Plain kotlinx-rpc is simpler for Kotlin-only boundaries with shared models. Use kotlinx-rpc's native gRPC/Protobuf integration only when the contract must interoperate with non-Kotlin gRPC clients via schema-first .proto files.

Why should I avoid adding HTTP calls alongside an existing RPC service?▼

Parallel HTTP calls to operations already exposed on an RPC service create two diverging code paths with duplicated token refresh, error handling, and serialization config. Extend the existing service interface with a new method instead.