Skip to content
Skillv1.0.0

android-compose-state-effects

Manage Compose state, remember APIs, side effects, snapshots, and lifecycle-aware collection without leaks or loops.

by krutikjain(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from krutikjain/android-agent-skills (skills/android-compose-state-effects/SKILL.md). Install upstream with npx skills add krutikjain/android-agent-skills --skill android-compose-state-effects. Copyright stays with the author.

Android Compose State Effects

When To Use

  • Use this skill when the request is about: compose side effect problem, remember vs derivedstateof, collect flow in compose screen.
  • Primary outcome: Manage Compose state, remember APIs, side effects, snapshots, and lifecycle-aware collection without leaks or loops.
  • Reach for this skill when the problem lives inside a composable or Compose runtime primitive, not when redesigning app-wide state holders or reducers.
  • This skill is about runtime primitives inside Compose. If the question is reducer design, screen contracts, or ViewModel ownership, hand off to android-state-management.
  • Handoff skills when the scope expands:
  • android-state-management
  • android-compose-performance

Workflow

  1. Classify the issue first: local remembered state, saved state, derived state, lifecycle-aware collection, or one-off side effects.
  2. Pick the narrowest Compose primitive that matches that problem: remember, rememberSaveable, derivedStateOf, produceState, collectAsStateWithLifecycle, LaunchedEffect, DisposableEffect, SideEffect, or snapshotFlow.
  3. Keep durable UI state separate from transient events such as snackbars, navigation, and analytics.
  4. Stabilize effect keys and callback references so recomposition does not relaunch work or capture stale lambdas.
  5. Hand off broader state-holder design to android-state-management only after the Compose-runtime issue is isolated.

Guardrails

  • Prefer lifecycle-aware collection such as collectAsStateWithLifecycle for UI-facing flows.
  • Use rememberUpdatedState when an effect should see the latest lambda or value without restarting.
  • Keep one-shot effects out of immutable screen state when they are really events.
  • Do not launch coroutines or trigger navigation directly from the composable body outside the appropriate effect APIs.

Anti-Patterns

  • Using LaunchedEffect(Unit) or unstable keys when the effect should restart on real dependency changes.
  • Collecting flows in multiple places and wondering why events duplicate.
  • Storing transient events as persistent booleans in screen state and then manually resetting them.
  • Using derivedStateOf or snapshotFlow when plain state reads would be simpler and cheaper.

Review Focus

  • Which runtime primitive owns this behavior?
  • Are recomposition and effect restarts intentional?
  • Are state and event channels modeled separately?
  • Is collection lifecycle-aware and cancellation-safe?

Examples

Happy path

  • Scenario: Collect task state and snackbar events in Compose without duplicate launches.
  • Command: cd examples/orbittasks-compose && ./gradlew :app:testDebugUnitTest

Edge case

  • Scenario: Handle recomposition when permission state and sync state change together.
  • Command: cd examples/orbittasks-compose && ./gradlew :app:assembleDebug

Failure recovery

  • Scenario: Disambiguate state/effects work from generic Compose layout or state-management requests.
  • Command: python3 scripts/eval_triggers.py --skill android-compose-state-effects

Done Checklist

  • The chosen Compose primitive matches the actual runtime problem.
  • Effects have stable keys and do not duplicate on recomposition.
  • State and events are separated clearly.
  • Broader app-state architecture work is handed off instead of mixed into the composable fix.

Official References

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/krutikjain-android-agent-skills-android-compose-state-effects/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

krutikjain-android-agent-skills-android-compose-state-effects.ocm.jsonjson
{
  "ocm": "1",
  "id": "krutikjain-android-agent-skills-android-compose-state-effects",
  "kind": "skill",
  "name": "android-compose-state-effects",
  "description": "Manage Compose state, remember APIs, side effects, snapshots, and lifecycle-aware collection without leaks or loops.",
  "publisher": "krutikjain",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "android",
      "compose",
      "state",
      "side-effects",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Manage Compose state, remember APIs, side effects, snapshots, and lifecycle-aware collection without leaks or loops."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/krutikjain/android-agent-skills",
      "path": "skills/android-compose-state-effects/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/krutikjain/android-agent-skills/blob/HEAD/skills/android-compose-state-effects/SKILL.md",
      "key": "krutikjain/android-agent-skills/skills/android-compose-state-effects/SKILL.md"
    }
  },
  "instructions": "# Android Compose State Effects\n\n## When To Use\n- Use this skill when the request is about: compose side effect problem, remember vs derivedstateof, collect flow in compose screen.\n- Primary outcome: Manage Compose state, remember APIs, side effects, snapshots, and lifecycle-aware collection without leaks or loops.\n- Reach for this skill when the problem lives inside a composable or Compose runtime primitive, not when redesigning app-wide state holders or reducers.\n- This skill is about runtime primitives inside Compose. If the question is reducer design, screen contracts, or ViewModel ownersh",
  "cost": {
    "context_tokens": 994
  }
}

Fetch it by URL: GET /api/v1/registry/krutikjain-android-agent-skills-android-compose-state-effects/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.