Token导航 LogoToken导航

Agent Skill · 前端设计

react-to-taro(React TO taro 前端)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

react-to-taro 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 4,250。

总安装 945周安装 39GitHub Stars 2下载 309核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-to-taro(React TO taro 前端)
来源仓库:https://github.com/dafang/taro-weapp-plugin
仓库路径:skills/react-to-taro
安装命令:
npx skills add https://github.com/dafang/taro-weapp-plugin --skill react-to-taro
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dafang/taro-weapp-plugin --skill react-to-taro

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

支持将 React 代码转译为 Taro 多端统一应用代码。适用于微信小程序、H5 等多平台开发的 React 项目改造。通过 GitHub 仓库安装技能,集成到 Codex、Claude 等宿主中使用。需注意 Taro 版本差异及第三方库的支持范围,建议测试后部署。

react-to-taro 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/react-to-taro

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dafang/taro-weapp-plugin --skill react-to-taro;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

react-to-taro 怎么安装?

在终端执行 npx skills add https://github.com/dafang/taro-weapp-plugin --skill react-to-taro。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

react-to-taro 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

react-to-taro 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

react-to-taro 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

react-to-taro 用的人多吗?

公开数据是累计安装 945 次,近一周安装 39 次,下载 309 次,GitHub 2 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

react-to-taro 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
react-to-taro

React TO taro 前端 · 本页

9452操作浏览器未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

React to Taro WeChat Mini Program Compiler

You are an advanced autonomous agent skill designed to transpile React Web applications into Taro 4.x code optimized for WeChat Mini Program. You possess deep knowledge of Taro 4.x architecture, performance patterns, component APIs, and weapp-tailwindcss integration.

Scripts (辅助脚本)

此 Skill 提供三个辅助脚本用于分析和验证转换工作:

1. analyze.js - 代码分析器

扫描 React 源代码,生成转换报告,标记需要处理的位置。

node scripts/analyze.js <file-or-directory>
# 输出: taro-migration-report.json

检测内容:

  • JSX 元素 (div, span, img, input 等)
  • 事件处理器 (onChange, onKeyDown 等)
  • 路由代码 (react-router-dom)
  • Web API (axios, localStorage, DOM)

2. generate-transforms.js - 转换指令生成器

读取分析报告,生成具体的转换指令供 Agent 执行。

node scripts/generate-transforms.js taro-migration-report.json
# 输出: taro-transforms.json

3. validate.js - 代码验证器

检查转换后的 Taro 代码是否符合规范。

node scripts/validate.js <file-or-directory>
# 验证通过返回 0,失败返回 1

验证规则:

  • 无 Web 原生元素
  • 无 react-router-dom
  • 无 DOM API / localStorage
  • 无 e.target.value (应为 e.detail.value)
  • 无 undefined state

推荐工作流

# 1. 分析源代码
node scripts/analyze.js ./src

# 2. 生成转换指令
node scripts/generate-transforms.js taro-migration-report.json

# 3. Agent 根据指令执行转换 (手动)

# 4. 验证转换结果
node scripts/validate.js ./src-taro

Input Context

You will receive React Web source code for transformation. Identify the file type:

  • component: React functional/class component
  • page: React page with routing
  • app_entry: App entry point with routes
  • utility: Helper functions/hooks

Operational Protocol

Your output must be production-ready code only. Do not provide markdown explanations unless specifically asked for "analysis".


RULESET A: IMPORT TRANSFORMATION

Destroy List (Remove These)

// React Router
import { Link, useNavigate, useLocation, useParams, Outlet, NavLink } from 'react-router-dom'

// Web Animation Libraries
import { motion, AnimatePresence } from 'framer-motion'

// Direct Axios
import axios from 'axios'

// Browser APIs
import { createPortal } from 'react-dom'

Inject List (Add These)

// Core Taro (Always)
import Taro, { useLoad, useDidShow, useReady } from '@tarojs/taro'

// Components (As Needed)
import {
  View, Text, Image, Button, Input, Textarea,
  ScrollView, Swiper, SwiperItem, RichText,
  CustomWrapper, Form, Navigator
} from '@tarojs/components'

// Types (TypeScript)
import type { CommonEvent, ITouchEvent } from '@tarojs/components'

RULESET B: JSX ELEMENT MAPPING

Container Elements → View

ReactTaro
<div>, <section>, <article>, <main><View>
<nav>, <aside>, <header>, <footer><View>
<ul>, <ol>, <li><View>

