Agent skill

Kotlin Control Flow

by chrisbanes in chrisbanes/skills

A skill your agent uses when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns…

Apache-2.0Auto-check passedMobile

Install Kotlin Control Flow

skills CLI
$ npx skills add chrisbanes/skills --skill kotlin-control-flow -a claude-code

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

GitHub CLI
$ gh skill install chrisbanes/skills kotlin-control-flow --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/chrisbanes/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/kotlin-control-flow .claude/skills/kotlin-control-flow && 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
kotlin-control-flow
GitHub stars
1.1k
Token cost
~1.2k tokens
SKILL.md length
544 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns…

  • Works in 7 steps: Name the value being classified. If… → Choose the branch shape → Use a guard only on a subject when,… → …
  • Reviewing Kotlin branching and control flow: when expressions
  • SKILL.md covers Core principle, Procedure, Recipes and Related
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Kotlin Control Flow is an agent skill from chrisbanes/skills. Use when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns, or replacing complex if/else chains.

Its SKILL.md is about 1.2k 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 Mobile, covering Android development. It works with Kotlin. The repository describes itself as: Skills for Kotlin, Jetpack Compose, and Android development. The licence is Apache-2.0.

When your agent uses it

  • Reviewing Kotlin branching and control flow: when expressions
  • Guard conditions
  • Sealed type exhaustiveness
  • Nullable branching

Example prompts

  • “/kotlin-control-flow”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Name the value being classified. If every branch tests it, use
  2. Choose the branch shape
  3. Use a guard only on a subject when, after a primary condition, when the
  4. For a closed enum, Boolean, sealed type, or nullable closed type, name every
  5. Use an early return only when it removes invalid or nullable state from the
  6. Verify smart casts still work without as, !!, mutable temporaries, or
  7. Compile and test. On failure, return to the smallest applicable earlier step

What it can do on your machine

Read from SKILL.md and the folder at commit 00bda52. 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

Kotlin Control Flow loads about 1.2k tokens when it runs. Until then it costs about 58 tokens; SKILL.md has 544 words of instructions outside code blocks.

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

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 chrisbanes/skills at commit 00bda52, republished under its Apache-2.0 licence (© chrisbanes). 544 words, ~1,165 tokens.

