ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry

Claude Code and agent skill by ronjunevaldoz/kmp-agent-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Mimics the public API *shape* (DSL entry points, chainable modifier objects, slot lambdas, marker annotations, scoped builders) of a well-known reference API — Jetpack Compose, SwiftUI, Retrofit, Room, etc. — when building a from-scratch Kotlin Multiplatform library on a different runtime (a custom Vulkan/Metal renderer, a custom RPC engine, a custom persistence engine). Does NOT cover consuming or wrapping the real reference library — that is normal dependency usage. Does NOT cover building a real Compose-compiler-style plugin; explicitly scopes to plain-function DSL mimicry and documents what real recomposition/skipping you give up by not writing one.

Install

npx vskill@latest install ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry

SKILL.md

The same SKILL.md was published earlier as ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry.

When to Use This Skill

Use this skill when you need to:

  • Build a Kotlin Multiplatform library on a non-standard runtime (a custom native

renderer, a custom transport, a custom storage engine) and want its Kotlin API to feel like a well-known reference API (Jetpack Compose, SwiftUI, Retrofit, Room, ...) without literally depending on or reimplementing that library's internals

  • Design a chainable configuration object (a Modifier-equivalent) for a custom

rendering or layout engine

  • Design a slot-lambda DSL (content: Scope.() -> Unit) for a custom scene-graph builder
  • Decide how far to take the mimicry — plain-function DSL vs. writing an actual

Kotlin compiler plugin — before committing engineering time to either

  • Document, for future maintainers and for legal clarity, exactly which parts of a

reference API were mimicked and which were deliberately changed

Do NOT use this skill when:

  • The project already depends on the real reference library (Compose Multiplatform,

Ktor, etc.) and just needs to use it — that is ordinary consumption, not mimicry; see kmp-compose-design-system for building a design system on top of real Compose Multiplatform

  • The goal is a real Kotlin compiler plugin providing true fine-grained recomposition —

that is a distinct, much larger undertaking this skill deliberately does not cover; it only tells you when that investment is actually justified (see Decision Table below)

  • The goal is copying the reference library's actual source code under a new package —

never do this; see Guidelines

Trigger keywords: mimic api, api mimicry, clone api shape, inspired by jetpack compose, custom dsl engine, from-scratch renderer, vulkan ui, metal ui, port api ergonomics, reimplement compose-like dsl, non-compose renderer, engine-agnostic dsl, own compiler-free dsl, api shape porting, compliance audit, trademark violation, font license, clean room implementation, IP audit.

Freshness rule: the reference API you are mimicking changes between its own releases (Jetpack Compose's Modifier and CompositionLocal surface, SwiftUI's ViewBuilder, etc.) — re-read the reference API's current public docs before mimicking a new version's shape. Never mimic from memory or from an old cached understanding of the reference API; verify against its real current source or docs.


