migrating-to-modifier-node

Migrates Jetpack Compose modifiers from Modifier.composed to persistent Modifier.Node implementations.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill migrating-to-modifier-node-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: migrating-to-modifier-node
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/migrating-to-modifier-node
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill migrating-to-modifier-node-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Legacy Modifier.composed { } factories allocate a fresh composable scope per recomposition, cannot be skipped, and force parent composables to recompose on every frame. This Skill guides authoring new custom modifiers and migrating legacy ones to the persistent Modifier.Node + ModifierNodeElement<T> architecture, eliminating per-recomposition allocation and parent invalidation chains. ## Core Features & Use Cases - Migration workflow: An 8-step checklist covering discovery of Modifier.composed usages, Element/Node scaffolding, interface selection, lifecycle hooks, and verification. - Specialized node interfaces: Guidance for DrawModifierNode, LayoutModifierNode, SemanticsModifierNode, PointerInputModifierNode, CompositionLocalConsumerModifierNode, LayoutAwareModifierNode, GlobalPositionAwareModifierNode, ObserverModifierNode, DelegatingNode, and TraversableNode. - Wrong/right code patterns: Concrete Kotlin examples for draw, coroutine animation, CompositionLocal reads, the data-class diffing requirement, and DelegatingNode composition. - Use Case: A code review flags Modifier.composed { drawBehind { ... } } in a hot list item. Use this Skill to rewrite it as a data class Element plus a DrawModifierNode, then verify the parent composable becomes skippable in the compiler report. ## Quick Start Ask the AI to migrate every Modifier.composed factory in this module to Modifier.Node and verify no composed usages remain.

Frequently Asked Questions about migrating-to-modifier-node

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

FAQPage Schema
How do I migrate Modifier.composed to Modifier.Node in Jetpack Compose?▼

Create three pieces: a public extension function, a data class ModifierNodeElement implementing create() and update(), and a Modifier.Node subclass implementing the specialized interfaces your modifier needs. Move side effects into onAttach/onDetach and use the node's built-in coroutineScope.

Why must ModifierNodeElement be a data class?▼

Compose uses the Element's equals() to decide whether to call update() or leave the node alone. A plain class falls back to referential equality, so every apply looks like a new modifier and update() is never called, leaving the node with stale parameters.

Which Modifier.Node interface should I use for custom drawing?▼

Use DrawModifierNode and implement ContentDrawScope.draw(), calling drawContent() to render the wrapped content. It replaces drawBehind and drawWithCache for custom modifiers, and pairs with CompositionLocalConsumerModifierNode for theme-aware drawing.

Can a Modifier.Node launch coroutines for animations?▼

Yes, every Modifier.Node exposes a built-in coroutineScope tied to its attach/detach lifecycle. Launch animations from onAttach() and never create your own CoroutineScope, which would leak past onDetach since the built-in one is cancelled automatically.

When should I not migrate a modifier to Modifier.Node?▼

Skip migration when the modifier is a one-line composable wrapper, when built-in modifier composition already suffices, or when the real issue is a wrong-phase state read. Modifier.Node targets custom node behavior, not chain reordering.

How do I verify a Modifier.Node migration improved performance?▼

Grep the module to confirm zero Modifier.composed usages remain, check the compiler report shows consuming composables as restartable and skippable, and confirm in Layout Inspector that recomposition counts plateau during modifier-driven animations on a release build.