Download SKILL.mdSave it as .claude/skills/kotlin-control-flow/SKILL.md (or your agent's skills folder).
name
kotlin-control-flow
description
Use when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns, or replacing complex if/else chains.

Kotlin control flow

Core principle

Make the classified value obvious, keep branch-local predicates on their branch, and let the compiler prove closed-domain coverage.

Procedure

  1. Name the value being classified. If every branch tests it, use when (subject); otherwise keep a subjectless when or if chain.

  2. Choose the branch shape:

    Code shapePrefer
    One classified valuewhen (subject)
    Unrelated boolean conditionsSubjectless when or if/else
    Primary case plus a branch-local predicateGuard condition
    Invalid input before the main pathEarly return, require, or check
    Closed value-returning domainExhaustive when expression
    Open input or deliberate fallbackExplicit else
  3. Use a guard only on a subject when, after a primary condition, when the extra predicate belongs to that branch and an unguarded branch still handles the primary condition. Put the guarded branch first. Split comma-separated conditions instead of guarding one of them.

  4. For a closed enum, Boolean, sealed type, or nullable closed type, name every case and omit else. Match objects by value and class/data-class subtypes with is. When a data-bearing sealed case is collapsed by a catch-all, show the branch-level use in the review:

    kotlin
    is Outcome.Failed -> safeFailureLabel(outcome.reason)

    The is check smart-casts outcome, so the branch can use reason without a cast. The helper name is illustrative; choose a safe mapping for the caller contract. Do not replace this branch-level explanation with a note that unspecified callers can inspect the original result. If the input is an open server/platform value or needs real fallback/logging, keep else.

  5. Use an early return only when it removes invalid or nullable state from the main path. Keep nesting that expresses cleanup, transaction, or error handling.

  6. Verify smart casts still work without as, !!, mutable temporaries, or duplicate casts. If they do not, keep the original shape or take a smaller refactor.

  7. Compile and test. On failure, return to the smallest applicable earlier step or retain the prior shape. In a review of a closed sealed mapping, when a data-bearing subtype affects the mapping or its safe handling, put the typed branch and member access in the finding itself, not only in analysis or as a general note to add explicit cases. Use this pseudocode template with the actual subtype and payload member substituted:

    kotlin
    is <DataSubtype> -> map(result.<payload>)

    This is a template, not literal Kotlin: the is test smart-casts result, and the member access shows how the branch uses its payload. If the public value stays generic, state how the branch handles the detail or why it is deliberately discarded. Naming cases alone or sending callers to inspect the original value is not complete branch guidance. Apply this only to closed, data-bearing cases; retain else for open-world values or real fallbacks. Finish when the subject, fallbacks, and relevant branch data are obvious to a reader and the resulting shape is easier to scan.

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

Recipes

Use guarded branches to refine one case, rather than nesting an if:

kotlin
return when (event) {
    is Event.Message if event.isUnread -> Row.Highlighted(event.message)
    is Event.Message -> Row.Normal(event.message)
    Event.Empty -> Row.Empty
}

Use a subject when when repeated conditions classify one value, and include null as a branch when it is one case in a larger classification:

kotlin
return when (val selected = selection) {
    null -> SelectionUi.None
    is Selection.Single if selected.item.isArchived -> SelectionUi.Archived(selected.item)
    is Selection.Single -> SelectionUi.Active(selected.item)
    is Selection.Multiple -> SelectionUi.Count(selected.items.size)
}

Do not introduce guards on unsupported Kotlin versions, force unrelated boolean checks into a subject when, remove an open-world fallback, or flatten code that obscures cleanup, transactions, or errors.

© chrisbanes, Apache-2.0. 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 skills/kotlin-control-flow of chrisbanes/skills.

Open the folder on GitHubat commit 00bda52

Compare with similar skills

Kotlin Control Flow 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.

Kotlin Control Flow compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Kotlin Control Flow this skillchrisbanes/skills1.1k—~1.2kAutomated safety check: PassApache-2.0
Compose Multiplatform Patternsmonta-app/ocpp-emulator1805 repos~2kAutomated safety check: PassApache-2.0
Kotlin Patternsgetknit/knit1325 repos~4.7kAutomated safety check: PassGPL-3.0
Summoncodeyousef/summon167—~1.1kAutomated safety check: PassApache-2.0
Add JSON Schemayontrack/yontrack102—~883Automated safety check: PassMIT
Add Ktnip Parameter Strategyvendelieu/telegram-bot249—~613Automated safety check: PassApache-2.0

Similar skills

  • 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
  • Kotlin Patterns

    getknit/knit

    Idiomatic Kotlin patterns, best practices, and conventions for building robust, efficient, and maintainable Kotlin applications with coroutines, null safety, and DSL builders.

    132 GitHub starsUsed in 5 repos~4.7k tokens
    MobileAuto-check passed
  • Summon

    codeyousef/summon

    A skill your agent uses when developing applications with the Summon Kotlin Multiplatform UI framework.

    167 GitHub stars~1.1k tokensUpdated yesterday
    MobileAuto-check passed
  • Add JSON Schema

    yontrack/yontrack

    Add a new downloadable JSON schema to the Resources page — Kotlin provider class only, auto-discovered by Spring.

    102 GitHub stars~883 tokensUpdated today
    MobileAuto-check passed
  • Add Ktnip Parameter Strategy

    vendelieu/telegram-bot

    Adds a new parameter resolution strategy to the ktnip KSP processor.

    249 GitHub stars~613 tokensUpdated 5 days ago
    MobileAuto-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.

    131 GitHub stars~4k tokensUpdated 4 days ago
    MobileAuto-check passed

More from chrisbanes/skills

All 19 skills in this repo
  • Gradle Run

    chrisbanes/skills

    A skill your agent uses when planning to execute Gradle through gradle, ./gradlew, or a custom gradlew wrapper script, or diagnosing a Gradle build, compact workflow ledger, repeated failure…

    1.1k GitHub stars~1.2k tokensUpdated yesterday
    Auto-check passed
  • Compose Animations

    chrisbanes/skills

    A skill your agent uses when writing or reviewing Jetpack Compose motion: visibility enter/exit, animating one property toward a target, color or size transitions, multiple properties from one…

    1.1k GitHub stars~1.1k tokensUpdated yesterday
    Auto-check passed
  • A skill your agent uses when writing or reviewing Jetpack Compose UI tests, screenshot tests or baseline-recording evidence, previews, semantics assertions, fake image loading, keyboard input, focus…

    1.1k GitHub stars~1.8k tokensUpdated yesterday
    Auto-check passed
  • Release Kotlin Library

    chrisbanes/skills

    A skill your agent uses when preparing, publishing, or checking readiness for a Kotlin library release, including verifying its gradle-maven-publish-plugin prerequisite, reconciling changelogs and…

    1.1k GitHub stars~1.9k tokensUpdated yesterday
    Auto-check: notes
  • Run GitHub Project

    chrisbanes/skills

    A skill your agent uses when asked to set up, review, or operate a repository's GitHub Project workflow, including ready claims, role-labelled human work, unknown remote mutation outcomes, Todo…

    1.1k GitHub stars~1.5k tokensUpdated yesterday
    Auto-check passed
  • Compose Component Design

    chrisbanes/skills

    A skill your agent uses when designing or reviewing reusable Jetpack Compose component APIs with modifier parameters, root layout placement, caller-provided variable content, primitive content…

    1.1k GitHub starsUsed in 1 repo~718 tokens
    Auto-check passed

Works with

Categories

Questions about Kotlin Control Flow

What does Kotlin Control Flow do?

A skill your agent uses when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns…. Kotlin Control Flow is an agent skill from chrisbanes/skills. Use when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns, or replacing complex if/else chains.

When should I use Kotlin Control Flow?

Kotlin Control Flow fits situations like: reviewing Kotlin branching and control flow: when expressions; guard conditions; sealed type exhaustiveness; nullable branching.

How do I install Kotlin Control Flow in Claude Code?

Run `npx skills add chrisbanes/skills --skill kotlin-control-flow -a claude-code`. Or copy the skill folder (skills/kotlin-control-flow in chrisbanes/skills) into .claude/skills/kotlin-control-flow in your project. Claude Code loads it when a task matches its description.

How do I install Kotlin Control Flow in Codex?

Run `npx skills add chrisbanes/skills --skill kotlin-control-flow -a codex`. Or copy the skill folder (skills/kotlin-control-flow in chrisbanes/skills) into .agents/skills/kotlin-control-flow in your project. Codex loads it when a task matches its description.

Can I use Kotlin Control Flow 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 chrisbanes/skills --skill kotlin-control-flow -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/kotlin-control-flow, .gemini/skills/kotlin-control-flow, .github/skills/kotlin-control-flow and .opencode/skills/kotlin-control-flow in your project.

What does Kotlin Control Flow need to run?

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

Does Kotlin Control Flow 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 Kotlin Control Flow 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 Kotlin Control Flow use?

Kotlin Control Flow is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Kotlin Control Flow use?

About 1.2k tokens (SKILL.md is roughly 4.7k 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 Kotlin Control Flow?

Skills that share tags, products or a category with Kotlin Control Flow: Compose Multiplatform Patterns (monta-app/ocpp-emulator, 180 stars), Kotlin Patterns (getknit/knit, 132 stars), Summon (codeyousef/summon, 167 stars) and Add JSON Schema (yontrack/yontrack, 102 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Kotlin Control Flow?

chrisbanes (a GitHub user) maintains it in chrisbanes/skills, which has 1,093 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 8, 2026.

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