Hard rule — never violated: Engine (as in EngineModifier, EngineScope,
EngineUiDsl) is a placeholder in this SKILL.md's worked example, exactly like
GROUP_ID. It must never be written to disk literally for a real project — pick your
own project's actual prefix before writing the first mimicked primitive. Do not fuse
your backend's brand name with the reference API's own type name either (e.g. don't
name it VulkanModifier just because the backend is Vulkan and the mimicked type is
Compose's Modifier) unless that fusion is genuinely your project's established
convention — it usually isn't, and reads as if it were copied from a real, verified
source when it's just this example's stand-in.

Recommendation First

Default to this approach:

  1. Catalog the reference API's real public surface first — read its actual current

docs/source, don't guess. List the specific types/functions/annotations you intend to mimic.

  1. Mimic ergonomics, not internals. A chainable Modifier-style object and a

slot-lambda DSL are cheap to mimic faithfully with plain Kotlin. Recomposition, snapshot state, and skipping are not — they depend on the reference's own compiler plugin. Default to a plain-function DSL with explicit invalidation, not a fake compiler plugin.

  1. Never reuse the reference library's package namespace or literal branding. Own

group id, own package, own annotation name (@EngineUiDsl, not @Composable).

  1. Write a mirror map at docs/MIRROR_MAP.md (not project root — this is a

Reference-kind doc per kmp-project-docs-maintainer's docs-hygiene.md, same placement rule as any other permanent, update-in-place registry) documenting each mimicked primitive, its inspiration, the deliberate deviation, and whether the reference API's own common-case convenience shorthand for that primitive was mirrored too (e.g. Compose's Modifier.fillMaxSize() is sugar over .width(Max).height(Max) — implementing only the low-level combinator and skipping the shorthand real consumers actually reach for is an incomplete mimicry, not a smaller one) — before writing the second mimicked primitive, not after the tenth. Mimicking more than one reference API (Compose's Modifier and a themed component API like shadcn-compose) in the same project? One file, add a Reference API column instead of splitting into one map per reference — keeps a single source of truth. If it grows past docs-hygiene.md's 150-line limit for any docs/ file (mechanically checked by audit_skills_repo.py --docs-hygiene-only), split by Reference API into docs/reference/mirror-map-<reference>.md files, and keep docs/MIRROR_MAP.md itself as a short index pointing to each.

Why:

  • most of a reference API's ergonomics (chainable config, slot lambdas, scoped

builders) come from ordinary Kotlin language features, not compiler magic — you get 90% of the developer-experience win for a fraction of the effort

  • a real compiler plugin is a permanent maintenance burden riding on your own fork of

Kotlin compiler internals — only justified when fine-grained recomposition is a measured, not assumed, performance requirement

  • consumers who see @Composable-shaped code assume @Composable-shaped guarantees;

an undocumented gap between mimicked ergonomics and real behavior is where the bug reports come from

kotlin
// Own annotation, own package — not androidx.compose.runtime.Composable
@DslMarker
annotation class EngineUiDsl
@EngineUiDsl
sealed interface EngineModifier {
fun then(other: EngineModifier): EngineModifier =
if (other is EngineModifier.None) this else CombinedEngineModifier(this, other)
object None : EngineModifier
}

Core Pattern: Mapping Reference Primitives to Plain Kotlin

This method applies to any reference API — the table below uses Jetpack Compose as the running example because it has the richest primitive set (DSL, chain object, scoped ambient values, state), not because this skill is Compose-specific. See "Other reference APIs, same method" below for non-UI examples.

Reference primitive (e.g. Jetpack Compose)What actually powers itMimicable without a compiler plugin?Kotlin equivalent
@Composable functionCompose compiler plugin (call-site tracking, skipping)No — mimicking the annotation without the plugin gives you a plain function call, not real skippingOwn marker annotation (@EngineUiDsl) used as documentation only; be explicit it's not enforced
Modifier chainPlain immutable linked-list-style object with then()Yes, fullySealed interface + then(), exactly Compose's own shape — no magic involved
Slot lambda (content: @Composable () -> Unit)Trailing lambda + receiver scope, a plain language featureYes, fullyfun Box(content: EngineScope.() -> Unit)
CompositionLocalCompose runtime's ambient value propagation through the composition treeNo — depends on the runtime tracking a composition treeExplicit scope object threaded as a parameter, or a plain ThreadLocal/context object if the design tolerates it
remember { } / mutableStateOfCompose's snapshot state system + recomposition schedulerNo — reimplementing snapshot state from scratch is a multi-month undertakingAn explicit state holder bound to your own render loop's invalidation call (requestRedraw()); callers manage identity/keys themselves
LaunchedEffect / lifecycle-scoped coroutinesCompose runtime lifecycle integrationPartiallyYour own scene-graph node lifecycle + CoroutineScope bound to node attach/detach
Decision Table: plain-function DSL vs. real compiler plugin
SignalChoose
Ergonomics (chainable modifiers, slot DSL, readable call sites) is the goalPlain-function DSL — covers this fully
Fine-grained recomposition/skipping is a measured perf requirement, not assumedReal compiler plugin — but treat this as its own multi-month project, not an extension of this skill
Team size / maintenance budget for owning Kotlin compiler plugin internals long-termIf small, plain-function DSL — a compiler plugin tracks Kotlin compiler versions forever
Consumers must be able to write literal @Composable functions and get real Compose semanticsNeither — depend on real Compose Multiplatform instead; mimicry no longer applies
Other reference APIs, same method

Jetpack Compose is one example, not the scope of this skill. The same catalog → map → decide → mirror-map method applies to any reference API's ergonomics:

Reference API mimickedWhat's mimicked (ergonomics, not internals)What's explicitly not mimicked
Retrofit-style declarative service interfacesinterface-with-annotated-methods DSL, generating a typed client at your call boundaryRetrofit's actual annotation processor / CallAdapter machinery — write a plain factory function instead
Room-style DAO annotations@Dao-shaped method-per-query interface as the ergonomic surfaceRoom's KSP-generated implementation — back it with your own hand-written or codegen'd implementation for your storage engine
SwiftUI's ViewBuilder/declarative treeTrailing-closure-equivalent slot lambdas, same as the Compose row aboveSwiftUI's own diffing/identity system
Jetpack Compose (worked example below)Modifier chain, slot lambdas, DSL marker annotationsSnapshot state, recomposition, CompositionLocal propagation
Worked example: Vulkan-backed UI DSL inspired by Jetpack Compose

One concrete instance of the method above — not the only valid target for this skill. A KMP library wraps a custom Vulkan rendering backend (via expect/actual + JNI/cinterop — see kmp-jni-pro and kmp-expect-actual) and needs a Compose-shaped declarative UI layer on top of it.

Naming below uses the Engine placeholder — see the hard rule above before writing any of this to disk for a real project.

kotlin
// :library/src/commonMain/kotlin/.../EngineModifier.kt
@EngineUiDsl
sealed interface EngineModifier {
object None : EngineModifier
}
private data class CombinedEngineModifier(
val outer: EngineModifier,
val inner: EngineModifier,
) : EngineModifier
fun EngineModifier.padding(all: Dp): EngineModifier = this.then(PaddingModifier(all))
fun EngineModifier.size(width: Dp, height: Dp): EngineModifier = this.then(SizeModifier(width, height))
// :library/src/commonMain/kotlin/.../EngineScope.kt
class EngineScope internal constructor(private val node: SceneNode) {
@EngineUiDsl
fun Box(modifier: EngineModifier = EngineModifier.None, content: EngineScope.() -> Unit) {
val child = node.addChild(SceneNode.Kind.Box, modifier)
EngineScope(child).content()
}
@EngineUiDsl
fun Text(text: String, modifier: EngineModifier = EngineModifier.None) {
node.addChild(SceneNode.Kind.Text(text), modifier)
}
}
// Entry point — mirrors setContent { } shape, explicit invalidation instead of
// Compose's snapshot-driven recomposition
fun EngineCanvas.setContent(content: EngineScope.() -> Unit) {
val root = SceneNode.root()
EngineScope(root).content()
this.submit(root) // hands the built scene graph to the Vulkan backend
}

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry/badge)](https://verified-skill.com/skills/ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry)

Something wrong with this skill or its page? Tell us.