Skip to content

Adonis0123/adonis-skills / skills/design-system

design-system

Verified

Run a shared multi-site design system where every product swaps only its interface accent color: analyze any website's theme colors and roles, wire a new site or plugin to the semantic tokens, and lint plugins for hard-coded colors, fallback values and unknown roles. Use when the user gives a URL and asks what its theme or palette is, asks to connect a site to the design system, add an accent theme, or check whether a plugin follows the theme contract. Skip one-off styling tweaks, logo or illustration work, and plugin-architecture refactors (code-plugin-architecture).

FileKindSize
SKILL.mdskill md9.6 KB
references/token-format.mdmarkdown3.2 KB
scripts/check_tokens.pyscript5.6 KB
scripts/lint_plugin.pyscript2.8 KB
scripts/test_check_tokens.pyscript2.6 KB

scripts/lint_plugin.py

View on GitHub
#!/usr/bin/env python3
"""检查插件是否守主题契约:不写死色值、var() 不带后备色、只用设计系统里有的角色。

  python3 lint_plugin.py <插件目录或文件> [--tokens <tokens.json>]

有问题时逐条输出“文件:行 — 问题 — 改法”并退出 1。同一行写 design-system-ignore 可跳过(写明原因)。
"""
import json
import re
import sys
from pathlib import Path

EXTS = {".css", ".scss", ".less", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".vue", ".svelte", ".html"}
SKIP_DIRS = {"node_modules", "dist", "build", ".git", ".next", "coverage", "generated"}
COLOR = re.compile(
    r"(?<![\w&/-])#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})\b(?![\w-])"
    r"|\b(?:rgba?|hsla?|oklch|oklab|lab|lch)\(\s*[\d.]"
)
VAR = re.compile(r"var\(\s*--([A-Za-z0-9_-]+)\s*(,)?")
IGNORE = "design-system-ignore"


def files(target):
    if target.is_file():
        yield target
        return
    for p in sorted(target.rglob("*")):
        if p.is_file() and p.suffix in EXTS and not SKIP_DIRS.intersection(p.parts) and not p.name.endswith((".test.ts", ".spec.ts")):
            yield p


def main():
    args = sys.argv[1:]
    if not args or args[0].startswith("--"):
        sys.exit("用法:python3 lint_plugin.py <插件目录或文件> [--tokens <tokens.json>]")
    target = Path(args[0])
    roles = None
    if "--tokens" in args:
        tokens = json.loads(Path(args[args.index("--tokens") + 1]).read_text())
        roles = set().union(*(set(r) for r in tokens["roles"].values()))
    problems = []
    for f in files(target):
        for n, line in enumerate(f.read_text(errors="ignore").splitlines(), 1):
            if IGNORE in line:
                continue
            for m in COLOR.finditer(line):
                problems.append(f"{f}:{n} — 写死了色值 {m.group(0).rstrip('( ')} — 换成语义角色 var(--<角色>);确实要固定(如 logo)就在行尾注释 {IGNORE} 并写原因")
            for m in VAR.finditer(line):
                name = m.group(1)
                if m.group(2):
                    problems.append(f"{f}:{n} — var(--{name}, …) 带了后备色 — 删掉逗号后的值,让漏接主题时显眼地坏掉")
                if roles is not None and name not in roles:
                    problems.append(f"{f}:{n} — --{name} 不是设计系统的角色 — 换成 tokens.json roles 里已有的角色;确实缺就先在设计系统加角色")
    if problems:
        print("\n".join(problems))
        print(f"\n不通过:{len(problems)} 处。脚本只定位候选,logo、插画、截图里的颜色逐条判断。")
        sys.exit(1)
    print(f"通过:{target} 没有写死的色值、后备色" + ("或未知角色" if roles is not None else ""))


if __name__ == "__main__":
    main()
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall