@singhsume123/xml-to-compose
AConvert Android XML layouts to Jetpack Compose. Use when asked to migrate XML layouts, convert views to composables, or help with Compose migration. Handles layouts, widgets, attributes, styles, and resource references.
Install
agr install @singhsume123/xml-to-compose --target claudeWrites 4 files into .claude/skills/, pinned to git-91a2293e.
- .claude/skills/xml-to-compose/LICENSE
- .claude/skills/xml-to-compose/README.md
- .claude/skills/xml-to-compose/SKILL.md
- .claude/skills/xml-to-compose/marketplace.json
Document
name: xml-to-compose description: Convert Android XML layouts to Jetpack Compose. Use when asked to migrate XML layouts, convert views to composables, or help with Compose migration. Handles layouts, widgets, attributes, styles, and resource references.
XML to Jetpack Compose Converter
Convert Android XML layouts to idiomatic Jetpack Compose code.
Conversion Process
- Analyze the XML structure and identify root layout
- Map each view to its Compose equivalent
- Convert attributes to Modifier chains (order matters!)
- Handle resource references (@string, @dimen, @color)
- Extract styles into reusable composables or theme values
Quick Reference
Layouts
| XML | Compose |
|---|---|
LinearLayout (vertical) | Column |
LinearLayout (horizontal) | Row |
FrameLayout | Box |
ConstraintLayout | Column/Row or ConstraintLayout (dependency) |
ScrollView | Column + Modifier.verticalScroll() |
RecyclerView | LazyColumn / LazyRow |
ViewPager2 | HorizontalPager |
Common Widgets
| XML | Compose |
|---|---|
TextView | Text |
EditText | TextField / OutlinedTextField |
Button | Button |
ImageView | Image / AsyncImage (Coil) |
CheckBox | Checkbox |
Switch | Switch |
ProgressBar | CircularProgressIndicator / LinearProgressIndicator |
CardView | Card |
Modifier Order
Order matters! Follow this sequence:
clickable/toggleablepadding(outer)size/fillMaxWidth/weightbackground/clipborderpadding(inner)
Detailed Mappings
See reference files for complete mappings:
references/layouts.md— Layout containersreferences/widgets.md— UI componentsreferences/attributes.md— XML attributes to Modifiers
Output Guidelines
- Use Material 3 — Import from
androidx.compose.material3 - Prefer built-in modifiers — Avoid custom implementations
- Handle nullability — XML allows null text, Compose needs defaults
- Extract dimensions — Use
dimensionResource()or define in theme - Keep composables stateless — Hoist state to caller
- Add Preview — Include
@Previewfunction for each composable
Example
Input:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/welcome"
android:textSize="24sp"
android:textStyle="bold"/>
<Button
android:id="@+id/action_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/get_started"/>
</LinearLayout>
Output:
@Composable
fun WelcomeSection(
onGetStartedClick: () -> Unit,
modifier: Modifier = Modifier
) {
Column(
modifier = modifier
.fillMaxWidth()
.padding(16.dp)
) {
Text(
text = stringResource(R.string.welcome),
fontSize = 24.sp,
fontWeight = FontWeight.Bold
)
Spacer(modifier = Modifier.height(8.dp))
Button(
onClick = onGetStartedClick,
modifier = Modifier.fillMaxWidth()
) {
Text(text = stringResource(R.string.get_started))
}
}
}
@Preview(showBackground = true)
@Composable
private fun WelcomeSectionPreview() {
WelcomeSection(onGetStartedClick = {})
}
Key conversions:
match_parent→fillMaxWidth()/fillMaxHeight()wrap_content→ default (no modifier needed)layout_marginTop→Spacerbetween elements- Click listeners → lambda parameters
- IDs → not needed (state hoisting instead)
Trustgrade A
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- passLicense
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-91a2293ec0662026-07-31