agentleFS
KotlinKotlin/kotlinx-rpc/CLAUDE.md

kotlinx-rpc

CLAUDE.md1.1k starsChanged 5 days agoApache-2.0View on GitHub

The skill from https://mr3zee.github.io/code-doc-writer/ must be installed and used in every session that adds/changes committed files. kotlinx-rpc is a Kotlin Multiplatform library for building RPC services. Version catalog: versions-root/libs.versions.toml EXTREMELY IMPORTANT. This library is a protocol agnostic library. It can be called a Kotlin RPC toolkit. It hosts different protocols: - kRPC (custom protocol) - gRPC (HTTP/2 + Protocol Buffers) They are not TRANSPORTS. Each protocol has its own client and server implementations, as well as code generation patterns. IMPORTANT:…

We split this CLAUDE.md into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always operate at maximum effort level.

    line 10
  2. Very specific:

    Use the running_gradle_tests skill.

    line 28
  3. Very specific:

    Use the running_gradle_builds skill for these tasks:

    line 38
  4. Distinctive:

    All published modules require explicit return types and visibility

    line 136
  5. Distinctive:

    All public types require KDoc

    line 137
  6. Distinctive:

    Use gradle-conventions and gradle-conventions-settings for all Gradle project changes when the change is either large or is intended for …

    line 145
  7. Very specific:

    Gradle: Use the running_gradle_builds skill with clean, then --stop via Bash, then re-run the task with --rerun-tasks …

    line 158
  8. Very specific:

    JS/WASM: delete package-lock.json + build/{js,wasm}, then use the running_gradle_builds skill to run …

    line 159

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

The skill from https://mr3zee.github.io/code-doc-writer/ must be installed and used in every session that adds/changes committed files.

kotlinx-rpc is a Kotlin Multiplatform library for building RPC services. Version catalog: versions-root/libs.versions.toml

Effort Level

Always operate at maximum effort level. Do not ask about effort preferences.

Protocols

EXTREMELY IMPORTANT. This library is a protocol agnostic library. It can be called a Kotlin RPC toolkit. It hosts different protocols:

  • kRPC (custom protocol)
  • gRPC (HTTP/2 + Protocol Buffers)

They are not TRANSPORTS. Each protocol has its own client and server implementations, as well as code generation patterns.

Build & Test

IMPORTANT: Always use Gradle skills (running_gradle_builds, running_gradle_tests, managing_gradle_dependencies, introspecting_gradle_projects, gradle_expert, etc.) instead of running ./gradlew directly. Gradle skills provide structured feedback, failure diagnostics, and background orchestration that raw shell commands lack.

Testing

Use the running_gradle_tests skill. Example tasks:

  • <module>:jvmTest --tests "TestClass.testMethod" -- Single test
  • <module>:jvmTest -- All JVM tests for a module

Building

Use the running_gradle_builds skill. Example tasks:

  • <module>:build -- Build a module
  • assemble -- Assemble all modules

Validation

Use the running_gradle_builds skill for these tasks:

  • checkLegacyAbi -- Binary compatibility (formerly BCV apiCheck)
  • detekt -- Static analysis (does NOT fail build, check console)
  • :jpms-check:compileJava -- Java module system check
  • kotlinUpgradeYarnLock -- Fix JS dependency locks
  • kotlinWasmUpgradeYarnLock -- Fix WASM dependency locks

Non-Gradle validation:

./scripts/validate_published_artifacts.sh -s # Artifact validation (-v verbose, --dump update)

Other specialized commands

./scripts/publish_local.sh                  # Publish to build/repo/ for local testing

Generated Code — Do Not Edit Manually

Several checked-in files are machine-generated. Never modify them by hand — always run the appropriate regeneration task and commit the output. This includes .api and .klib.api ABI dump files (use updateLegacyAbi), conformance test output, WKT generated code, implicit import lists, and other. Hand-editing these files produces incorrect results (e.g., klib dump sort order differs from what's intuitive).

Module Map

The most important modules have brief READMEs in their directories, read when you need to work with the module.

Core (multiplatform)

  • :core -- RPC abstractions (@Rpc, RpcClient, RpcServer, RpcCall, descriptors)
  • :utils -- Shared utilities

kRPC transport (multiplatform)

  • :krpc:krpc-core, :krpc:krpc-client, :krpc:krpc-server -- Protocol, client, server
  • :krpc:krpc-logging, :krpc:krpc-test -- Logging, test utilities
  • :krpc:krpc-serialization:krpc-serialization-{core,json,cbor,protobuf} -- Serialization formats
  • :krpc:krpc-ktor:krpc-ktor-{core,server,client} -- Ktor integration

gRPC transport (experimental KMP)

  • :grpc:grpc-{core,client,server,ktor-server,marshaller,marshaller-kotlinx-serialization}

Protobuf (mainly used with gRPC)

  • :protobuf:protobuf-{api,wkt,core}

Native shims (standalone Gradle build)

  • native-deps/shims/grpc/ -- gRPC cinterop shim KLIB (:kotlinx-rpc-grpc-core-shim)
  • native-deps/shims/protobuf/ -- Protobuf cinterop shim KLIB (:kotlinx-rpc-protobuf-shim)
  • native-deps/shims/annotation/ -- Shared opt-in markers (:kotlinx-rpc-native-shims-annotation)
  • native-deps/grpc-c-prebuilt/ -- Prebuilt gRPC static archives and headers

Included builds (separate Gradle projects)

  • compiler-plugin/ -- Kotlin K2 compiler plugin (FIR diagnostics + IR codegen)
  • gradle-plugin/ -- Gradle plugin (org.jetbrains.kotlinx.rpc.plugin)
  • protoc-gen/ -- Protobuf code generator
  • dokka-plugin/ -- Documentation plugin

Tests (not published)

  • :tests:compiler-plugin-tests -- Compiler plugin box/diagnostic tests (skipped for Kotlin master builds)
  • :tests:krpc-compatibility-tests, :tests:krpc-protocol-compatibility-tests -- Protocol compat
  • :tests:protobuf-conformance -- Protobuf spec conformance (not on Windows)
  • :tests:protobuf-unittest, :tests:grpc-test-server, :tests:test-protos

Architecture

RPC Call Flow

  1. User defines @Rpc interface with suspend methods and/or Flow return types
  2. Compiler plugin generates stub class: each method creates RpcCall(descriptor, methodName, args, serviceId) and delegates to RpcClient.call() (unary) or RpcClient.callServerStreaming() (streaming)
  3. Client serializes the call and sends over wire
  4. Server deserializes, looks up RpcServiceDescriptor, invokes RpcInvokator.call(serviceImpl, args)
  5. Response flows back through the same layers
  6. Client and Server are bound to RPC protocols (kRPC or gRPC)

Key abstractions (core/src/commonMain/kotlin/kotlinx/rpc/)

  • @Rpc annotation on interface -- triggers compiler plugin
  • RpcServiceDescriptor<T> -- generated per-service metadata + stub factory
  • RpcCallable -- per-method metadata + RpcInvokator (either UnaryResponse or FlowResponse)
  • RpcCall -- single invocation payload: descriptor + method name + args + service ID
  • RpcClient / RpcServer -- protocol-agnostic client and server interfaces

kRPC protocol

Custom protocol.

gRPC protocol

HTTP/2 + Protocol Buffers. Code generated from .proto files via protoc-gen/. Uses @Grpc annotation.

Compiler Plugin

Module structure

  • compiler-plugin-common -- Shared between backend and k2
  • compiler-plugin-k2 -- FIR frontend: diagnostics, declaration generation
  • compiler-plugin-backend -- IR backend: codegen (stub classes, descriptors)
  • compiler-plugin-cli -- Entrypoint, combines backend and k2

Conventions

  • All published modules require explicit return types and visibility
  • All public types require KDoc
  • Internal APIs shared across modules: annotate with @InternalRpcApi
  • Dependencies go in versions-root/libs.versions.toml, never inline
  • New modules: includePublic() in settings.gradle.kts for published, include() for internal
  • Published modules auto-prefixed with kotlinx-rpc-
  • Module families: common prefix + core for shared (e.g., krpc-core, krpc-client, krpc-server)
  • Filesystem paths: OS-agnostic only -- Path.of("a", "b") not Path.of("a/b")
  • Disable KMP targets per module: kotlinx.rpc.exclude.<target>=true in module's gradle.properties
  • Use gradle-conventions and gradle-conventions-settings for all Gradle project changes when the change is either large or is intended for more than one subproject. Keep actual build files clean.

Testing

  • Framework: JUnit 5 + kotlin-test + coroutines-test
  • KMP source sets: commonTest, jvmTest, jsTest, nativeTest, etc.

Documentation

Uses Writerside, lives in docs/pages/.

Troubleshooting

  • Gradle: Use the running_gradle_builds skill with clean, then --stop via Bash, then re-run the task with --rerun-tasks --no-configuration-cache --no-build-cache flags via the skill
  • JS/WASM: delete package-lock.json + build/{js,wasm}, then use the running_gradle_builds skill to run kotlinUpgradeYarnLock/kotlinWasmUpgradeYarnLock

References

Download now (ZIP)

Trending

Quiet since September.about the whole repository

Dec 2025: 2 mentionsJan 2026: 1 mentionFeb 2026: 0 mentionsMar 2026: 1 mentionApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 2 mentionsJul 2026: 2 mentionsAug 2026: 0 mentionsSep 2026: 1 mentionOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the Kotlin/kotlinx-rpc repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about Kotlin/kotlinx-rpc

The biggest 5 of 16 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 16

Talked about on GitHub (16 times).

On GitHub · 16

11 more on GitHub

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.