Agent skill

Kmp Ktor

by rcosteira79 in rcosteira79/android-skills

A skill your agent uses when setting up or working with Ktor client in KMP or Android projects — HttpClient configuration, per-platform engine selection, kotlinx.serialization, bearer auth with…

MITAuto-check passedBackend & APIs

Install Kmp Ktor

skills CLI
$ npx skills add rcosteira79/android-skills --skill kmp-ktor -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rcosteira79/android-skills kmp-ktor --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rcosteira79/android-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/android-skills/skills/kmp-ktor .claude/skills/kmp-ktor && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
kmp-ktor
GitHub stars
153
Token cost
~1.7k tokens
SKILL.md length
512 words
Files
1
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when setting up or working with Ktor client in KMP or Android projects — HttpClient configuration, per-platform engine selection, kotlinx.serialization, bearer auth with…

  • Working with Ktor client in KMP
  • SKILL.md covers Plugin install order —…, encodeDefaults = true — or…, expectSuccess — pick one… and Bearer refresh —…, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Android projects — HttpClient configuration

What it does

Kmp Ktor is an agent skill from rcosteira79/android-skills. Use when setting up or working with Ktor client in KMP or Android projects — HttpClient configuration, per-platform engine selection, kotlinx.serialization, bearer auth with refresh, MockEngine testing, and error mapping at the repository boundary.

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs. It works with Android and Kotlin. The repository describes itself as: Claude Code skills for Android & KMP development. The licence is MIT.

When your agent uses it

  • Working with Ktor client in KMP
  • Android projects — HttpClient configuration
  • Per-platform engine selection
  • Kotlinx.serialization

Example prompts

  • “/kmp-ktor”

What it can do on your machine

Read from SKILL.md and the folder at commit 0f9af5a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are kotlin).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Kmp Ktor loads about 1.7k tokens when it runs. Until then it costs about 64 tokens; SKILL.md has 512 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~64
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rcosteira79/android-skills at commit 0f9af5a, republished under its MIT licence (© rcosteira79). 512 words, ~1,701 tokens.

Download SKILL.mdSave it as .claude/skills/kmp-ktor/SKILL.md (or your agent's skills folder).
name
kmp-ktor
description
Use when setting up or working with Ktor client in KMP or Android projects — HttpClient configuration, per-platform engine selection, kotlinx.serialization, bearer auth with refresh, MockEngine testing, and error mapping at the repository boundary.

Ktor Client for KMP and Android

This reference covers the Ktor client configuration traps — plugin install order, serialization flags, auth refresh, and error mapping — not the basics of a shared HttpClient, engine selection, or ContentNegotiation setup. Related: android-skills:android-data-layer (repository + the DataError error model — its canonical home), android-skills:android-retrofit (Android-only equivalent).

Plugin install order — HttpRequestRetry BEFORE HttpTimeout

The install order most often gotten wrong: installing HttpTimeout before HttpRequestRetry. Plugins run in install order for outgoing requests; retries must be able to catch timeout errors, so retry has to wrap timeout.

kotlin
val json = Json { ignoreUnknownKeys = true; coerceInputValues = true; encodeDefaults = true }  // encodeDefaults: see the section below

HttpClient(engine) {
    install(ContentNegotiation) { json(json) }
    install(Auth) { bearer { /* loadTokens / refreshTokens */ } }
    install(HttpRequestRetry) {                 // BEFORE HttpTimeout
        retryOnServerErrors(maxRetries = 3)
        exponentialDelay()
    }
    install(HttpTimeout) {                       // AFTER HttpRequestRetry
        requestTimeoutMillis = 30_000; connectTimeoutMillis = 15_000; socketTimeoutMillis = 15_000
    }
}

Reversed, HttpTimeout resolves the request as failed before the retry plugin sees it, so timeouts are never retried. (Separately, the Auth plugin handles 401 refresh independently — let HttpRequestRetry cover transient/5xx failures; don't chain the two around the same status code.)

encodeDefaults = true — or protocol-constant fields silently vanish

kotlinx.serialization defaults to encodeDefaults = false, which strips any property whose value equals its declared default from the serialized output. A jsonrpc: String = "2.0" (or version = "1.0", type = "...") disappears from the payload; the server rejects every request with a generic "invalid request," and the fix is a one-line flag — found only after hours chasing HTTP-layer red herrings. Always set it for client APIs — the val json defined at the top of this file does, alongside ignoreUnknownKeys and coerceInputValues. That one configured instance is what the whole client shares: install(ContentNegotiation) { json(json) } and the WebSocket converter both take it.

expectSuccess — pick one model, consistently

expectSuccess = true makes Ktor throw ClientRequestException (4xx) / ServerResponseException (5xx) on non-2xx — and that throw runs before any manual status check, so an if (response.status == OK) branch after it is dead code. Pick one model project-wide: expectSuccess = true + try/catch (matches the repository pattern), or expectSuccess = false + explicit response.status.isSuccess() inspection. Never mix them.

Show full SKILL.md (225 more words)Show less

Bearer refresh — markAsRefreshTokenRequest() or it loops

In the Auth bearer { refreshTokens { … } } block, mark the refresh POST with markAsRefreshTokenRequest() so it isn't intercepted by the same Auth plugin — without it, a failing refresh triggers another refresh, looping infinitely. It's an HttpRequestBuilder extension: call it inside the request builder block, not bare in refreshTokens { } (where it doesn't compile).

kotlin
install(Auth) {
    bearer {
        loadTokens { tokenStorage.getTokens()?.let { BearerTokens(it.access, it.refresh) } }
        refreshTokens {
            val refresh = oldTokens?.refreshToken ?: return@refreshTokens null
            val r = client.post("auth/refresh") {
                markAsRefreshTokenRequest()                      // skip the Auth plugin for this call
                setBody(RefreshRequestDto(refresh))
            }.body<TokenResponseDto>()
            tokenStorage.save(r.accessToken, r.refreshToken); BearerTokens(r.accessToken, r.refreshToken)
        }
        sendWithoutRequest { it.url.pathSegments.none { seg -> seg in listOf("login", "register") } }
    }
}

Keep BearerTokens at the plugin boundary; the rest of the app uses your own token type. TokenStorage is project-defined (DataStore on Android/JVM, Keychain on iOS).

WebSockets & SSE — use the serialization converter

For real-time transports, install the kotlinx-serialization converter so typed messages flow over the same Json config as ContentNegotiation; without it you hand-encode/decode Frame.Text. (SSE = server→client only, plain HTTP, built-in reconnect; WebSocket = bidirectional, manual reconnect, binary frames — default to SSE when the client only consumes.)

kotlin
val client = HttpClient(engine) {
    install(WebSockets) {
        pingIntervalMillis = 30_000
        contentConverter = KotlinxWebsocketSerializationConverter(json)  // the shared configured instance — bare `Json` reverts to encodeDefaults = false
    }
    install(SSE)
}

client.webSocket("wss://api.example.com/ws") {
    sendSerialized(SubscribeMessage(topic = "items"))
    while (true) { val msg = receiveDeserialized<ServerMessage>(); /* handle */ }
}

// SSE — incoming is a Flow<ServerSentEvent>
client.sse("https://api.example.com/events") { incoming.collect { event -> /* event.event / event.data / event.id */ } }

Wrap SSE/WebSocket collection in a LaunchedEffect or repository coroutine so cancellation closes the HTTP connection when the consumer goes away.

Error mapping + testing

Catch specific Ktor types at the repository (ClientRequestException / ServerResponseException / HttpRequestTimeoutException / IOException) and map to DataError — catch (e: Exception) would swallow CancellationException. The full repository pattern + DataError taxonomy lives in android-skills:android-data-layer. For richer per-error UI states (Unauthorized, RateLimited, Forbidden, …), a sealed ApiResult<T> + a safeRequest wrapper with expectSuccess = false is the alternative shape — pick one per project.

Inject HttpClientEngine so tests swap in MockEngine, reusing the production createHttpClient factory so plugin config matches:

kotlin
val mockEngine = MockEngine { request ->
    assertEquals("/users/42", request.url.encodedPath)
    respond("""{"id":"42","name":"Ada","created_at":1700000000000}""",
        HttpStatusCode.OK, headersOf(HttpHeaders.ContentType, "application/json"))
}
val repo = UserRepository(UserService(createHttpClient(mockEngine, baseUrl = "https://api.example.com/")))

© rcosteira79, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/android-skills/skills/kmp-ktor of rcosteira79/android-skills.

Open the folder on GitHubat commit 0f9af5a

Compare with similar skills

Kmp Ktor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Kmp Ktor compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Kmp Ktor this skillrcosteira79/android-skills153—~1.7kAutomated safety check: PassMIT
Apollo Kotlinapollographql/skills117—~547Automated safety check: PassMIT
CometChat Android v5 Headless SDKcometchat/cometchat-skills132—~4kAutomated safety check: PassMIT
Kotlin SpecialistJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Android Hidden API and R8 Checkgkd-kit/gkd43k—~1.5kAutomated safety check: PassGPL-3.0
Cherrypick Logkomikku-app/komikku4.8k—~1.9kAutomated safety check: PassApache-2.0

Similar skills

  • Apollo Kotlin

    apollographql/skills

    Guide for building applications with Apollo Kotlin, the GraphQL client library for Android and Kotlin.

    117 GitHub stars~547 tokensUpdated 2 days ago
    Backend & APIsAuto-check passed
  • CometChat Android v5 Headless SDK

    cometchat/cometchat-skills

    Builds chat on Android with your own UI against the headless CometChat Chat SDK v5, covering install, Jetifier conflicts, credentials and init-before-login ordering.

    132 GitHub stars~4k tokensUpdated 5 days ago
    MobileAuto-check passed
  • Kotlin Specialist

    Jeffallan/claude-skills

    Applies idiomatic Kotlin 1.9+ patterns for coroutines and Flow, multiplatform code, Jetpack Compose on Android and Ktor servers, checked with detekt and ktlint.

    12k GitHub stars~1.5k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • Checks whether Android hidden-API implementations and system callbacks survive R8 minification, and diagnoses Release-only failures such as AbstractMethodError.

    43k GitHub stars~1.5k tokensUpdated yesterday
    MobileAuto-check passed
  • Cherrypick Log

    komikku-app/komikku

    Update and review cherrypicklog.md, the todo list of upstream commits not yet cherry-picked into the fork's target branch.

    4.8k GitHub stars~1.9k tokensUpdated today
    Productivity & AutomationAuto-check passed
  • Compose Multiplatform Patterns

    monta-app/ocpp-emulator

    Compose Multiplatform and Jetpack Compose patterns for KMP projects — state management, navigation, theming, performance, and platform-specific UI.

    180 GitHub starsUsed in 5 repos~2k tokens
    MobileAuto-check passed

More from rcosteira79/android-skills

All 21 skills in this repo
  • Guides writing correct, performant Compose and Compose Multiplatform UI across Android, desktop, iOS and web, from state and animation to design-to-code and crash fixes.

    153 GitHub stars~2.6k tokensUpdated 21 days ago
    Auto-check passed
  • Kotlin Multiplatform Boundaries

    rcosteira79/android-skills

    Helps choose how common Kotlin Multiplatform code reaches platform APIs: expect/actual, a common interface with platform bindings, or separate platform screens.

    153 GitHub stars~1.5k tokensUpdated 21 days ago
    Auto-check passed
  • Android Data Layer and Room in KMP

    rcosteira79/android-skills

    Sets out the repository pattern's error-propagation model for Android and Kotlin Multiplatform, plus the Room setup for commonMain.

    153 GitHub stars~1.2k tokensUpdated 21 days ago
    Auto-check passed
  • Android Debugging

    rcosteira79/android-skills

    Android and KMP debugging techniques for crashes, ANRs, memory leaks, R8 traces, Gradle failures and Compose recomposition, built on finding the root cause first.

    153 GitHub stars~2.6k tokensUpdated 21 days ago
    Auto-check passed
  • Android and KMP Baseline

    rcosteira79/android-skills

    Sets house defaults for Android and Kotlin Multiplatform work and routes to the right specialized skill for Compose, networking, testing or build tooling.

    153 GitHub stars~3k tokensUpdated 21 days ago
    Auto-check passed
  • Android Gradle Build Logic

    rcosteira79/android-skills

    Sets up Android Gradle convention plugins in a build-logic composite build, including the version catalog wiring and shared configuration that are easy to get wrong.

    153 GitHub stars~959 tokensUpdated 21 days ago
    Auto-check passed

Works with

Categories

Questions about Kmp Ktor

What does Kmp Ktor do?

A skill your agent uses when setting up or working with Ktor client in KMP or Android projects — HttpClient configuration, per-platform engine selection, kotlinx.serialization, bearer auth with…. Kmp Ktor is an agent skill from rcosteira79/android-skills.serialization, bearer auth with refresh, MockEngine testing, and error mapping at the repository boundary.

When should I use Kmp Ktor?

Kmp Ktor fits situations like: working with Ktor client in KMP; android projects — HttpClient configuration; per-platform engine selection; kotlinx.serialization.

How do I install Kmp Ktor in Claude Code?

Run `npx skills add rcosteira79/android-skills --skill kmp-ktor -a claude-code`. Or copy the skill folder (plugins/android-skills/skills/kmp-ktor in rcosteira79/android-skills) into .claude/skills/kmp-ktor in your project. Claude Code loads it when a task matches its description.

How do I install Kmp Ktor in Codex?

Run `npx skills add rcosteira79/android-skills --skill kmp-ktor -a codex`. Or copy the skill folder (plugins/android-skills/skills/kmp-ktor in rcosteira79/android-skills) into .agents/skills/kmp-ktor in your project. Codex loads it when a task matches its description.

Can I use Kmp Ktor in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rcosteira79/android-skills --skill kmp-ktor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/kmp-ktor, .gemini/skills/kmp-ktor, .github/skills/kmp-ktor and .opencode/skills/kmp-ktor in your project.

What does Kmp Ktor need to run?

SKILL.md names no scripts, command-line tools or credentials: Kmp Ktor is instructions for the agent only.

Does Kmp Ktor access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Kmp Ktor safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Kmp Ktor use?

Kmp Ktor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Kmp Ktor use?

About 1.7k tokens (SKILL.md is roughly 6.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Kmp Ktor?

Skills that share tags, products or a category with Kmp Ktor: Apollo Kotlin (apollographql/skills, 117 stars), CometChat Android v5 Headless SDK (cometchat/cometchat-skills, 132 stars), Kotlin Specialist (Jeffallan/claude-skills, 12k stars) and Android Hidden API and R8 Check (gkd-kit/gkd, 43k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Kmp Ktor?

rcosteira79 (a GitHub user) maintains it in rcosteira79/android-skills, which has 153 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on September 19, 2026.

Source: rcosteira79/android-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.