Community编程与开发github.com

react-native-brownfield-migration(褐地迁移)

使用@callstack/react-native-brownfield实现从原生iOS或Android到React Native或Expo的渐进式褐地迁移。在已选择褐地路径后,用于设置集成、打包XCFramework或AAR产物,或在宿主应用中添加React Native界面时使用。

react-native-brownfield-migration(褐地迁移) 是什么?

该技能为技术人员提供了一套完整的工作流,用于在现有原生iOS或Android应用中渐进式地采用React Native,基于`@callstack/react-native-brownfield`库。它覆盖了从初始设置、打包XCFramework(iOS)或AAR(Android)产物,到将React Native界面集成到宿主应用的全过程,并支持Expo和纯React Native两种路径。技能强调路径选择首先执行,并遵循一系列全局安全准则(如每次只选一条路径、优先使用配置文件而非重复命令行标志、通过`agent-device`进行运行时验证等)。同时,它提供了详细的问题-技能映射表和快速参考文件列表,帮助开发者快速定位到具体的参考文档(如CLI配置、运行时API、不同平台的集成指南),从而实现高效、可控的增量迁移。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/callstackincubator/agent-skills/tree/main/skills/react-native-brownfield-migration

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

迁移到 React Native

仅当已决定采用褐地迁移后,才可使用此技能。如果用户仍在褐地、绿野、基于检查点路径、推迟或不迁移之间做选择,请先使用assess-react-native-migration。

概述

使用@callstack/react-native-brownfield在现有原生应用中渐进式采用React Native的规范性工作流,从初始设置到分阶段宿主集成。

  • Expo 轨道
  • 纯 React Native 轨道

除非用户明确要求迁移或比较,否则每个任务使用一个轨道。

迁移策略

将此策略用于褐地迁移规划与执行:

  1. 评估应用状态,选择 Expo 或纯路径。
  2. 使用 @callstack/react-native-brownfield 执行初始设置。
  3. 从 RN 源应用打包 RN 产物(XCFramework/AAR)。
  4. 将一个 RN 界面集成至宿主应用,并验证启动/运行时。
  5. 按功能/屏幕重复集成以进行增量发布。

智能体护栏(全局)

在所有参考文件中应用以下规则:

  1. 首先选择一条路径(Expo 或纯路径),不要混合步骤。
  2. 使用文档中的占位符(<framework_target_name>、<android_module_name>、<registered_module_name>),并从项目文件中解析。
  3. 在移至宿主集成之前,验证每个打包命令。
  4. 在依赖任何参考文件中的标志表之前,运行 npx brownfield <command> --help;帮助输出优先。
  5. 将稳定的项目设置一次性写入 brownfield.config.* 中,而不是重复使用标志——参见 cli-and-config.md。
  6. 对于长平台代码片段和 CLI 选项详情,优先参考官方文档。
  7. 尽可能保持宿主应用不直接接触 React Native API(外观模式)。
  8. 对于启动/运行时验证,使用 agent-device 打开宿主应用,导航至 RN 界面,捕获截图/屏幕快照,并收集设备证据。如果缺少且验证需要,通过环境批准/可信路径安装它,或要求用户安装/启用它。

规范文档

路径选择门(必须先运行)

在选择任何参考文件之前,对项目进行分类:

  1. 如果尚不存在 React Native 应用,使用 Expo 创建路径:
  2. 如果存在 React Native 应用,检查 package.json 和 app.json:
    • 如果存在 expo 或请求了 Expo 插件工作流,则为 Expo。
    • 如果使用了原生文件夹和直接的 RN CLI 工作流,且无 Expo 路径要求,则为纯 RN。
  3. 如果仍不明确,提出一个消歧问题。
  4. 仅沿一条路径继续。

何时应用

在以下情况下参考此包:

  • 实施从纯原生应用到 React Native 或 Expo 的已接受增量迁移时
  • 为 Expo 或纯 React Native 项目创建褐地集成流程时
  • 使用 @callstack/react-native-brownfield 执行初始设置时
  • 从 React Native 应用生成 iOS XCFramework 产物时
  • 从 React Native 应用生成并发布 Android AAR 产物时
  • 将生成的产物集成到宿主 iOS/Android 应用时

快速参考

文件描述
quick-start.md共享预检和必选的路径选择门
cli-and-config.mdCLI 命令、完整标志集、配置文件、产物布局、代码生成副作用
runtime-api.md宿主 <-> RN API 表面(JS、Swift、Kotlin)和参考应用
expo-create-app.md在 Expo 褐地设置前搭建新的 Expo 应用
expo-quick-start.mdExpo 插件设置和打包就绪
expo-ios-integration.mdExpo iOS 打包和宿主启动集成
expo-android-integration.mdExpo Android 打包、发布和宿主集成
bare-quick-start.md纯 React Native 基线设置
bare-ios-xcframework-generation.md纯 iOS XCFramework 生成
bare-android-aar-generation.md纯 Android AAR 生成与发布
bare-ios-native-integration.md纯 iOS 宿主集成
bare-android-native-integration.md纯 Android 宿主集成

问题 -> 技能映射

问题从哪里开始
需要先做迁移路径决策assess-react-native-migration
需要 Expo 与纯路径决策quick-start.md
需要 CLI 标志、配置文件形状或产物路径cli-and-config.md
需要宿主 <-> RN API 名称、签名或工作示例应用runtime-api.md
需要在宿主与 RN 之间共享状态,或类型安全的 RN -> 原生导航brownie / brownfield-navigation 技能
需要为褐地创建新的 Expo 应用expo-create-app.md
需要 Expo 褐地设置和插件连接expo-quick-start.md
需要 Expo iOS 褐地集成expo-ios-integration.md
需要 Expo Android 褐地集成expo-android-integration.md
需要纯 RN 基线设置bare-quick-start.md
需要纯 RN iOS XCFramework 生成bare-ios-xcframework-generation.md
需要纯 RN Android AAR 生成/发布bare-android-aar-generation.md
需要纯 RN iOS 宿主集成bare-ios-native-integration.md
需要纯 RN Android 宿主集成bare-android-native-integration.md

相关技能

  • 评估 React Native 迁移 在选择迁移路径之前使用。
  • brownie(宿主 <-> RN 共享状态)和 brownfield-navigation(类型安全的 RN -> 原生导航)来自另一个仓库:通过名称调用它们,如果未安装则回退到规范文档。

Individual skills in this repo

This repo contains 15 individual skills — each has its own dedicated page.

agent-device

Automates interactions for Apple-platform apps (iOS, tvOS, macOS) and Android devices. Use when navigating apps, taking snapshots/screenshots, tapping, typing, scrolling, or extracting UI info across mobile, TV, and desktop targets.

assess-react-native-migration

Assesses whether and how an existing mobile product should migrate to React Native. Use when auditing one or more product repositories for migration readiness, including products whose iOS, Android, and other clients live in separate directories or repositories; choosing brownfield, greenfield, or a checkpoint-based path; defining a representative trial; or preparing a baseline and ROI decision before implementation. When product scope or material evidence is unavailable, grills the stakeholder with exactly one question per turn instead of sending a questionnaire.

callstackincubator/github

GitHub patterns using gh CLI for pull requests, stacked PRs, code review, branching strategies, and repository automation. Use when working with GitHub PRs, merging strategies, or repository management tasks.

callstackincubator/validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

create-react-native-library

Scaffolds React Native libraries with create-react-native-library for standalone libraries or local native modules and views. Use when creating or working on React Native libraries or adding native functionality in an existing app.

dogfood

Systematically explore and test a mobile app on iOS/Android with agent-device to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", or "test this app" on mobile. Produces a structured report with reproducible evidence: screenshots, optional repro videos, and detailed steps for every issue.

github-actions

GitHub Actions workflow patterns for React Native iOS simulator and Android emulator cloud builds with downloadable artifacts. Use when setting up CI build pipelines or downloading GitHub Actions artifacts via gh CLI and GitHub API.

react-native-best-practices

Provides React Native performance optimization guidelines for FPS, TTI, bundle size, memory leaks, re-renders, and animations. Applies to tasks involving Hermes optimization, JS thread blocking, bridge overhead, FlashList, native modules, or debugging jank and frame drops.

react-native-testing

Write tests using React Native Testing Library (RNTL) v13 and v14 (`@testing-library/react-native`). Use when writing, reviewing, or fixing React Native component tests. Covers: render, screen, queries (getBy/getAllBy/queryBy/findBy), Jest matchers, userEvent, fireEvent, waitFor, and async patterns. Supports v13 (React 18, sync render) and v14 (React 19+, async render). Triggers on: test files for React Native components, RNTL imports, mentions of "testing library", "write tests", "component tests", or "RNTL".

react-native-tv-best-practices

Reviews React Native TV apps for focus/D-pad navigation, 10-foot UI layout, TV playback/DRM integration, low-memory TV performance, and TV accessibility. Use when building, debugging, or reviewing react-native-tvos, Expo TV, Amazon Vega/Kepler, or React Native web TV targets where the issue depends on remote input, TV focus, TV packaging, TV hardware, or TV playback constraints.

react-navigation

Provides React Navigation UI patterns for stacks, tabs, drawers etc. Use when building navigation UIs with React Navigation, configuring headers, bottom sheets or handling safe areas and insets.

upgrading-react-native

Upgrades React Native apps to newer versions by applying rn-diff-purge template diffs, updating package.json dependencies, migrating native iOS and Android configuration, resolving CocoaPods and Gradle changes, and handling breaking API updates. Use when upgrading React Native, bumping RN version, updating from RN 0.x to 0.y, or migrating Expo SDK alongside a React Native upgrade.

validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

writing-user-docs

House style for user-facing documentation — voice, scope, structure, and what to leave out. Use this skill whenever writing, editing, or reviewing anything a user reads to learn how to use a tool — help center articles, getting-started guides, tutorials, feature docs, README usage sections, in-app help, release notes, or FAQ entries. Trigger it even when the request is phrased plainly — "document this feature", "write docs for X", "explain this to users", "write a README for this library", "turn these notes into a guide" — and even when no style guidelines are mentioned. Also use it to review existing docs for tone, bloat, or leaked implementation detail. Do not use it for internal engineering docs, architecture write-ups, RFCs, or code comments.

相关技能