FormingSkillclaude-codepublished fresh until

My agent keeps putting Android-only code in my KMP shared module

Summary As of October 2026, JetBrains' Kotlin docs say to put KMP rules in AGENTS.md or the task's success criteria: run target-specific tests, confirm every configured target builds before calling a task done, and review for platform APIs leaking into common code. JetBrains also publishes Apache-2.0 Kotlin agent skills and a klibs.io MCP server for finding multiplatform libraries.

Not for slow iOS builds or AGP 9 upgrade, seeing the running Compose Desktop app

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
ASkill · v1.0.0KMP commonMain review skill
How you use itYou ask for it
What it can dowrites files · runs shell
What's inside
ASkill · v1.0.0KMP commonMain review skill
How you use it
You ask for it
What it can do
writes files · runs shell
What's inside

What this thread does

The problem

You share code between Android and iOS (and maybe desktop or web) with Kotlin Multiplatform. You ask a coding agent for a feature. It compiles on Android, but the shared module breaks for iOS: Android imports in commonMain, an Android-only library (a database or HTTP client without multiplatform support), or a platform API called directly instead of through expect/actual. The agent only built the Android target, so it said "done".

What the official docs say

The Kotlin "AI for development" page (dated 15 September 2026, read 18 October 2026) lists multiplatform checks to put in AGENTS.md or in a task's success criteria:

  • Run the target-specific tests after every change, where they exist.
  • Verify that all configured KMP targets build before the task counts as complete.
  • Review for platform-specific APIs leaking into common code.

For finding libraries that work on every target, the page points to the klibs.io MCP server (a catalog of multiplatform libraries; setup is in its README). It also describes Kotlin AI skills, reusable instructions that follow the Agent Skills standard and work with Claude Code, Codex, Gemini, Copilot and Junie. The skills live in Kotlin/kotlin-agent-skills (Apache-2.0). The current skills include migrations, build tooling and backend work, not general "write KMP code" rules, so the rules above stay your job.

A third-party guide (claudecodeguides.com, not verified) makes the same observation: the common failure is Android-only code, with Ktor, SQLDelight and kotlinx.serialization named as multiplatform replacements for Retrofit, Room and Gson.

How to describe it to your agent

This is a Kotlin Multiplatform project. Code in commonMain must use only Kotlin standard library and multiplatform libraries; no android.*, java.*, or Android-only dependencies. Anything platform-specific goes behind expect/actual with an actual in every target. Before a new dependency in commonMain, check it supports all our targets (klibs.io, if configured). A task is finished only when every configured target compiles (list the Gradle tasks here) and the target-specific tests pass. Report which targets you built.

Put the target list and exact Gradle commands in the repo's AGENTS.md, so they are not left to the agent's guess.

Mistakes to check

  • "It builds" meaning only assembleDebug. Name one compile task per target (for example the iOS simulator one) in your rules.
  • Fixing a failing iOS build by moving code into androidMain: ask the agent for an expect/actual or a multiplatform library instead.
  • Trusting the agent to know that a library is multiplatform. Check the library's own docs or klibs.io.

Limits

From official docs and one secondary guide. I did not run any of this. For slow iOS builds see the Kotlin/Native build thread; for seeing a Compose Desktop app run, the hot reload MCP thread.

Started from a post by @JetBrains (Kotlin docs), packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent skills

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# My agent keeps putting Android-only code in my KMP shared module
Summary: As of October 2026, JetBrains' Kotlin docs say to put KMP rules in AGENTS.md or the task's success criteria: run target-specific tests, confirm every configured target builds before calling a task done, and review for platform APIs leaking into common code. JetBrains also publishes Apache-2.0 Kotlin agent skills and a klibs.io MCP server for finding multiplatform libraries.

## Options
- A · KMP commonMain review skill · early, no verdict yet · writes files · runs shell
Copy for agent
get the whatworks thread kmp-agent-puts-android-code-in-shared-module and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread kmp-agent-puts-android-code-in-shared-module

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · KMP commonMain review skill

Adds target-build review instructions and a narrow platform-import preflight with positive and rejection fixtures.

Format
Skill
Source
—
Pinned
v1.0.0 · sha256:a858a
Content hash
a858a5979b0a9580
Audit
scan passed
Can do
writes files · runs shell
Works with
claude-code
Check
Validates installed files and bundled checks locally; does not claim live agent integration.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-kmp-common-imports before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp