weapp-tailwindcss
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseweapp-tailwindcss Skill
weapp-tailwindcss Skill
用于业务项目接入 ,并让 AI 稳定完成“小程序 + 多端”配置、排障与 Tailwind 写法规范落地。
weapp-tailwindcss本 Skill 服务“项目使用者”场景,不是仓库内部二次开发指南。
Used for integrating into business projects, and enabling AI to stably complete "mini-program + multi-end" configuration, troubleshooting, and implementation of Tailwind writing specifications.
weapp-tailwindcssThis Skill serves the "project user" scenario, not a guide for secondary development inside the repository.
适用任务
Applicable Tasks
- 新项目快速启用
tailwindcss + weapp-tailwindcss - 老项目迁移(/
uni-app/taro/ 原生小程序)uni-app x - 多端协同(小程序 + /
H5)配置App - 样式不生效、任意值异常、
rpx字符串 class 未转译等问题排查JS - 需要“Tailwind class 应该怎么写”的团队规范与代码评审清单
- Quickly enable for new projects
tailwindcss + weapp-tailwindcss - Legacy project migration (/
uni-app/taro/ native mini-programs)uni-app x - Multi-end collaboration (mini-program + /
H5) configurationApp - Troubleshooting issues such as invalid styles, abnormal arbitrary values, untranslated
rpxstring classes, etc.JS - Team specifications and code review checklists for "How to write Tailwind classes"
任务分流
Task Diversion
先判断用户当前任务类型,再进入对应流程:
- 集成新项目
- 迁移存量项目
- 排查已有问题
- 沉淀 Tailwind 写法规范
First determine the user's current task type, then enter the corresponding process:
- Integrate new project
- Migrate existing project
- Troubleshoot existing problems
- Settle Tailwind writing specifications
信息收集最小集
Minimum Information Collection Set
缺少关键信息时,先补齐后再输出方案:
- 当前框架:/
uni-app/taro/ 原生小程序 / 其他uni-app x - 构建工具:/
vite/webpack5/ 其他webpack4 - 目标端:仅小程序,还是小程序 + /
H5App - 主版本(v3 / v4)与包管理器(重点确认是否
tailwindcss)pnpm@10+ - 运行环境:版本(建议
node)^20.19.0 || >=22.12.0 - 当前诉求是“集成配置 / 问题排查 / 写法规范沉淀”中的哪一类
When key information is missing, fill it first before outputting the solution:
- Current framework: /
uni-app/taro/ native mini-program / othersuni-app x - Build tool: /
vite/webpack5/ otherswebpack4 - Target end: Mini-program only, or mini-program + /
H5App - main version (v3 / v4) and package manager (focus on confirming if it is
tailwindcss)pnpm@10+ - Runtime environment: version (recommended
node)^20.19.0 || >=22.12.0 - Which of the following is the current demand: "integration configuration / problem troubleshooting / writing specification settlement"
执行流程
Execution Process
1) 基线配置(所有任务通用)
1) Baseline Configuration (common for all tasks)
- 先判断 Tailwind 主版本与扫描方式:
- 用
tailwindcss@3tailwind.config.js -> content - 用入口 CSS 的
tailwindcss@4@source - 扫描范围必须覆盖真实模板与脚本文件,并排除 /
dist/unpackagenode_modules - 明确 需要有
postinstallweapp-tw patch - 若是 ,提醒执行
pnpm@10+pnpm approve-builds weapp-tailwindcss - 如怀疑补丁缓存或目标记录异常,可使用
weapp-tw patch --clear-cache
- First determine the Tailwind main version and scanning method:
- uses
tailwindcss@3tailwind.config.js -> content - uses
tailwindcss@4in the entry CSS@source - The scanning range must cover real template and script files, and exclude /
dist/unpackagenode_modules - Clarify that needs to include
postinstallweapp-tw patch - If using , remind to execute
pnpm@10+pnpm approve-builds weapp-tailwindcss - If patch cache or target record abnormality is suspected, you can use
weapp-tw patch --clear-cache
2) 按任务类型执行
2) Execute by task type
-
集成/迁移任务:
-
优先读取 references/integration-playbook.md
-
按框架给出“可复制最小配置”,不要只给概念
-
多端场景下,明确条件,避免把小程序插件能力无条件作用到纯
disabledH5 -
排障任务:
-
优先读取 references/troubleshooting-playbook.md
-
先按“症状 -> 最短排查路径”输出步骤,再给修复示例
-
明确每一步“期望现象/验证点”,避免模糊建议
-
写法规范任务:
-
读取 references/tailwind-writing-best-practices.md
-
按“推荐写法 / 反例 / 评审清单”输出
-
需要运行时拼类时,优先/
@weapp-tailwindcss/merge/cvavariants -
涉及封装重命名时,提醒
ignoreCallExpressionIdentifiers
-
Integration/migration tasks:
-
Prioritize reading references/integration-playbook.md
-
Provide "copyable minimum configuration" according to the framework, do not only give concepts
-
In multi-end scenarios, clarify theconditions to avoid unconditionally applying mini-program plugin capabilities to pure
disabledH5 -
Troubleshooting tasks:
-
Prioritize reading references/troubleshooting-playbook.md
-
First output steps according to "symptom -> shortest troubleshooting path", then provide repair examples
-
Clarify the "expected phenomenon/verification point" for each step, avoid vague suggestions
-
Writing specification tasks:
-
Read references/tailwind-writing-best-practices.md
-
Output according to "recommended writing / counterexample / review checklist"
-
When runtime class splicing is required, prioritize/
@weapp-tailwindcss/merge/cvavariants -
When it comes to encapsulation and renaming, remind of
ignoreCallExpressionIdentifiers
3) 回归验证(所有任务都要给)
3) Regression Verification (required for all tasks)
- 先跑开发态,再跑目标端构建
- 至少验证 3 类样式:基础工具类、任意值(含 )、变体/伪类
rpx - 若 中 class 不生效,优先检查
JS/TS是否覆盖该文件与扩展名content/@source - 若 /
space-y-*不生效,固定优先级:space-x-* - 先改结构(子节点落到 或外层补
view/text)view - 再评估
virtualHost - 最后才扩展 (保持最小标签集合)
cssChildCombinatorReplaceValue
- Run the development environment first, then run the target end build
- Verify at least 3 types of styles: basic utility classes, arbitrary values (including ), variants/pseudo-classes
rpx - If class in does not take effect, first check if
JS/TScovers the file and its extensioncontent/@source - If /
space-y-*does not take effect, follow the fixed priority:space-x-* - First modify the structure (child nodes fall to or add
view/textin the outer layer)view - Then evaluate
virtualHost - Finally extend (keep the minimum tag set)
cssChildCombinatorReplaceValue
输出格式要求
Output Format Requirements
最终输出必须包含:
- 结论(适用框架、Tailwind 版本、目标端)
- 修改文件清单(按文件逐条列出)
- 可直接复制的配置片段
- 安装/运行命令(默认 )
pnpm - 验证步骤与预期结果
- 回滚方案(至少一条)
若用户要求“规范沉淀”,额外补充:
- 推荐写法(Do)
- 禁止写法(Don't)
- 最小回归检查清单(Code Review Checklist)
The final output must include:
- Conclusion (applicable framework, Tailwind version, target end)
- Modification file list (listed one by one by file)
- Config snippets that can be copied directly
- Installation/runtime commands (default )
pnpm - Verification steps and expected results
- Rollback solution (at least one)
If the user requires "specification settlement", additionally supplement:
- Recommended writing (Do)
- Prohibited writing (Don't)
- Minimum regression check checklist (Code Review Checklist)
关键约束
Key Constraints
- 不要省略 ,否则
weapp-tw patch与rpx转译链路可能失效JS - 不要把小程序转译插件无条件应用到纯 场景
H5 - 不要忽略 范围配置;这会直接导致 class 不生成
content/@source - 不要建议“运行时自由拼接 class 字符串”作为常规方案;优先枚举化或
cva/tv - 对 、
text-[22rpx]等二义性任意值,提供bg-[22rpx]/length:前缀作为兜底写法color: - 涉及 /
twMerge/twJoin/cva/cn的封装或重命名时,提醒配置tvignoreCallExpressionIdentifiers - 需要原样透传第三方类名时,优先使用
weappTwIgnore - 对 /
space-y-*,默认按space-x-*(含view + view)处理,不要假设会自动覆盖全部标签text - /
space-y-*的标签扩展应最小化,只加入业务确实需要的标签,避免选择器污染space-x-* - 不要提供与仓库原则冲突的建议:转译基于
JS精确命中,禁止启发式兜底转译classNameSet - 对版本不确定时,优先给出与官方文档一致的最小可用方案,再做增量优化
- Do not omit , otherwise the
weapp-tw patchandrpxtranslation links may failJS - Do not unconditionally apply the mini-program translation plugin to pure scenarios
H5 - Do not ignore the range configuration; this will directly cause classes not to be generated
content/@source - Do not suggest "freely splicing class strings at runtime" as a regular solution; prioritize enumeration or
cva/tv - For ambiguous arbitrary values such as ,
text-[22rpx], providebg-[22rpx]/length:prefixes as a fallback writing methodcolor: - When it comes to encapsulation or renaming of /
twMerge/twJoin/cva/cn, remind to configuretvignoreCallExpressionIdentifiers - When you need to pass through third-party class names as they are, prioritize using
weappTwIgnore - For /
space-y-*, default to handle according tospace-x-*(includingview + view), do not assume that all tags will be automatically coveredtext - The tag extension of /
space-y-*should be minimized, only add tags that the business actually needs to avoid selector pollutionspace-x-* - Do not provide suggestions that conflict with repository principles: translation is based on precise hit of
JS, heuristic fallback translation is prohibitedclassNameSet - When the version is uncertain, first provide the minimum available solution consistent with the official documentation, then do incremental optimization
引用资料
References
- references/integration-playbook.md
- 在“新接入/迁移”类问题中优先读取
- 直接复用其中的最小配置骨架与验证清单
- references/troubleshooting-playbook.md
- 在“样式不生效/行为异常”类问题中优先读取
- 按症状路径输出排查步骤,不跳步
- references/tailwind-writing-best-practices.md
- 在用户要求“Tailwind 写法建议、团队规范、代码评审清单、动态类治理”时读取
- 按“决策顺序 + 示例 + 反例 + 验证步骤”输出,不只给概念
- references/integration-playbook.md
- Prioritize reading in "new access/migration" type problems
- Directly reuse the minimum configuration skeleton and verification checklist in it
- references/troubleshooting-playbook.md
- Prioritize reading in "invalid style/abnormal behavior" type problems
- Output troubleshooting steps according to the symptom path, do not skip steps
- references/tailwind-writing-best-practices.md
- Read when the user requires "Tailwind writing suggestions, team specifications, code review checklist, dynamic class governance"
- Output according to "decision order + example + counterexample + verification steps", do not only give concepts