compose-modifier-and-layout-style

Enforces Jetpack Compose conventions for modifier parameters, modifier chains, and conditional layout structure.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill compose-modifier-and-layout-style-w0lzard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: compose-modifier-and-layout-style
Source: https://github.com/w0lzard/Wolzard-s-Marketplace/tree/main/plugins/personal-skills/skills/compose-modifier-and-layout-style
Command: npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill compose-modifier-and-layout-style-w0lzard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Composable functions often hardcode layout decisions like fillMaxWidth on their root, omit the modifier parameter entirely, or build modifier chains through stepwise var reassignments, making components hard to reuse and review. This Skill provides concrete rules and before/after Kotlin examples for writing and reviewing Compose layout APIs so callers retain control over placement, sizing, and padding. ## Core Features & Use Cases - Modifier parameter conventions: Declare a modifier parameter with a Modifier default, apply it to the root layout first, and avoid hardcoding fillMaxWidth or padding that belongs to the caller. - Fluent chain construction: Replace var-based stepwise modifier reassignment with a single chained expression, including conditional segments via .then(if (c) Modifier.x() else Modifier), and format chains of three or more calls multiline. - Conditional layout hoisting: Move single if conditions outside layout wrappers when the layout carries no container semantics, with explicit carve-outs for Box with modifiers, siblings, and if/else branches. - Measure-phase constraint decoration: Use a Modifier.layout-based decorateMeasureConstraints helper so sibling composables match a measured size without composition-time coupling. - Use Case: While reviewing a pull request, you find a PrimaryButton with modifier.fillMaxWidth() hardcoded on its root and a Column whose only content is one if. Apply the rules to move layout decisions to the caller and hoist the conditional. ## Quick Start Review this Compose file and fix any modifier parameter, modifier chain, or conditional layout issues according to the compose modifier and layout style rules.

Frequently Asked Questions about compose-modifier-and-layout-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a modifier parameter to a Jetpack Compose composable?

Add modifier: Modifier = Modifier after required parameters and before content lambdas, then pass it to the root layout's modifier argument. The caller's modifier goes first in the chain, with the composable's intrinsic modifiers appended after.

How do I build a conditional modifier chain in Compose without var?

Splice the condition inline using .then(if (condition) Modifier.background(Color.Red) else Modifier) within a single chained expression. The empty Modifier acts as the identity element, so no var reassignment is needed.

Should composables hardcode fillMaxWidth on their root layout?

No, hardcoding fillMaxWidth or padding on the root removes the caller's ability to decide placement and sizing. Keep only modifiers that define the composable's identity, like clip(CircleShape) on an avatar, and let callers add layout modifiers.

When should I hoist an if condition outside a Compose layout?

Hoist the if when the layout's only content is that single conditional and the layout carries no container semantics like modifier or alignment arguments. Keep it inside when the layout has siblings, visual modifiers, or both if/else branches contribute composables.

Does this modifier style apply to Preview and test composables?

No, @Preview functions and test-only composables called from composeTestRule.setContent are exempt since the framework invokes them without callers. Composables that do not emit layout, like @ReadOnlyComposable accessors, also need no modifier parameter.

How do I match a sibling composable's height without recomposition in Compose?

Capture the size with onSizeChanged on the measured row and apply it on siblings inside a Modifier.layout block via a decorateMeasureConstraints helper. Reading the captured state in the composable body would tie siblings to composition on every measurement change.