bricks-design-systems
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRequires: Bricks 2.4+ with the Abilities API enabled
要求: Bricks 2.4+ 且已启用 Abilities API
Update check
更新检查
Run first when filesystem tools are available:
bash
_BS_UPDATE_CHECK=""
for _CAND in "$HOME/.bricks/skills/bricks-skills/scripts/bricks-skills-update-check" "$PWD/scripts/bricks-skills-update-check" "$HOME/.claude/skills/bricks-skills/scripts/bricks-skills-update-check" "$HOME/.codex/skills/bricks-skills/scripts/bricks-skills-update-check"; do
[ -f "$_CAND" ] && _BS_UPDATE_CHECK="$_CAND" && break
done
[ -n "$_BS_UPDATE_CHECK" ] && sh "$_BS_UPDATE_CHECK" || trueIf it prints , load bricks-skills-update before continuing. If it prints , mention the new version and continue.
BRICKS_SKILLS_UPDATE_AVAILABLE <old> <new> <tag>BRICKS_SKILLS_JUST_UPDATED <old> <new>当文件系统工具可用时,首先运行以下命令:
bash
_BS_UPDATE_CHECK=""
for _CAND in "$HOME/.bricks/skills/bricks-skills/scripts/bricks-skills-update-check" "$PWD/scripts/bricks-skills-update-check" "$HOME/.claude/skills/bricks-skills/scripts/bricks-skills-update-check" "$HOME/.codex/skills/bricks-skills/scripts/bricks-skills-update-check"; do
[ -f "$_CAND" ] && _BS_UPDATE_CHECK="$_CAND" && break
done
[ -n "$_BS_UPDATE_CHECK" ] && sh "$_BS_UPDATE_CHECK" || true如果输出 ,请先加载 bricks-skills-update 再继续。如果输出 ,请提及新版本后继续。
BRICKS_SKILLS_UPDATE_AVAILABLE <old> <new> <tag>BRICKS_SKILLS_JUST_UPDATED <old> <new>Bricks: design system authoring
Bricks:设计系统创作
If aability is not available as a direct tool: first check whether it is outside the fast path and call it throughbricks/*withmcp-adapter-execute-ability. If the dispatcher also rejects it, callability_name: "bricks/<name>"to check whether a site admin disabled it under Bricks > AI.bricks-list-ability-status
如果无法直接使用能力:首先检查它是否在快速路径之外,若不在则通过bricks/*调用,参数mcp-adapter-execute-ability。若调度器也拒绝调用,请调用ability_name: "bricks/<name>"检查站点管理员是否在 Bricks > AI 下禁用了该能力。bricks-list-ability-status
Before you write anything
开始创作前
Call . You are looking for three answers:
bricks/get-design-context- Does a matching resource already exist? Reuse it.
- Is there a convention to follow? (kebab-case classes, variable naming, t-shirt or numeric scale: match it.)
--space-{size} - Are there empty slots? (Palette exists but one color is missing, scale exists but one step is missing.) Fill the slot instead of creating a new parallel resource.
Also inspect . If a category already has a config, use that category ID and prefix. Do not create variables when the typography category prefix is , and do not hand-author static spacing/type values when a scale category exists.
variableCategoriesscalefs-*text-A fresh Bricks install can have no saved design-system resources: no custom theme style, classes, components, or saved variables. Bricks still exposes a built-in default color palette fallback in the builder and in ; do not tell users Bricks has no default palette. If returns empty, treat the editable design system as greenfield and seed it deliberately (see bricks-seed-design-system skill).
list-color-palettesget-design-context调用 。你需要获取三个答案:
bricks/get-design-context- 是否已存在匹配的资源?若存在则复用。
- 是否有需要遵循的约定?(短横线分隔的类名、变量命名规则、T恤尺码式或数值式比例:请遵循对应约定。)
--space-{size} - 是否有空缺的位置?(调色板已存在但缺少某个颜色,比例已存在但缺少某个层级:请填补空缺,而非创建新的并行资源。)
同时检查 。如果某个分类已有 配置,请使用该分类ID和前缀。当排版分类的前缀是 时,不要创建 变量;当存在比例分类时,不要手动编写静态间距/字体数值。
variableCategoriesscaletext-fs-*全新安装的 Bricks 可能没有已保存的设计系统资源:无自定义主题样式、类、组件或已保存的变量。但 Bricks 在编辑器和 中仍提供内置的默认调色板回退;不要告知用户 Bricks 没有默认调色板。若 返回空值,则将可编辑的设计系统视为全新项目,有意地初始化它(请参见 bricks-seed-design-system 技能)。
list-color-palettesget-design-contextGlobal classes
全局类
- Names must be unique across all classes. The write aborts with if the name is taken. Read the existing one before retrying.
bricks_conflict_duplicate_global_class_name - Keep names kebab-case, lowercase, no vendor prefixes. ,
.button,.card. Not.hero-text,btn_v2,Button.--hero-text - Don't create modifier classes like : create a base class and a modifier class that sets only the color. Bricks supports class combinations natively.
.button-red - Class settings follow the same shape as element settings: call on a minimal element using the class to verify CSS output before committing settings programmatically.
bricks/render-elements
- 名称必须在所有类中唯一。若名称已被占用,写入操作会因 终止。重试前请先查看已存在的类。
bricks_conflict_duplicate_global_class_name - 名称请保持**kebab-case(短横线分隔小写)**格式,不要使用供应商前缀。例如 、
.button、.card,而非.hero-text、btn_v2、Button。--hero-text - 不要创建类似 的修饰类:请创建一个基础类和仅设置颜色的修饰类。Bricks 原生支持类组合。
.button-red - 类设置与元素设置的结构一致:在通过编程方式提交设置前,请调用 对使用该类的最小元素进行渲染,以验证CSS输出。
bricks/render-elements
Global variables
全局变量
- Use the scale generator () for typography and spacing. Do not hand-author static spacing or type variables that match a configured scale prefix. The same generator handles both typography and spacing: it's one math model (fluid
bricks/generate-scale-variableswith slope) driven by the category config. There is no separate typography-scale tool.clamp() - When includes spacing or typography categories with
get-design-context.variableCategories, pass the existingscaletocategoryId. The generated names inherit the configured prefix, such asgenerate-scale-variablesorspace-.text- - The scale generator resolves the html base font-size from three sources in order: style manager value -> theme styles -> default. If your scale outputs unexpected pixel values, that order is why.
10px - Variable names must be unique at save time, but the builder UI does not validate this on create: call first and guard against duplicates before writing. Conflict returns
list-global-variableson save.bricks_conflict_duplicate_global_variable_name - Variables are referenced in CSS as . Use the bare name (
var(--{name}), notspace-m) when creating: Bricks adds the--space-mprefix when emitting CSS.-- - When building a fluid scale, use the Bricks scale shape. has four keys the builder cannot work without, plus the math knobs:
category.scale- :
scaleScopeor"typography", nothing else. Style Manager has one fixed tab per scope and lists a category only when"spacing"matches the open tab. Omit it and the scale still shows a "scale" badge in the Variable Manager, still blocks hand-authored values for its prefix, and still gets cascade-deleted with the category — but Style Manager > Typography/Spacing will be empty and the user can never edit or regenerate it.scale.scaleScope - : the ordered step names, e.g.
scaleNames. This list is the scale's extent.["2xs","xs","s","m","l","xl","2xl"](fires when the html font size or min/max screen width changes, and on import) derives each variable's step from its index in this list. Omit it and the baseline index collapses toregenerateVariables(), silently rewriting every variable at the wrong step.0 - : must be one of the
baselineentries. Default t-shirt baseline isscaleNames.m - : e.g.
prefix,text-.space- - Math knobs: (
scaleType|tshirt|numeric),custom,minFontSize,maxFontSize/minScaleRatio,minScaleRatioSelect/maxScaleRatio. Note:maxScaleRatioSelectwins unless it is the literal string*ScaleRatioSelect, in which case"custom"is used.*ScaleRatio
- Keep and
scaleRangein agreement. The builder generates exactly one variable perscaleNamesentry.scaleNamesinstead takes agenerate-scale-variables, so it is possible to generate 11 variables against a 7-entryscaleRange: { from, to }— after which the Style Manager preview andscaleNamesboth map variables onto the wrong steps.regenerateVariables()matches a 7-name list with baseline at index 2.scaleRange: { from: -2, to: 4 } - with
generate-scale-variablesreturns the generated variables for review; show these to the user and wait for approval before saving.save: false - Global variables are stored in a global option, not post revisions. Use for cleanup of individual variables; it returns a
delete-global-variablesnapshot.beforeDelete
- 请使用比例生成器()处理排版和间距。不要手动编写与已配置比例前缀匹配的静态间距或字体变量。同一个生成器可同时处理排版和间距:它是由分类配置驱动的单一数学模型(带斜率的流体
bricks/generate-scale-variables函数)。没有单独的排版比例工具。clamp() - 当 包含带有
get-design-context.variableCategories的间距或排版分类时,请将已有的scale传入categoryId。生成的变量名称会继承已配置的前缀,例如generate-scale-variables或space-。text- - 比例生成器会按以下优先级解析HTML基础字号:样式管理器值 -> 主题样式 -> 默认 。如果你的比例输出了意外的像素值,原因就在此优先级顺序。
10px - 变量名称在保存时必须唯一,但编辑器UI在创建时不会验证这一点:请先调用 ,在写入前避免重复。保存时若存在冲突会返回
list-global-variables。bricks_conflict_duplicate_global_variable_name - 在CSS中引用变量时使用 。创建变量时请使用裸名称(例如
var(--{name}),而非space-m):Bricks 在生成CSS时会自动添加--space-m前缀。-- - 创建流体比例时,请使用 Bricks 比例结构。包含编辑器必须的四个关键属性,以及数学控制项:
category.scale- :只能是
scaleScope或"typography"。样式管理器每个范围对应一个固定标签页,仅当"spacing"与当前打开的标签页匹配时才会列出该分类。若省略该属性,比例仍会在变量管理器中显示“比例”标识,仍会阻止手动编写其前缀的数值,仍会随分类一起被级联删除,但样式管理器 > 排版/间距标签页会为空,用户无法编辑或重新生成该比例。scale.scaleScope - :有序的层级名称,例如
scaleNames。此列表定义了比例的范围。["2xs","xs","s","m","l","xl","2xl"](当HTML字号、最小/最大屏幕宽度变化或导入时触发)会根据变量在该列表中的索引推导其层级。若省略该属性,基线索引会默认为regenerateVariables(),导致所有变量的层级被错误改写。0 - :必须是
baseline中的一个条目。默认T恤尺码式比例的基线是scaleNames。m - :例如
prefix、text-。space- - 数学控制项:(
scaleType|tshirt|numeric)、custom、minFontSize、maxFontSize/minScaleRatio、minScaleRatioSelect/maxScaleRatio。注意:maxScaleRatioSelect优先级更高,除非其值为字符串*ScaleRatioSelect,此时会使用"custom"。*ScaleRatio
- 请保持 和
scaleRange一致。编辑器会为每个scaleNames条目生成一个变量。而scaleNames接受generate-scale-variables参数,因此可能会针对7个条目的scaleRange: { from, to }生成11个变量——这会导致样式管理器预览和scaleNames都将变量映射到错误的层级。regenerateVariables()与基线索引为2的7个名称列表匹配。scaleRange: { from: -2, to: 4 } - 调用 时设置
generate-scale-variables会返回生成的变量供审核;请将这些变量展示给用户,获得批准后再保存。save: false - 全局变量存储在全局选项中,而非文章修订版。请使用 清理单个变量;该操作会返回
delete-global-variable快照。beforeDelete
Color palettes
调色板
- Palettes are ordered arrays of colors. Each color has an id, name, raw value (hex / rgb / rgba / hsl / hsla accepted), and optional CSS variable reference.
- Formats usually round-trip. Light and dark shades preserve the parsed base format. Transparent shades are emitted as HSL/HSLA because the builder's transparent-shade path changes alpha directly.
- Before creating a new palette, check whether the existing primary palette has the color. Fragmented palettes are the most common design-system mess.
- Generating shades. Use to produce light, dark, or transparent ramps from a base color. The ability uses Bricks' PHP color helper, ported from the builder Color Shades popup, so previews should match the builder math. Shade
bricks/generate-color-shadesnames becomerawonly when the base color has avar(--{base-variable}-{l|d|t}-{index})value such asrawor whenvar(--brand-primary)is passed. Without that variable reference, each generated shade keeps the base raw value. WhenbaseVariable, existing shades of the same type, parent, and mode are replaced.save: true - A color ramp is two-step: create the base color with a reference, then call
var(--name)forgenerate-color-shadesandlight(typically 4-5 steps each).darkis optional for tint overlays.transparent
- 调色板是有序的颜色数组。每个颜色包含id、名称、原始值(支持十六进制 / rgb / rgba / hsl / hsla),以及可选的CSS变量引用。
- 格式通常可双向转换。浅色和深色阴影会保留解析后的基础格式。透明阴影会以HSL/HSLA格式输出,因为编辑器的透明阴影处理路径会直接修改透明度。
- 创建新调色板前,请检查现有主调色板是否已包含该颜色。碎片化的调色板是设计系统最常见的问题。
- 生成阴影。使用 从基础颜色生成浅色、深色或透明色阶。该能力使用Bricks的PHP颜色助手,改编自编辑器的颜色阴影弹窗,因此预览效果应与编辑器的计算结果一致。仅当基础颜色的
bricks/generate-color-shades值为raw这类变量引用,或传入了var(--brand-primary)参数时,生成的阴影baseVariable名称才会变为raw。若没有该变量引用,每个生成的阴影会保留基础原始值。当设置var(--{base-variable}-{l|d|t}-{index})时,相同类型、父级和模式的现有阴影会被替换。save: true - 颜色阶分为两步:首先创建带有 引用的基础颜色,然后为
var(--name)和light(通常各4-5个层级)调用dark。generate-color-shades是可选的,用于色调叠加。transparent
Theme styles
主题样式
- Theme styles do not apply without conditions. A style with an empty conditions array is ignored by the normal theme-style matcher. Always set when creating: use
conditionsfor a site-wide base, or a more specific condition such as[{ main: "any" }],postType,ids, orterms.archiveType - By default, Bricks applies the highest-scoring matching theme style. More specific conditions beat broad ones: beats
postType, and exactanybeatsids.postType - If the Theme styles loading method setting is enabled, Bricks loads every matching theme style in score order. In that mode, broad styles load earlier and more specific styles load later.
- The first theme style on a fresh site should almost always be so defaults actually render.
conditions: [{ main: "any" }] - Theme styles are stored in a global option, not post revisions. Use for cleanup; it returns the removed style in
delete-theme-style.beforeDelete
- 主题样式没有条件则不会生效。条件数组为空的样式会被常规主题样式匹配器忽略。创建时请始终设置 :若要设置全站基础样式,使用
conditions;若要设置更具体的条件,可使用[{ main: "any" }]、postType、ids或terms。archiveType - 默认情况下,Bricks 会应用匹配度最高的主题样式。更具体的条件优先级高于宽泛条件:优先级高于
postType,精确any优先级高于ids。postType - 若启用了“主题样式加载方式”设置,Bricks 会按分数顺序加载所有匹配的主题样式。在此模式下,宽泛样式先加载,更具体的样式后加载。
- 全新站点的第一个主题样式几乎总是 ,这样默认样式才能正常渲染。
conditions: [{ main: "any" }] - 主题样式存储在全局选项中,而非文章修订版。请使用 清理;该操作会在
delete-theme-style中返回被移除的样式。beforeDelete
Components
组件
- Labels are unique across all components. on collision.
bricks_conflict_duplicate_component_name - Components carry their own element tree. External references to global classes and CSS variables inside that tree are preserved: if a component uses and
.button, those references follow it wherever it's instanced.var(--space-m) - Deleting a component with non-zero leaves orphan pointers. The builder renders missing components as a placeholder. Either replace the usages first or explicitly accept the orphans with the user.
usageCount - Prefer over copying element trees. The extraction rewrites ids cleanly and swaps the source subtree to a component instance in one write, with a revision snapshot.
extract-component-from-elements
See the bricks-components skill for slots, nested components, and property binding specifics.
- 标签在所有组件中必须唯一。若存在冲突会返回 。
bricks_conflict_duplicate_component_name - 组件带有自己的元素树。元素树中对全局类和CSS变量的外部引用会被保留:若组件使用了 和
.button,这些引用会随组件实例化到任何位置。var(--space-m) - 删除使用次数()非零的组件会留下孤立引用。编辑器会将缺失的组件渲染为占位符。请先替换所有引用,或明确获得用户同意后再接受孤立引用。
usageCount - 优先使用 而非复制元素树。提取操作会清晰地重写id,并在一次写入中将源子树替换为组件实例,同时生成修订快照。
extract-component-from-elements
关于插槽、嵌套组件和属性绑定的细节,请参见 bricks-components 技能。
Workflows
工作流
Add a color ramp to an existing palette
为现有调色板添加颜色阶
- with
create-color+raw: "#RRGGBB".variable: "brand-primary" - with
generate-color-shades,paletteId,colorId,shadeType: "light",steps: 4.save: true - Repeat for (and optional
darkfor tints).transparent - to verify.
list-color-palettes
- 调用 ,参数为
create-color+raw: "#RRGGBB"。variable: "brand-primary" - 调用 ,参数为
generate-color-shades、paletteId、colorId、shadeType: "light"、steps: 4。save: true - 为 (可选为
dark生成色调)重复步骤2。transparent - 调用 验证结果。
list-color-palettes
Add or replace a scale
添加或替换比例
- Pick the naming first (t-shirt or numeric) and stick to it across typography + spacing.
- with
generate-scale-variables: review output with user.save: false - Re-run with once approved.
save: true - to verify.
list-global-variables
For building a full design system from an empty site, use the bricks-seed-design-system skill. For cleanup of an existing one, use bricks-audit-design-system.
- 先确定命名规则(T恤尺码式或数值式),并在排版和间距中统一使用。
- 调用 并设置
generate-scale-variables:将输出结果展示给用户审核。save: false - 获得批准后,重新调用并设置 。
save: true - 调用 验证结果。
list-global-variables
若要从空站点构建完整设计系统,请使用 bricks-seed-design-system 技能。若要清理现有设计系统,请使用 bricks-audit-design-system 技能。",