Communitygithub.com

oklch-palette-formula

OKLCHベースのニュートラルパレット生成フォーミュラ。グラウンド、サーフェス、ライン、インク/テキストを、数十の手動選択hex値ではなく、少数の入力値からOKLCH計算式で生成します。ライト/ダークテーマ、ステップごとのラダーオーバーライド、既存色の再現フィットスクリプト、ブラウザコントラスト監査を備えています。テーマ作成、ダークモード追加、プロダクトの再着色、テキストコントラスト監査、複数アプリのパレット統合に使用します。

oklch-palette-formula とは?

このスキルは、UIのニュートラルカラーパレット(ページ背景、カード表面、フィールド、罫線、テキスト)を、OKLCH色空間の数式として定義・生成するためのフレームワーク「OKLCH Palette Formula」を提供します。従来のように数十個のhex値を目視で選ぶ代わりに、色相、明度、クロマ(彩度)という少数のパラメータを調整するだけで、ライトテーマとダークテーマの両方の一貫したパレットを生成できます。Pythonスクリプトで既存のhexパレットからフィッティングし、ΔE誤差を評価できます。また、ブラウザ上ですべてのトークン間のWCAGコントラスト比を自動監査し、不合格箇所を報告します。Tailwind CSS v4の`@theme`との統合もサポートしており、プロダクトの再着色やダークモード追加、複数アプリのパレット統一に特に有用です。このフレームワークは、色の設計プロセスを数学的に体系化し、手動調整と矛盾を排除します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Adamparishspok/skills/tree/HEAD/skills/oklch-palette-formula

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

OKLCHパレットフォーミュラ

プロダクトのニュートラルカラー(ページ背景、カード表面、フィールド、罫線、4段階のテキスト)は、通常テーマごとに15~30個のhex値が目視で選ばれています。それらは徐々にずれていき、ダークモードはもうひとつの手動選択セットとなり、どのペアがまだコントラストを満たしているのか誰もわかりません。それらを数式に置き換えましょう:

surface-ish token:  L = paper + depth  × n(token)     chroma = tint      hue = hue
ink token:          L = ink   + step   × n(token)     chroma = ink-tint  hue = hue

n(token) はトークンのラダー上の位置で、ラダーはテーマごとに1つです。1つの入力を動かすとランプ全体が連動して動くため、コントラストが生まれるステップ間のギャップは再着色後も維持されます。プロダクトの再着色は、1行(--hue)で完了します。

3つのノブ(--hue、--lightness、--chromaまたは--contrast)がすべての色を駆動します。

ファイル

  • references/palette.css:スターター入力値とラダーを備えたドロップインルール。
  • scripts/fit_palette.py:既存のhexパレットに入力値をフィッティングし、トークンごとのΔEを出力します。
  • scripts/ladders.json:デフォルトのラダー(ライト、ダーク)。
  • scripts/palette-audit.mjs:実際のブラウザで両テーマのすべてのトークンを解決し、コントラスト違反を報告します。
  • scripts/oklch.py:色変換とΔE/WCAGヘルパー関数。

手順

  1. トークンは役割で名前付けし、値では行わない。 デフォルトの例:

    • グラウンド: ground(ページ)、panel(レール、バー)、surface(カード、メニュー)、surface-2(フィールド)、surface-3(チップ、ホバー行)、field。
    • ライン: line、line-2、line-3(罫線、最も薄いものから濃いものへ)、さらに field-line(コントロールの枠線、3:1を満たす必要あり)。
    • インク: ink、ink-2、ink-3、ink-4(テキスト、最も濃いものから控えめなものへ)。インクステップはすべてテキスト用のため、それぞれ4.5:1を満たす必要があります。
  2. 再選択ではなくフィッティングする。 既存プロダクトでは、python3 scripts/fit_palette.py theme.css を実行します。これは --color-* hex宣言(ライト、次に [data-theme="dark"] ルール)を読み取り、デフォルトラダーに対して入力値をフィッティングし、トークンごとのΔEを出力します。ΔEが2未満であれば視覚的に同一とみなせます。

  3. デザインがステップ間の間隔を異なるように設定している場合は、色ではなくラダーステップをオーバーライドします。 候補を評価するには、fit_palette.py theme.css light '<inputs>' '<overrides>' を実行し、最大ΔEが約2以下になるまで調整します。一般的なオーバーライド例:field: 0(フィールドはカード表面と同じ)、より広い line-3、ink と ink-2 の間のより大きなギャップ。

  4. ルールを記述する(references/palette.css を参照):

    • テーマ属性を持つ要素に入力値と --color-* 数式を配置します。
    • ダークルールで変更した入力値をすべて再宣言します。キットのデフォルト用に書かれたダークルールは、そうしないと 自身の 値で上書きされます。
    • Tailwind v4では、ユーティリティが存在するように @theme 内にトークン名を保持します。実行時の宣言がそれらを上書きします。
  5. 実際のブラウザで監査する: node scripts/palette-audit.mjs <url>。すべてのトークンを描画し、sRGBを読み取り、以下をチェックします:

    • すべてのインクステップがすべてのグラウンドに対して4.5:1であること。
    • field-line と ring が3:1であること。

    不合格(FAIL)は、そのトークンのラダーステップを移動させることで修正します。色を特殊ケース化してはいけません。既存パレットではFAILが予想されます。17アプリの移行では、監査により半数以上のアプリで ink-4 または field-line の値が不合格となり、それらはすべて以前に出荷されていたものです。

注意点

  • カスタムプロパティ内の var() は、それが宣言された場所で解決されます。
    • 数式を :root に宣言し、子要素に入力値を設定すると、子要素は再色付けされません。
    • エイリアストークン(--color-heading: var(--color-ink))も、同じテーマ要素で宣言する必要があります。
  • Tailwind v4の @theme 値は :root 上に存在します。 アプルート([data-app])にスコープされたテーマは、@theme ではなくその場所で数式を宣言する必要があります。
  • canvasや地図ライブラリに色を渡すもの(getComputedStyle(...).getPropertyValue('--color-x'))は、未解決の oklch(calc(...)) 文字列を受け取ります。まず解決してください。プローブ要素を描画し、監査と同様の方法で1pxのcanvasから読み取ります。
  • グラウンドとインクに同一の色相。 デザインのインクがグラウンドと異なる色相を持つ場合は、--ink-tint を低く抑えます。Lが0.98の場合、どのクロマも色かぶりとして認識されます。
  • ブランド、ステータス、チャートの色は数式の外に維持します。 テキストオンカラーのバリエーション(例:brand-text)は、別々に選ぶのではなく、同じ色相で固定明度から導出します。
  • 混合色相でライト専用のパレットをコンポからサンプリングした場合、ΔE約2以内に収まらない可能性があります。 デザインを歪めるよりはスキップしてください。監査は引き続き適用されます。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

Adamparishspok/skills

Make a website, web app or online store ready for AI agents. Scan it with Cloudflare's Agent Readiness checks, decide which checks apply to this kind of site, ship the discovery files and headers in priority order, and add the AI-first basics the scanner does not score (server-rendered content, JSON-LD, llms.txt). Covers robots.txt AI rules, Content Signals, sitemap, Markdown for Agents (Accept text/markdown), Link headers, API catalog, OAuth discovery, auth.md, MCP server card, A2A agent card, agent skills index, WebMCP, and commerce protocols (ACP, UCP, AP2, MPP, x402). Use when making a site AI-ready, agent-ready or AI-first, or fixing an isitagentready.com or Cloudflare Agent Readiness report. Triggers on: AI ready, agent ready, AI-first, agent readiness, isitagentready, AI Crawl Control, Markdown for Agents, text/markdown, llms.txt, GPTBot, ClaudeBot, AI crawlers, Content-Signal, ai-train, api-catalog, .well-known, oauth-protected-resource, auth.md, MCP server card, agent card, agent skills, WebMCP, a...

Adamparishspok/skills

Install a complete, lean favicon set on any website or web app — the five files modern browsers, iOS and Android actually use, one block of head markup added once in the root layout, and a check that every file resolves. Covers finding the public folder per framework, generating the set from one SVG (or from a RealFaviconGenerator package), dark-mode SVG icons, maskable manifest icons, cache busting and verification. Use when adding, replacing or auditing a favicon, app icon, apple-touch-icon or web manifest. Triggers on: favicon, favicon.ico, favicon.svg, apple-touch-icon, site.webmanifest, manifest.json, app icon, PWA icon, maskable icon, tab icon, RealFaviconGenerator.

Adamparishspok/skills

Give an interface one shared tempo and a small vocabulary of hover and state micro-interactions: duration tiers (tap/pop/hover/card/layout) for CSS and Motion, swap hand-offs, rows whose highlight grows in, trailing arrows, chevron nudges, card lifts without translate, scroll-edge fades, and icon/label swaps for copy and toggle buttons. Use when animations feel inconsistent, durations are scattered magic numbers, hovers only change colour, or a product feels flat or unfinished. Triggers on: animation duration, transition timing, hover state, micro-interaction, polish, copy button feedback, menu icon to close, back arrow, card hover, scroll fade, motion tokens, Framer Motion durations.

Adamparishspok/skills

Consolidate several apps or prototypes onto one shared component library without flattening their looks. Covers finding duplicated local components (buttons, selects, fields, modals, pagers, toasts), making shared components token-sized so each suite or app sets its own measurements, mapping variant names, deciding what stays app-specific, and the tailwind-merge traps that silently break custom tokens. Use when several apps each grew their own Btn/Select/Modal, when a design system's components "don't fit" a second product, or when retheming a family of apps. Triggers on: shared component library, design system consolidation, duplicate components, retheme, suite of apps, shadcn retokened, token-driven components, cn tailwind-merge custom tokens, variant mapping.

関連スキル