Agent skill

Ha Android Concurrency

by home-assistant in home-assistant/android

Home Assistant Android coroutine and threading guidance. An agent skill from home-assistant/android.

Apache-2.0Auto-check passedDevelopment

Install Ha Android Concurrency

skills CLI
$ npx skills add home-assistant/android --skill ha-android-concurrency -a claude-code

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

GitHub CLI
$ gh skill install home-assistant/android ha-android-concurrency --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/home-assistant/android.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/ha-android-concurrency .claude/skills/ha-android-concurrency && 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
ha-android-concurrency
GitHub stars
4k
Token cost
~1k tokens
SKILL.md length
487 words
Files
1
Skills in repo
10
Repo updated
First seen
Licence
Apache-2.0

At a glance

Home Assistant Android coroutine and threading guidance. An agent skill from home-assistant/android.

  • Launching coroutines
  • SKILL.md covers Scopes and Lifecycle, Never Block a Thread, Dispatchers and Mutex and Double-Checked Locking, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Choosing dispatchers

What it does

Ha Android Concurrency is an agent skill from home-assistant/android. Home Assistant Android coroutine and threading guidance. Use when launching coroutines, choosing dispatchers, sharing mutable state across threads, exposing Flows, or reviewing for blocking calls and race conditions.

Its SKILL.md is about 1k 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 Development, covering Async programming. It works with Android, Home Assistant and Kotlin. The repository describes itself as: Home Assistant Companion for Android. The licence is Apache-2.0.

When your agent uses it

  • Launching coroutines
  • Choosing dispatchers
  • Sharing mutable state across threads
  • Reviewing for blocking calls and race conditions

Example prompts

  • “/ha-android-concurrency”

What it can do on your machine

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

Ha Android Concurrency loads about 1k tokens when it runs. Until then it costs about 60 tokens; SKILL.md has 487 words of instructions outside code blocks.

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

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 home-assistant/android at commit 9e658ce, republished under its Apache-2.0 licence (© home-assistant). 487 words, ~1,041 tokens.

Download SKILL.mdSave it as .claude/skills/ha-android-concurrency/SKILL.md (or your agent's skills folder).
name
ha-android-concurrency
description
Home Assistant Android coroutine and threading guidance. Use when launching coroutines, choosing dispatchers, sharing mutable state across threads, exposing Flows, or reviewing for blocking calls and race conditions.

HA Android Concurrency

Use this skill when writing or reviewing anything asynchronous: coroutines, Flows, dispatchers, or shared mutable state.

All concurrency uses Kotlin Coroutines and Flow exclusively.

Scopes and Lifecycle

  • Tie every new coroutine scope to an Android lifecycle (viewModelScope, lifecycleScope) to prevent leaks.
  • Don't create a CoroutineScope per object: the lifecycle owner (service, screen) owns the scope and passes it (or the caller's coroutineScope { }) to the objects it manages. Creating one scope per session/item multiplies leaks and cancellation bugs.
  • A child object must never cancel a scope it doesn't own — cancelling a shared scope kills unrelated siblings. If a class needs its own scope, build it internally and document the required release()/close() call.
  • Never catch kotlin.coroutines.cancellation.CancellationException — let it propagate so coroutines cancel properly.

Never Block a Thread

  • Never use runBlocking.
  • Prefer suspension over blocking everywhere. synchronized blocks are forbidden; use Mutex or another non-blocking mechanism for concurrent access.
  • Race conditions are hard to debug — design concurrent access carefully upfront and make shared references thread-safe or don't share them.

Dispatchers

  • Run heavy work on a dedicated dispatcher: Default for CPU-bound work, IO for blocking network or storage calls. Don't reflexively add withContext(Dispatchers.IO) around calls that are already main-safe (repository suspend functions usually are).
  • Only use Main for system APIs that require the main thread, and keep the work inside it to the strict minimum: precompute on Default, then withContext(Dispatchers.Main) for just the UI/system call. Don't run a whole function on Main because one line needs it.
  • Make functions main-safe whenever possible; when a function must run on a specific thread, annotate it (@MainThread) or document it, and keep the docs accurate when call sites change.
  • Confine mutable state (like a session map in a service) to one thread instead of sprinkling synchronization — reads and writes from mixed dispatchers on a plain map is a recurring review finding.
Show full SKILL.md (180 more words)Show less

Mutex and Double-Checked Locking

Use kotlinx.coroutines.sync.Mutex (never synchronized) to serialize access to shared mutable state. When a value must be initialized exactly once but reads should stay cheap after that, combine a @Volatile field with double-checked locking: read the volatile field first without locking, and only take the mutex when it's still unset.

@Volatile makes a write by one coroutine/thread immediately visible to others, so the fast path outside the lock never reads a stale or half-published value; the mutex guarantees the initializer runs once even under a concurrent race.

kotlin
private val mutex = Mutex()

@Volatile private var value: T? = null

suspend fun get(): T {
    value?.let { return it }          // fast path, no lock
    return mutex.withLock {
        value?.let { return it }      // re-check: another coroutine may have set it while we waited
        initializer().also { value = it }
    }
}

The project already provides this as SuspendLazy in :common (common/src/main/kotlin/io/homeassistant/companion/android/common/util/SuspendLazy.kt) — reuse it for lazy single initialization instead of re-implementing the pattern. Write the pattern by hand only when the caller isn't suspend or the state is reset/invalidated over time. Both re-checks inside the lock are required: dropping the second one reintroduces the race the pattern exists to close.

