avoiding-subcomposition-pitfalls

avoiding-subcomposition-pitfalls is a skill for Claude Code, Codex from skydoves/compose-performance-skills. It costs 175 tokens per session (4,256 once invoked), scanned A, original, Apache-2.0.

A guide to avoiding subcomposition in Jetpack Compose, where content is composed during layout measurement instead of the usual composition step.

In plain words
What is it for?
Use it to review SubcomposeLayout, BoxWithConstraints, Scaffold, and lazy-list usage, replace unnecessary wrappers, and keep required subcomposition efficient.
Why use it?
It helps reduce extra measurement and composition work that can slow the first frame, configuration changes, or scrolling, especially when these layouts are nested.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/skydoves/compose-performance-skills/avoiding-subcomposition-pitfalls
Any agent
npx skills add skydoves/compose-performance-skills --skill avoiding-subcomposition-pitfalls
Clone the repo
git clone --depth 1 https://github.com/skydoves/compose-performance-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for avoiding-subcomposition-pitfalls

README.md
[![agentmods](https://agentmods.dev/badge/skills/skydoves/compose-performance-skills/avoiding-subcomposition-pitfalls.svg)](https://agentmods.dev/skills/skydoves/compose-performance-skills/avoiding-subcomposition-pitfalls)
Your own site
<a href="https://agentmods.dev/skills/skydoves/compose-performance-skills/avoiding-subcomposition-pitfalls"><img src="https://agentmods.dev/badge/skills/skydoves/compose-performance-skills/avoiding-subcomposition-pitfalls.svg" alt="Measured on agentmods" height="20"></a>
Per session 175 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,256 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00175 $0.04256
Opus 5 $0.00088 $0.02128
Sonnet 5 $0.00035 $0.00851
Haiku 4.5 $0.00017 $0.00426

Measured 4d ago against content hash a71122f23983, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

avoiding-subcomposition-pitfalls scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

recomposition/avoiding-subcomposition-pitfalls/SKILL.md · 285 lines

How it starts

The opening of the file, as written. The whole thing — 285 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Avoiding Subcomposition Pitfalls — Keep Composition Out of the Measure Pass

SubcomposeLayout runs its content's composition during the measure pass, not during the parent's composition pass. That trades extra layout cost for the ability to use measured constraints inside the children's composition. BoxWithConstraints, material3.Scaffold, and the lazy layouts are all built on top of it, so the cost is invisible until it nests or lands inside a hot path. This skill teaches Claude how to detect the misuse, how to replace SubcomposeLayout with a cheaper primitive when its power is not needed, and how to keep it efficient when it is.

When to use this skill

  • The developer wraps content in BoxWithConstraints purely to read maxWidth / maxHeight and pick between a few composables, and the screen feels heavy at first frame or on configuration change (rotation, IME show).
  • A BoxWithConstraints or Scaffold is nested inside another BoxWithConstraints or Scaffold, multiplying subcomposition cost.
  • A BoxWithConstraints sits inside a LazyColumn/LazyRow item and the developer reports scroll jank that did not exist before the wrap was added.
  • The developer manually authors a SubcomposeLayout block but only uses constraints to compute final positions, never to drive child composition.
  • The Layout Inspector or a Perfetto trace shows Compose:applyChanges or measure-phase composition counts that scale with parent constraint changes (rotation, drag-to-resize, animated container size).
  • A custom SubcomposeLayout's measurePolicy block allocates a fresh composable lambda inside subcompose(slotId) { … } on every measurement. AndroidX maintains an internal lint check named ComposableLambdaInMeasurePolicy (in compose/lint/internal-lint-checks/) that flags exactly this pattern on its own codebase; published APIs like BoxWithConstraints, material.Scaffold, and material3.TabRow suppress that check because the trade-off is fundamental to their public contract. App-side code that reproduces the pattern pays the same cost without the suppression rationale.

Read the full file on GitHub · 285 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 285 lines · 175 tokens per session scan A a71122f23983

Subscribe to this mod's changes

avoiding-subcomposition-pitfalls is a skill published in the GitHub repository skydoves/compose-performance-skills (496 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 175 tokens to every session and 4,256 once invoked, about $0.0009 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

claude-android-ninja

Build and migrate Android apps with Kotlin, Jetpack Compose, MVVM, Hilt, Room 3 (KSP, SQLiteDriver, Flow/suspend DAOs), Navigation3, and multi-module Gradle. Use for new projects or modules, Compose screens and ViewModels, Room 3 and RemoteMediator, API 37 / targetSdk migration, Play Integrity client wiring…

Drjacky/claude-android-ninja · 123 tokens

rebrand

Rebrand a fresh clone of android-clean-template into a new app. Asks for the app name, application id, sample-feature and networking decisions, then executes docs/CLONECHECKLIST.md end to end. Use on a fresh un-rebranded clone (application id still com.mkchtv.cleantemplate) or when the user asks to set up, rename, or…

mykola-kichatov/android-clean-template · 85 tokens

sceneview

Build 3D and AR apps with the SceneView SDK in Jetpack Compose, SwiftUI (iOS/macOS/visionOS via SceneViewSwift), Web (Filament.js), Flutter and React Native. Use whenever the user asks for "3D in Compose", "AR with ARCore in Compose", a model viewer, or any cross-platform 3D/AR app where the dependency is…

sceneview/sceneview · 156 tokens

sceneview-ios

Build 3D and AR apps on Apple platforms (iOS, macOS, visionOS) with SceneViewSwift — the SwiftUI wrapper around RealityKit. Use whenever the user asks for "3D in SwiftUI", "AR with ARKit in SwiftUI", a model viewer for iOS, or any Apple-platform 3D/AR app where the dependency is the SceneViewSwift Swift Package from…

sceneview/sceneview · 148 tokens

kotlin-control-flow

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.

chrisbanes/skills · 44 tokens

roborazzi

Use when working with Roborazzi screenshot tests on Android/JVM — setting up the Roborazzi Gradle plugin, running record/compare/verify tasks, writing tests with captureRoboImage or RoborazziRule, Compose Preview screenshot testing (ComposablePreviewScanner), Compose Multiplatform (iOS/desktop) screenshots, AI-powered…

takahirom/roborazzi · 95 tokens