ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry
Claude Code and agent skill by ronjunevaldoz/kmp-agent-skills
- community
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-mimicrySKILL.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 inEngineModifier,EngineScope,EngineUiDsl) is a placeholder in this SKILL.md's worked example, exactly likeGROUP_ID. It must never be written to disk literally for a real project — pick yourown project's actual prefix before writing the first mimicked primitive. Do not fuseyour backend's brand name with the reference API's own type name either (e.g. don'tname itVulkanModifierjust because the backend is Vulkan and the mimicked type isCompose'sModifier) unless that fusion is genuinely your project's establishedconvention — it usually isn't, and reads as if it were copied from a real, verifiedsource when it's just this example's stand-in.
Recommendation First
Default to this approach:
- 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.
- 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.
- Never reuse the reference library's package namespace or literal branding. Own
group id, own package, own annotation name (@EngineUiDsl, not @Composable).
- 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
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 it | Mimicable without a compiler plugin? | Kotlin equivalent | |
|---|---|---|---|---|
@Composable function | Compose compiler plugin (call-site tracking, skipping) | No — mimicking the annotation without the plugin gives you a plain function call, not real skipping | Own marker annotation (@EngineUiDsl) used as documentation only; be explicit it's not enforced | |
Modifier chain | Plain immutable linked-list-style object with then() | Yes, fully | Sealed interface + then(), exactly Compose's own shape — no magic involved | |
Slot lambda (content: @Composable () -> Unit) | Trailing lambda + receiver scope, a plain language feature | Yes, fully | fun Box(content: EngineScope.() -> Unit) | |
CompositionLocal | Compose runtime's ambient value propagation through the composition tree | No — depends on the runtime tracking a composition tree | Explicit scope object threaded as a parameter, or a plain ThreadLocal/context object if the design tolerates it | |
remember { } / mutableStateOf | Compose's snapshot state system + recomposition scheduler | No — reimplementing snapshot state from scratch is a multi-month undertaking | An explicit state holder bound to your own render loop's invalidation call (requestRedraw()); callers manage identity/keys themselves | |
LaunchedEffect / lifecycle-scoped coroutines | Compose runtime lifecycle integration | Partially | Your own scene-graph node lifecycle + CoroutineScope bound to node attach/detach |
Decision Table: plain-function DSL vs. real compiler plugin
| Signal | Choose | |
|---|---|---|
| Ergonomics (chainable modifiers, slot DSL, readable call sites) is the goal | Plain-function DSL — covers this fully | |
| Fine-grained recomposition/skipping is a measured perf requirement, not assumed | Real 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-term | If 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 semantics | Neither — 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 mimicked | What's mimicked (ergonomics, not internals) | What's explicitly not mimicked | |
|---|---|---|---|
| Retrofit-style declarative service interfaces | interface-with-annotated-methods DSL, generating a typed client at your call boundary | Retrofit'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 surface | Room's KSP-generated implementation — back it with your own hand-written or codegen'd implementation for your storage engine | |
SwiftUI's ViewBuilder/declarative tree | Trailing-closure-equivalent slot lambdas, same as the Compose row above | SwiftUI's own diffing/identity system | |
| Jetpack Compose (worked example below) | Modifier chain, slot lambdas, DSL marker annotations | Snapshot 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.
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
- SKILL.md in the repositoryCheckingskills/kmp-api-mimicry/SKILL.md
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
[](https://verified-skill.com/skills/ronjunevaldoz/kmp-agent-skills/kmp-api-mimicry)