Testing Concurrency

  • Test concurrent behavior with unit tests under runTest using a TestDispatcher to control virtual time.
  • For the Main-dispatcher swap helpers, TestDispatcher choice, and Turbine Flow rules, see the ha-android-testing skill.

© home-assistant, 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 .agents/skills/ha-android-concurrency of home-assistant/android.

Open the folder on GitHubat commit 9e658ce

Compare with similar skills

Ha Android Concurrency 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.

Ha Android Concurrency compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ha Android Concurrency this skillhome-assistant/android4k—~1kAutomated safety check: PassApache-2.0
Kotlin SpecialistJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Kotlin Concurrency ExpertMoustachauve/WLED-Android1693 repos~1.4kAutomated safety check: PassApache-2.0
Task Workflowikarenkov/Modo343—~2.4kAutomated safety check: PassNone
Release Changelogsk2andy/candy-browser532—~593Automated safety check: PassMPL-2.0
Cameraxarindamxd/camerax-android1322 repos~1.6kAutomated safety check: PassApache-2.0

Similar skills

  • 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 6 days ago
    DevelopmentAuto-check passed
  • Kotlin Concurrency Expert

    Moustachauve/WLED-Android

    Kotlin Coroutines review and remediation for Android. An agent skill from Moustachauve/WLED-Android.

    169 GitHub starsUsed in 3 repos~1.4k tokens
    MobileAuto-check passed
  • Task Workflow

    ikarenkov/Modo

    Spec-driven workflow for non-trivial work. An agent skill from ikarenkov/Modo.

    343 GitHub stars~2.4k tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • Release Changelog

    sk2andy/candy-browser

    Create or update Candy Browser's English, image-rich, versioned release notes for the in-app What's New presentation and the matching GitHub release.

    532 GitHub stars~593 tokensUpdated today
    DevelopmentAuto-check passed
  • Camerax

    arindamxd/camerax-android

    Provide technical guidance for Android camera development with CameraX.

    132 GitHub starsUsed in 2 repos~1.6k tokens
    DevelopmentAuto-check passed
  • Composewebview Code Review

    parkwoocheol/compose-webview

    Performs code quality checks and reviews for ComposeWebView.

    103 GitHub stars~2k tokensUpdated 1 mo ago
    DevelopmentAuto-check passed

More from home-assistant/android

All 10 skills in this repo
  • Ha Android Architecture

    home-assistant/android

    Home Assistant Android module and layer architecture. An agent skill from home-assistant/android.

    4k GitHub stars~1.7k tokensUpdated today
    Auto-check passed
  • Ha Android E2E Debugging

    home-assistant/android

    Home Assistant Android end-to-end (Maestro) failure triage. An agent skill from home-assistant/android.

    4k GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Ha Android Kotlin Style

    home-assistant/android

    Home Assistant Android Kotlin style. An agent skill from home-assistant/android.

    4k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Ha Android Logging Errors

    home-assistant/android

    Home Assistant Android logging and error handling. An agent skill from home-assistant/android.

    4k GitHub stars~845 tokensUpdated today
    Auto-check passed
  • Ha Android Testing

    home-assistant/android

    Home Assistant Android testing guidance. An agent skill from home-assistant/android.

    4k GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Ha Android UI

    home-assistant/android

    Home Assistant Android UI guidance. An agent skill from home-assistant/android.

    4k GitHub stars~1.5k tokensUpdated today
    Auto-check passed

Categories

Questions about Ha Android Concurrency

What does Ha Android Concurrency do?

Home Assistant Android coroutine and threading guidance. An agent skill from home-assistant/android. Ha Android Concurrency is an agent skill from home-assistant/android. Home Assistant Android coroutine and threading guidance.

When should I use Ha Android Concurrency?

Ha Android Concurrency fits situations like: launching coroutines; choosing dispatchers; sharing mutable state across threads; reviewing for blocking calls and race conditions.

How do I install Ha Android Concurrency in Claude Code?

Run `npx skills add home-assistant/android --skill ha-android-concurrency -a claude-code`. Or copy the skill folder (.agents/skills/ha-android-concurrency in home-assistant/android) into .claude/skills/ha-android-concurrency in your project. Claude Code loads it when a task matches its description.

How do I install Ha Android Concurrency in Codex?

Run `npx skills add home-assistant/android --skill ha-android-concurrency -a codex`. Or copy the skill folder (.agents/skills/ha-android-concurrency in home-assistant/android) into .agents/skills/ha-android-concurrency in your project. Codex loads it when a task matches its description.

Can I use Ha Android Concurrency 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 home-assistant/android --skill ha-android-concurrency -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ha-android-concurrency, .gemini/skills/ha-android-concurrency, .github/skills/ha-android-concurrency and .opencode/skills/ha-android-concurrency in your project.

What does Ha Android Concurrency need to run?

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

Does Ha Android Concurrency 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 Ha Android Concurrency 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 Ha Android Concurrency use?

Ha Android Concurrency 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 Ha Android Concurrency use?

About 1k tokens (SKILL.md is roughly 4.2k 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 Ha Android Concurrency?

Skills that share tags, products or a category with Ha Android Concurrency: Kotlin Specialist (Jeffallan/claude-skills, 12k stars), Kotlin Concurrency Expert (Moustachauve/WLED-Android, 169 stars), Task Workflow (ikarenkov/Modo, 343 stars) and Release Changelog (sk2andy/candy-browser, 532 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ha Android Concurrency?

home-assistant (a GitHub organization) maintains it in home-assistant/android, which has 3,954 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on October 10, 2026.

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