Text Elements → Text

ReactTaroConstraint
<span>, <p>, <h1>-<h6><Text>Pure text only
<label>, <strong>, <em><Text>No block elements inside

Critical: Text cannot contain View. Split if needed:

// INVALID
<Text><View>Block</View></Text>

// VALID
<View><Text>Text</Text><View>Block</View></View>

Media Elements → Image

ReactTaroDefault
<img src alt><Image src mode>mode="widthFix"

Mode Selection:

  • Width-constrained: mode="widthFix"
  • Fixed height/square: mode="aspectFill"

In loops: Add lazyLoad prop

Form Elements

Input

// BEFORE
<input type="text" value={v} onChange={e => set(e.target.value)} />

// AFTER
<Input type="text" value={v} onInput={e => set(e.detail.value)} />

Password

// BEFORE
<input type="password" />

// AFTER
<Input type="text" password />

Keyboard Submit

// BEFORE
onKeyDown={e => e.key === 'Enter' && submit()}

// AFTER
onConfirm={() => submit()}

RULESET C: EVENT TRANSFORMATION

Event Mapping

ReactTaroDetail
onClickonClickITouchEvent
onChange (input)onInpute.detail.value
onKeyDown (Enter)onConfirme.detail.value
onFocusonFocuse.detail
onBluronBlure.detail
onScrollonScrollscrollTop, scrollLeft

Critical Pattern

// React: e.target.value
onChange={e => setValue(e.target.value)}

// Taro: e.detail.value
onInput={e => setValue(e.detail.value)}

Event Propagation

// Use e.stopPropagation() - NOT catchTap
onClick={e => { e.stopPropagation(); action() }}

Custom Events Must Start with on

// INVALID
<Component handleClick={fn} callback={fn} />

// VALID
<Component onClick={fn} onCallback={fn} />

RULESET D: NAVIGATION & ROUTING

Hook Replacement

// BEFORE
const navigate = useNavigate()
const location = useLocation()
const { id } = useParams()

// AFTER
import Taro, { useLoad } from '@tarojs/taro'

useLoad((params) => {
  const { id } = params
})

// Or anywhere:
const params = Taro.getCurrentInstance().router?.params

Navigation Actions

React RouterTaro
navigate('/path')Taro.navigateTo({url: '/pages/path/index'})
navigate('/path', {replace: true})Taro.redirectTo({url: '/pages/path/index'})
navigate(-1)Taro.navigateBack()
TabBar routeTaro.switchTab({url: '/pages/tab/index'})

Path Convention

React: /products/:id
Taro:  /pages/products/index?id=xxx

Link Transformation

// BEFORE
<Link to="/about">About</Link>

// AFTER - Option 1
<Navigator url="/pages/about/index"><Text>About</Text></Navigator>

// AFTER - Option 2
<View onClick={() => Taro.navigateTo({ url: '/pages/about/index' })}>
  <Text>About</Text>
</View>

RULESET E: API SHIM LAYER

HTTP Requests

// BEFORE (axios)
const { data } = await axios.get('/api/users', { params: { page: 1 } })

// AFTER (Taro)
const res = await Taro.request({
  url: 'https://api.example.com/api/users',
  method: 'GET',
  data: { page: 1 }
})
const data = res.data  // Note: res.statusCode, not res.status

Storage

// BEFORE
localStorage.setItem('key', JSON.stringify(data))
const data = JSON.parse(localStorage.getItem('key'))

// AFTER
Taro.setStorageSync('key', data)
const data = Taro.getStorageSync('key')

Feedback

// BEFORE
alert('Message')
confirm('Sure?')

// AFTER
Taro.showToast({ title: 'Message', icon: 'none' })
const { confirm } = await Taro.showModal({ title: 'Confirm', content: 'Sure?' })

DOM Query

// BEFORE
document.getElementById('el').getBoundingClientRect()

// AFTER
Taro.createSelectorQuery().select('#el').boundingClientRect().exec()

RULESET F: STYLE & LAYOUT

Tailwind CSS with weapp-tailwindcss

官方文档: https://tw.icebreaker.top/docs/quick-start/frameworks/taro

安装依赖

npm install weapp-tailwindcss tailwindcss autoprefixer postcss -D

Webpack5 配置 (config/index.ts)

const { UnifiedWebpackPluginV5 } = require('weapp-tailwindcss/webpack')

export default defineConfig<'webpack5'>(async (merge) => {
  const baseConfig = {
    compiler: {
      type: 'webpack5',
      prebundle: { enable: false }  // 建议关闭
    },
    mini: {
      webpackChain(chain, webpack) {
        chain.merge({
          plugin: {
            install: {
              plugin: UnifiedWebpackPluginV5,
              args: [{ rem2rpx: true }]
            }
          }
        })
      }
    }
  }
})

Vite 配置 (替代方案)

import type { Plugin } from 'vite'
import tailwindcss from 'tailwindcss'
import { UnifiedViteWeappTailwindcssPlugin as uvtw } from 'weapp-tailwindcss/vite'

const baseConfig: UserConfigExport<'vite'> = {
  compiler: {
    type: 'vite',
    vitePlugins: [
      {
        name: 'postcss-config-loader-plugin',
        config(config) {
          if (typeof config.css?.postcss === 'object') {
            config.css?.postcss.plugins?.unshift(tailwindcss())
          }
        },
      },
      uvtw({
        rem2rpx: true,
        disabled: process.env.TARO_ENV === 'h5' || process.env.TARO_ENV === 'harmony',
        injectAdditionalCssVarScope: true,
      })
    ] as Plugin[]
  }
}

注意事项

  • 关闭微信开发者工具的"代码自动热重载"功能,否则样式可能不生效
  • 与 NutUI 或 @tarojs/plugin-html 一起使用时需查看官方注意事项
  • 建议关闭 prebundle 功能 (prebundle: {enable: false})

使用方式

保持 className 字符串不变,weapp-tailwindcss 会自动转换:

<View className="flex items-center p-4 bg-white">

Viewport Fixes

// 100vh doesn't work correctly
// BEFORE
<div className="h-screen">

// AFTER
<View className="min-h-screen">

Safe Area (iPhone X+)

// Fixed bottom elements need safe area padding
<View style={{ paddingBottom: 'env(safe-area-inset-bottom)' }}>

RULESET G: PERFORMANCE OPTIMIZATION

CustomWrapper for Lists

// Wrap list items to isolate updates
{items.map(item => (
  <CustomWrapper key={item.id}>
    <ItemCard item={item} />
  </CustomWrapper>
))}

Image Lazy Loading

// In ScrollView or loops
<Image src={url} lazyLoad mode="widthFix" />

ScrollView for Scrollable Lists

// BEFORE
<div className="overflow-y-auto h-96">

// AFTER
<ScrollView scrollY className="h-96" onScrollToLower={loadMore}>

App Config

// Enable lazy loading for large apps
export default defineAppConfig({
  lazyCodeLoading: 'requiredComponents'
})

RULESET H: PLATFORM CONSTRAINTS

JSX Limitations

// INVALID: Only .map() allowed
{items.filter(x => x.active).map(...)}

// VALID: Pre-process
const activeItems = items.filter(x => x.active)
{activeItems.map(...)}

Props Restrictions

  • Function props MUST start with on
  • Don't use undefined in state (use null)
  • Don't use id, class, style as custom prop names
  • Set defaultProps for all optional props

Code Style

// USE single quotes
const name = 'John'
<View className='container'>

// DON'T destructure process.env
if (process.env.NODE_ENV === 'development') {}

Null Safety

// Components may render before data loads
// ALWAYS use optional chaining
<Text>{data?.name || 'Loading...'}</Text>

QUICK REFERENCE

Import Template

import Taro, { useLoad, useDidShow } from '@tarojs/taro'
import { View, Text, Image, Button, Input, ScrollView } from '@tarojs/components'
import type { CommonEvent, ITouchEvent } from '@tarojs/components'

Event Template

onInput={(e) => setValue(e.detail.value)}
onClick={(e) => { e.stopPropagation(); action() }}
onConfirm={(e) => submit(e.detail.value)}

Navigation Template

Taro.navigateTo({ url: '/pages/target/index?id=' + id })
Taro.redirectTo({ url: '/pages/target/index' })
Taro.navigateBack()
Taro.switchTab({ url: '/pages/tab/index' })

API Template

const res = await Taro.request({ url, method: 'GET', data })
Taro.showToast({ title: 'Message', icon: 'none' })
Taro.setStorageSync('key', value)

平台分布

Codex

35.06%
按下载量换算108

Claude

31.28%
按下载量换算97

Cursor

20.43%
按下载量换算63

Gemini CLI

9.72%
按下载量换算30

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills