返回提示词目录第 1184 页

设计令牌语义化迁移规划

只读盘点代码中的基础令牌引用,制定语义映射、分阶段迁移、自动化边界与视觉回归验证方案。

完整提示词

<context>
Code that references primitives (`blue-600`, `gray-500`) cannot be re-themed: dark mode, a new brand or a contrast fix means editing every usage. Moving to semantic tokens (`color.text.secondary`, `color.border.default`) cannot be done by value alone, because the same primitive plays different roles: `gray-500` is secondary text in one place, a border in another and a disabled icon in a third, and each needs a different semantic token that will diverge in dark mode. Good migrations map by context (the CSS property or platform attribute, the component, the state), automate only the unambiguous pairs, send the ambiguous ones to a person with the evidence, add the semantic tokens that are genuinely missing instead of forcing a near fit, and verify that the default theme looks identical after each phase, so the visual diff is zero before any new theme is turned on.
</context>

<task>
Plan the migration of {{repo_path}} to semantic tokens defined in {{token_source}}. Do not change any files; this is analysis and planning only.
{{#scope}}

<scope>
{{scope}}
</scope>
{{/scope}}

1. **Read the tokens.** List the primitive and semantic tokens in {{token_source}}, how semantic tokens alias primitives, and which themes exist. If there is no semantic layer, say so and propose a minimal one marked proposed.
2. **Inventory usages.** Search the code for every reference to primitive tokens (CSS custom properties, preprocessor variables, theme object keys, utility classes, native resources). Record file, token, the property or attribute it sets, and the component. Give totals per token and per property.
3. **Mapping rules.** Rules of the form "primitive X used for property Y in context Z maps to semantic token S", for example `gray-500` on `color` maps to `color.text.secondary` and on `border-color` maps to `color.border.default`. Count how many usages each rule covers.
4. **Ambiguous cases.** Usages no rule covers confidently (the same token for a decorative and a meaningful role, state colours used as brand colours, one-off tints). List them with file references and the question a designer must answer.
5. **Missing semantic tokens.** Roles found in code with no semantic token, with a proposed name following the existing naming grammar.
6. **Migration phases.** Order by package or feature area, smallest risk first, each phase shippable alone with zero visual change in the default theme.
7. **Automation.** Which rules a codemod can apply safely, what the codemod must not touch, and a lint rule that blocks new primitive references in component code after each area is migrated.
8. **Verification.** Visual regression in the default theme per phase, a check that every semantic token resolves in every theme, and contrast checks for any theme turned on afterwards.
</task>

<constraints>
- Read only. Do not modify files, install packages or run codemods.
- Never map by colour value alone; every mapping rule names the property or context.
- Report counts you actually found; mark estimates as estimates.
{{> guardrails/investigate-before-answering}}
{{> output/uncertainty}}
</constraints>

<output_format>
Markdown with the sections from the contract, in order. Usage inventory and mapping rules as tables with counts. Ambiguous cases with file paths and line numbers. End with Risks.
</output_format>

可替换内容

  • {{repo_path}}
  • {{token_source}}
  • {{#scope}}
  • {{scope}}
  • {{/scope}}
  • {{> guardrails/investigate-before-answering}}
  • {{> output/uncertainty}}

分类与标签

编程开发、设计令牌、代码迁移、设计系统、视觉回归

前往 AI 图片创作