New to Claude Skills? Learn how to install them →

android on GitHub

Migrate XML Views to Jetpack Compose

Free

Streamline your Android UI migration to Jetpack Compose.

by android6.7k stars on android/skills
1 views
Updated Aug 7, 2026
Get this skill

Free · Opens the source repo

What Migrate XML Views to Jetpack Compose does

The Migrate XML Views to Jetpack Compose skill provides a comprehensive, structured workflow for developers looking to transition their Android UI from legacy XML layouts to Jetpack Compose. This skill is designed to facilitate a smooth migration process while ensuring that the visual and functional integrity of the original UI is preserved. By following a systematic 10-step methodology, users can efficiently convert XML layouts into modern, declarative Compose components, which is essential for keeping up with current Android development practices.

The migration process begins with identifying the optimal XML candidate for migration, followed by a thorough analysis of the project's layout and structure. Users are guided through the creation of a detailed migration plan, ensuring that every step is accounted for. The skill emphasizes the importance of capturing the existing XML View UI, which serves as a reference point for the migration, and provides instructions for setting up the necessary Compose dependencies and theming.

Once the groundwork is laid, the actual migration of the XML layout to Compose occurs, accompanied by a Compose Preview for visual verification. This ensures that developers can validate the migration by comparing the original layout with the newly created composable. After successful validation, the skill guides users in replacing the usages of the XML layout within the project, culminating in the removal of the legacy XML code. This structured approach not only simplifies the migration process but also reduces the risk of errors and inconsistencies in the final product.

When to use it

Use this skill when you need to migrate an existing XML View to Jetpack Compose in an Android project, especially when maintaining visual fidelity is critical.

When not to use it

This skill is not suitable for projects that do not involve XML layouts or for migrating complex UI components that may require custom handling beyond the provided steps.

What you can build with it

Migrating a Simple XML Layout

A developer needs to convert a straightforward XML layout to Jetpack Compose for a new feature, using this skill to ensure a smooth transition.

Updating Legacy Codebases

A team is modernizing an older Android application and uses this skill to systematically migrate multiple XML layouts to Compose.

Ensuring UI Consistency

A designer wants to maintain visual fidelity while transitioning an XML layout to Jetpack Compose, leveraging this skill's validation steps.

How to install Migrate XML Views to Jetpack Compose

View source

1. Install with the skills CLI

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

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by android

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.

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 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. 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. 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 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.

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.

Frequently asked questions about Migrate XML Views to Jetpack Compose

Similar skills