{"data":{"slug":"discovered-67b8e67590f5d610c04af64f8d9dd4027ff415e7f184f7be","title":"Koi Foundation Health","summary":"Read-only health check of the design-system foundation in app\/globals.css. Reports incomplete color scales, channels out of sync, semantic aliases that collapse into a parallel ramp, loose hex values, contrast of the existing fg\/bg pairs (WCAG and APCA, light and dark), typography drift and the font contract. Edits nothing and proposes no new values; approved fixes go to koi-foundation-update.","url":"https:\/\/skillshunter.net\/skills\/discovered-67b8e67590f5d610c04af64f8d9dd4027ff415e7f184f7be","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-67b8e67590f5d610c04af64f8d9dd4027ff415e7f184f7be","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-67b8e67590f5d610c04af64f8d9dd4027ff415e7f184f7be.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-67b8e67590f5d610c04af64f8d9dd4027ff415e7f184f7be\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before running the checks, ensure that the `app\/globals.css` file is accessible and contains the required sections: `@theme`, `:root`, `.dark`, type recipes, and `--font-*` definitions. The report must be delivered without editing any file. If a delta is approved, direct the user to `koi-foundation-update` for implementation.","instructions":"---\nname: koi-foundation-health\ndescription: >\n  Read-only health check of the design-system foundation in app\/globals.css.\n  Reports incomplete color scales, channels out of sync, semantic aliases that\n  collapse into a parallel ramp, loose hex values, contrast of the existing\n  fg\/bg pairs (WCAG and APCA, light and dark), typography drift and the font\n  contract. Edits nothing and proposes no new values; approved fixes go to\n  koi-foundation-update. Use for \"\/koi-foundation-health\", \"is my\n  foundation healthy\", \"audit the tokens\", \"check contrast of my palette\".\n---\n\n# Koi Foundation Health\n\nA read-only diagnosis of the foundation that already exists. Sibling of\n`koi-foundation-update` (which applies an approved delta) and of\n`koi-design-system-foundation` (which bootstraps). This skill is **not** a\nthird skill allowed to edit tokens.\n\nUse it to organize, audit or explain the health of the foundation: an\nincomplete color scale, a semantic alias, the contrast of pairs already\ndefined, typography outside the local contract. Do not use it to sweep\ncomponents, showcases or pages: that is `koi-design-system-audit`.\n\n## Hard rules\n\n- Do not edit `app\/globals.css`, the foundation pages or any token. Do not\n  propose a hex to fill a missing step.\n- Do not treat a shadcn or component compatibility alias as a defect. An alias\n  may point at a semantic role (`foreground` \u2192 `fg-primary`); what it may not\n  be is a second ramp running parallel to `fg-*`.\n- Do not install a design-token generator, do not move the source of truth to\n  DTCG JSON, and do not rewrite the palette in OKLCH. The source of truth stays\n  the CSS.\n- Classify each finding as `safe`, `needs review` or `breaking`, with the same\n  meaning as in `koi-foundation-update`.\n- Whoever applies a delta is `koi-foundation-update`, and only after explicit\n  approval of the `needs review` and `breaking` items.\n\n## Where to read\n\nOnly these parts of `app\/globals.css`:\n\n- `@theme`: the primitive scale (`--color-au-*` in the shipped foundation),\n  semantic `--color-*`, authored `--text-*`\n- `:root`: the primitive mirror (`--au-*`) and the light semantic layer\n- `.dark`: the semantic reassignment\n- the type recipes: `@utility display-*`, `body-*`, `koi-eyebrow`, and any\n  other recipe the foundation declares\n- `--font-*` in `@theme` and `:root`, the comment at the top of the file, and\n  the family rules in `@layer base` (`code`, `pre`, `kbd`, `samp`)\n\nOutside the CSS, only how fonts are loaded in `app\/layout.tsx` (`<link>` tags\nor `next\/font`).\n\nDo not sweep product pages, `.next\/`, `node_modules\/` or the bridges.\n\n## The yardstick\n\nThe foundation is a three-layer model: primitive scale, semantic role\n(`fg-*`, `bg-*`, `border-*`, `accent-*`, `ring-*`) and component\/shadcn alias.\nHealth measures holes and collapse; it does not ask for a new system.\n\n- A 12-step scale in the format already used (the shipped one is 100\u20131200),\n  in the spirit of [Radix Colors](https:\/\/www.radix-ui.com\/colors). Alpha is\n  not required.\n- Theme colors enter by live reference (`var()`), as in\n  [Tailwind v4 theme](https:\/\/tailwindcss.com\/docs\/theme) and\n  [shadcn theming](https:\/\/ui.shadcn.com\/docs\/theming).\n- Names by role, not appearance:\n  [Naming Tokens](https:\/\/medium.com\/eightshapes-llc\/naming-tokens-in-design-systems-9e86c7444676).\n- Normal text contrast: [WCAG 2.2 1.4.3](https:\/\/www.w3.org\/WAI\/WCAG22\/Understanding\/contrast-minimum.html)\n  \u2265 4.5:1. A second reading in [APCA](https:\/\/git.apcacontrast.com\/documentation\/APCAeasyIntro.html)\n  (0.0.98G): a pair misses the floor when `|Lc| < 60`. Never suggest the\n  replacement color.\n- Typography: a composed recipe carries no color; body text has leading\n  \u2265 1.5. Two rules are house rules, not WCAG, and the report says so: a size\n  under 12px is a broken floor (WCAG sets no minimum size), and an authored\n  size in `px` does not follow the default font size a person chose in the\n  browser. `px` does **not** fail [WCAG 1.4.4](https:\/\/www.w3.org\/WAI\/WCAG22\/Understanding\/resize-text.html):\n  browser zoom meets the criterion. Never write \"violates WCAG\" for these two.\n\n## Checks\n\n### 1. Primitive scales\n\nList the color families the foundation declares (the shipped neutral\nfoundation has ten: `gray`, `blue`, `emerald`, `red`, `purple`, `amber`,\n`pink`, `lime`, `slate`, `teal`).\n\nRequired steps, in the shipped format: `100` to `1200` in hundreds. Optional,\nso their absence is not a finding: `25`, `50`, `150`. Outside the scale\ncontract: `white`, `black`, and any chart or illustration palette.\n\nFor each family, compare `--color-au-{family}-{step}` in `@theme` with\n`--au-{family}-{step}` in `:root`.\n\n- A required step missing in both channels: `needs review`. Group by family.\n  Do not invent the hex; the value is a scale decision.\n- A step present in one channel and missing in the other, or a different hex\n  between the channels: `needs review`.\n\n### 2. Aliases and loose hex\n\nAn alias whose value is a `var()` to a semantic role passes. Findings:\n\n- `--color-text-*` (or any similar ramp) whose value is only `var(--fg-*)`,\n  with no role `fg-*` lacks: `needs review`. Removing the name, if it is in\n  use, would be `breaking`: file it as `needs review` and note that removal\n  needs a usage check first.\n- `--color-*` in `@theme` with a literal hex, outside the primitive scale and\n  a chart palette: `needs review`. The primitive scale's hex is the source of\n  truth, not loose.\n\n### 3. Contrast of the existing pairs\n\nResolve the chain down to the hex, in light (`:root`) and dark (`.dark`):\n\n- `fg-primary` on `bg-canvas`\n- `fg-secondary` on `bg-canvas`\n- `fg-tertiary` on `bg-canvas` (eyebrows and metadata)\n- `fg-muted` on `bg-canvas`\n- `fg-on-inverse` on `bg-inverse`\n\nCreate no new pair. Compute WCAG and APCA with the snippet below, in a\nread-only `node` run, without writing a script into the repository. File a\n`needs review` only when a pair is under 4.5:1 or `|Lc| < 60`. In the report,\nshow all ten results (five pairs \u00d7 two themes), including the ones that pass.\n\nWCAG 1.4.3 exempts the text of a disabled component. If the token's comment\nsays the role is only for disabled or decorative use, record the exemption in\nthe finding; without that comment, treat it as readable text.\n\n```js\nfunction lin(c) {\n  const x = c \/ 255;\n  return x <= 0.04045 ? x \/ 12.92 : ((x + 0.055) \/ 1.055) ** 2.4;\n}\nfunction luminance(hex) {\n  const n = parseInt(hex.slice(1), 16);\n  const r = (n >> 16) & 255, g = (n >> 8) & 255, b = n & 255;\n  return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);\n}\nfunction wcag(a, b) {\n  const L1 = luminance(a), L2 = luminance(b);\n  const [hi, lo] = L1 > L2 ? [L1, L2] : [L2, L1];\n  return (hi + 0.05) \/ (lo + 0.05);\n}\nfunction y(hex) {\n  const n = parseInt(hex.slice(1), 16);\n  const ch = (c) => {\n    const x = c \/ 255;\n    return x <= 0.04045 ? x \/ 12.92 : ((x + 0.055) \/ 1.055) ** 2.4;\n  };\n  return 0.2126729 * ch((n >> 16) & 255) + 0.7151522 * ch((n >> 8) & 255) + 0.072175 * ch(n & 255);\n}\nfunction apca(text, bg) {\n  const clamp = (Y) => (Y >= 0.022 ? Y : Y + (0.022 - Y) ** 1.414);\n  const Yt = clamp(y(text)), Yb = clamp(y(bg));\n  if (Math.abs(Yb - Yt) < 0.0005) return 0;\n  if (Yb > Yt) {\n    const sapc = (Yb ** 0.56 - Yt ** 0.57) * 1.14;\n    return (sapc < 0.1 ? 0 : sapc - 0.027) * 100;\n  }\n  const sapc = (Yb ** 0.65 - Yt ** 0.62) * 1.14;\n  return (sapc > -0.1 ? 0 : sapc + 0.027) * 100;\n}\n```\n\n### 4. Typography\n\nGroup by cause. Do not open one finding per recipe.\n\n- A recipe whose block declares `color:`: `needs review`. Color belongs to the\n  `fg-*` channel.\n- An authored size token under 12px, and the recipes that consume it:\n  `needs review`, unless a comment beside the token records an approved\n  exception (for example, chips and counters). Say which exception you\n  accepted.\n- A `body-*` recipe with a numeric `line-height` under 1.5: `needs review`.\n  Display, heading and UI recipes are outside this rule.\n- Authored text size tokens declared in `px`: one `needs review` finding.\n  Changing the unit does not change the pixel at a 16px root; it changes the\n  response to the font-size preference. It is good practice, not a WCAG\n  violation. Do not rewrite the values.\n\n### 5. Fonts\n\n- Every family named in `--font-*` (`@theme` and `:root`) needs a load path in\n  `app\/layout.tsx`. A family declared and never loaded: `needs review` (it\n  falls silently to the fallback stack). A different stack between the two\n  channels: `needs review`.\n- List what consumes `var(--font-mono)` among recipes and base rules. Code\n  (`code`, `pre`, `samp`, code recipes) passes; anything else (keyboard\n  shortcuts, IDs, numbers): `needs review`. Numbers that must align use\n  `tabular-nums` on the text family.\n- If the foundation restricts a display family to display recipes, list what\n  consumes it; any other consumer is `needs review`.\n- A comment in `globals.css` that describes font usage differently from the\n  contract: `safe` (documentation only).\n- Font use on product pages is not this skill's: point at\n  `koi-design-system-audit`.\n\n## Classification\n\n- `safe`: documentation, or a mirror\/alias that changes no value in use. Zero\n  visual change. In this skill `safe` only applies when the fix moves no\n  value. Do not apply even the `safe` ones.\n- `needs review`: a missing required step, channels out of sync, a parallel\n  `text-*` ramp, a loose hex, a contrast pair under the floor, color inside a\n  recipe, a size under 12px, `body-*` leading under 1.5, a scale in `px`, a\n  family never loaded, mono outside code.\n- `breaking`: only when the single fix is to remove or rename a token in use.\n  Do not classify a whole finding as `breaking` while an additive alternative\n  exists; add the caveat.\n\n## Workflow\n\n1. Read the parts of `app\/globals.css` listed above.\n2. Run the five checks. Contrast comes from the read-only `node` run.\n3. Deliver the report and stop. Edit no file.\n4. If the user approves a delta, end here and point at\n   `koi-foundation-update`. Do not apply it yourself.\n\n## Output\n\nA report, in this order:\n\n- Checked: complete families, aliases that passed, contrast pairs that passed\n  (with the ratio and the Lc).\n- Findings, grouped by `needs review`, `breaking` and `safe`. Each finding\n  names the token or recipe, what failed, and that no new value was proposed.\n- Outside this skill: applying belongs to `koi-foundation-update`; recipe\n  coverage in the styleguide belongs to `npm run ds:check` and\n  `koi-design-system-audit`.\n- Files edited: none.\n","use_cases":["Check if the foundation is healthy","Audit the tokens in the design system","Verify contrast of the palette","Ensure typography and font rules are consistent"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/MirandaSls\/koi-design\/blob\/d86c88cb439045af1785329fcabfbd645fa3b646\/skills\/design-system\/koi-foundation-health\/SKILL.md","source_commit":"d86c88cb439045af1785329fcabfbd645fa3b646","license":null,"version":null,"listing_approved_at":"2026-11-29","created_at":"2026-11-28T18:44:16.000000Z","updated_at":"2026-11-29T10:53:15.000000Z","seo_title":"Koi Foundation Health Check","seo_description":"A read-only health check for the design-system foundation in app\/globals.css. Identifies issues with color scales, semantic aliases, contrast, typography, and font rules.","seo_keywords":["design system audit","color scale check","semantic alias validation","contrast verification","typography drift detection"]}}