Skip to main content
skill CX Codex

migrate-xml-views-to-jetpack-compose — Claude Code skill

Guides the migration of one Android XML screen to Jetpack Compose, from project review through validation and legacy XML cleanup.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add android/skills --skill migrate-xml-views-to-jetpack-compose -a claude-code
Open on GitHub

What migrate-xml-views-to-jetpack-compose does

This skill follows a 10-step path for moving an XML View to Jetpack Compose. It selects or reviews a target layout, inspects its hierarchy and project context, plans the work, then sets up Compose dependencies and theming. The layout becomes a composable with a required Compose Preview, and existing usages move to the new component.

For visual checks, it asks for a screen image or uses screenshot testing on an Android emulator. When a suitable test is missing, it can create one with UI Automator or Espresso. The Compose Preview is compared with the baseline, then a Compose UI test is written.

The skill migrates only the theme needed by the selected layout and keeps XML themes for interoperability. Remove the XML file and legacy tests only after checking for remaining references; that is a point worth verifying.

What it helps with

  • migrate one XML layout to Jetpack Compose
  • set up Compose dependencies and compiler support
  • compare the new UI with a baseline screenshot
  • replace XML layout usages with a composable
  • remove unreferenced XML resources after migration

Example prompts for the agent

  • “Migrate activity_main.xml to Jetpack Compose using this skill.”
  • “Review this XML screen and create a Compose migration plan.”
  • “Replace fragment_profile.xml with a composable and validate the visual result.”

How to install migrate-xml-views-to-jetpack-compose

1Skills CLI (Vercel)

npx skills add android/skills --skill migrate-xml-views-to-jetpack-compose -a claude-code

2Manually: put the files in place

~/.claude/skills/migrate-xml-views-to-jetpack-compose/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/migrate-xml-views-to-jetpack-compose/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about migrate-xml-views-to-jetpack-compose

How do I install migrate-xml-views-to-jetpack-compose in Claude Code?

Run npx skills add android/skills --skill migrate-xml-views-to-jetpack-compose -a claude-code. The skill file is placed at ~/.claude/skills/migrate-xml-views-to-jetpack-compose/SKILL.md.

What does migrate-xml-views-to-jetpack-compose do?

It guides the migration of one XML View to Jetpack Compose through analysis, Compose setup, layout conversion, validation, and XML cleanup.

Does the migration require a Compose Preview?

Yes. The new composable must include a Compose Preview for visual verification against the original XML screen.

Source text

SKILL.md · Apache-2.0
---
name: migrate-xml-views-to-jetpack-compose
description: Provides a structured workflow for migrating an Android XML View to Jetpack
  Compose. This skill details the step-by-step process, from planning and dependency
  setup, to theming and layout migration, validation and XML cleanup. Use this skill
  when you need to migrate an XML View to Jetpack Compose in an Android project. It
  solves the problem of converting the UI of a legacy XML View into modern, declarative
  Compose components while maintaining interoperability.
license: Complete terms in LICENSE.txt
metadata:
  author: Google LLC
  last-updated: '2026-09-18'
  keywords:
  - Jetpack Compose
  - migration
  - XML
  - Views
  - interoperability
  - incremental adoption
  - UI development
---

This skill guides through the process of migrating an existing Android XML View
to Jetpack Compose. It performs a stable, safe and visually consistent
transition by following a structured, 10-step methodology. This skill migrates
UI (XML to Jetpack Compose) only.

## Objective

To systematically convert a single legacy XML layout into modern, declarative
Jetpack Compose UI while maintaining pixel-perfect visual parity and functional
integrity.

## Summary of the 10-step migration process

1. **Identify the optimal XML candidate for migration**
2. **Analyze the project and layout**
3. **Create a plan**
4. **Capture the XML View UI**
5. **Set up Compose dependencies and compiler**
6. **Set up Compose theming**
7. **Migrate the XML layout to Compose**
8. **Validate the migration**
9. **Replace usages**
10. **XML code removal**

## Detailed steps

### Step 1: Identify the optimal XML candidate for migration

If the user has explicitly specified a target XML layout, proceed to Step 2.
Otherwise, analyze the codebase to identify the best candidate for migration by
following the logic in [references/identify-optimal-xml-candidate.md](references/identify-optimal-xml-candidate.md).

### Step 2: Analyze the project and layout

Analyze the identified XML View's structure, hierarchy, and implementation
details.
Use [references/analysis-of-the-project-and-layout.md](references/analysis-of-the-project-and-layout.md) to
guide your technical audit of the layout and surrounding project context.

### Step 3: Create a plan

Using the outputs and analysis done in the Step 1 and 2, generate a
step-by-step plan for the migration. If you support user interaction, present
to the user and ask for approval before proceeding. If user interaction is not
supported, proceed to Step 4 following the generated plan.

### Step 4: Capture the XML View UI

**IF** you support user interaction, ask the user to upload a screenshot of the
XML View UI or provide an absolute path to a file. Use this image as a visual
reference for the layout migration in Step 7.
**ELSE IF** you are able to run an Android emulator, locate an existing
screenshot test for the XML candidate. If none exists, create one using the
existing project testing framework. If no framework exists,
use **UI Automator** or **Espresso** to create a screenshot test with minimum
required setup. Run the test and take a baseline screenshot of the XML UI.
**ELSE** proceed to Step 5.

### Step 5: Set up Compose dependencies and compiler

Check `build.gradle` or `libs.versions.toml` for Compose dependencies and
compiler setup. If missing, use
[Setup Compose Dependencies and Compiler](references/android/develop/ui/compose/setup-compose-dependencies-and-compiler.md).
Run a sync to ensure dependencies resolve without errors.

### Step 6: Set up Compose theming

If the project already has Compose theming set up, proceed to Step 7. If Compose
theming is missing, initialize it. For Material-based projects, follow
[Material 3 migration guidelines](references/android/develop/ui/compose/designsystems/migrate-xml-theme-to-compose.md).
For custom design systems, apply expert judgment to migrate XML theming and
match existing styles.
**Constraints:** Do not migrate the entire theme. Implement only the minimum
theming required for the specific XML candidate. Maintain original XML themes
for interoperability. Maintain existing project code conventions, patterns,
names and values.

### Step 7: Migrate the XML View to Compose

Convert the XML candidate to Jetpack Compose code, referencing
[references/xml-layout-migration.md](references/xml-layout-migration.md) and the image from Step 4.
You must include a **Compose Preview** for the newly created composable to
facilitate visual verification.

### Step 8: Replace usages

Replace the usages of the migrated XML layout to use the new Compose component.

- To add Compose in Views, use [Compose in Views](references/android/develop/ui/compose/migrate/interoperability-apis/compose-in-views.md).
- To add Views in Compose, use [Views in Compose](references/android/develop/ui/compose/migrate/interoperability-apis/views-in-compose.md).

### Step 9: Validate the migration

Compare the baseline screenshot image from Step 4 with the rendered Compose
Preview of the new composable. Ignore string content; focus on layout and
styling. Iterate on the Compose code until visual parity is achieved. Once
verified, write a Compose UI test for the new composable.

### Step 10: XML code removal

Delete the migrated XML file and its associated legacy tests. **Caution:** Only
remove code and resources that are not referenced by other parts of the project.

© Google LLC · Apache-2.0 · android/skills

Similar skills

Everything for Mobile →

From the same set24

navigation-3 A reference skill for Jetpack Navigation 3: the move from Navigation 2 plus ready recipes for deep links, multiple back stacks, scenes, Hilt and ViewModel. CX Codex +1 3,200installs r8-analyzer Inspects Android build files and R8 keep rules for redundant or package-wide directives. Helps slim down app size during Proguard troubleshooting. CX Codex +1 3,200installs testing-setup Analyzes your Android app's testing strategy and installs libraries, infrastructure, and frameworks for unit tests, UI tests, screenshot tests, and end-to-end tests. CX Codex +1 2,500installs adaptive Guides the agent in adapting Android Compose UI for foldables, tablets, desktop, and phones. Helpful when supporting multiple screen sizes and input devices. CX Codex +1 2,400installs styles Walks an Android coding agent through moving a project onto the experimental Jetpack Compose Styles API, from Gradle opt-in to component-by-component migration. CX Codex +1 2,200installs play-billing-library-version-upgrade Walks an Android project from any legacy Google Play Billing Library version to the current stable one. It finds the Gradle dependency itself and rebuilds after every step. CX Codex +1 1,900installs android-intent-security Audits AndroidManifest.xml component settings and intent-handling code to stop Intent Redirection and unauthorized component execution. CX Codex +1 1,700installs engage-sdk-integration Takes an Android app through a Play Engage SDK integration: picks the right vertical, generates the publishing classes, then compiles until it builds. CX Codex +1 1,500installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor