# OKLCH Skill: modern CSS colours, palettes and contrast (jakubkrehel/oklch-skill) — skill card for AI agents

> AgentGid skill card. Checked on 2026-11-21 against commit 0e81f04.
> Every fact comes from the pack's own files at that commit. Numbers marked "as reported" are the author's.
> Human page: https://agentgid.com/skills/jakubkrehel/oklch-skill/

## Explain it to a non-programmer
A colour guide for your AI assistant. It moves the colours in your site's styles to OKLCH, a newer way of writing colours where the numbers match what the eye sees. It also builds colour scales, fixes text that is hard to read and sets up themes for Tailwind CSS.

## Who it is for
- You want your site's hex, rgb or hsl colours converted to OKLCH
- You need a colour scale from 50 to 950 for a design system or a dark mode
- Some text on your site is hard to read and you want the contrast fixed
- You build with Tailwind CSS v4 and want your own colours in its theme
- Not for: You want the exact numbers computed by a tool: the guide asks the assistant to check them with a real contrast calculation

## What it is
- Kind: knowledge
- License: MIT
- Repository: https://github.com/jakubkrehel/oklch-skill

## What it does
- Converts hex, rgb and hsl colours to oklch(), changing only the colour values and leaving the rest of the CSS as it was
- Builds 5, 9 or 11 step palettes (50 to 950) by spreading lightness evenly and keeping each step within what screens can show
- Builds several hues with the same lightness and the same share of maximum vividness, so they look equally bright
- Makes dark mode by reversing the palette: the lightest step becomes the darkest
- Checks contrast with APCA by default and WCAG 2 for formal compliance, and fixes it by moving lightness only
- Spots hue drift in old HSL palettes: more than 10 degrees of spread between steps
- Clamps colours that are too vivid for ordinary screens and adds Display P3 and older-browser fallbacks
- Writes Tailwind CSS v4 @theme colour scales in oklch
- Never cuts: CSS keywords (currentColor, inherit, initial, unset, transparent), gradient interpolation methods and colours in third-party library configs that expect hex

## Skills
| Skill | Call | Changes code? | In plain words |
|---|---|---|---|
| oklch-skill | plain language ("Convert the colours in this file to OKLCH"); it also starts on words like oklch, palette, contrast, gamut, dark mode colors | yes | Rewrites, builds and checks the colours in your site's styles |

### oklch-skill
- Asks for: Your stylesheet, Tailwind theme or a base colour
- Asks for: Palette size you want: 5, 9 or 11 steps
- Asks for: The text colour and the background it sits on, for a contrast check
- Gives: A Before / After table of every changed colour
- Gives: Colours as oklch(L C H) values
- Gives: A palette as CSS variables --color-50 to --color-950, or a Tailwind @theme scale
- Gives: Fallback CSS for Display P3 screens and for browsers without oklch
- Say: "Convert all colours in styles.css to OKLCH and build a 9-step palette from my brand blue"

## Know before installing
- It switches on by itself when you mention colour words such as palette, contrast ratio, design tokens or dark mode colors.
- It treats hex, rgb and hsl colours in new code as a mistake and converts them to oklch().
- Only markdown: no scripts ship with it, so the assistant works out the colour numbers itself. The guide says its contrast rules are approximations.
- It uses APCA contrast by default; WCAG 2 is still needed when you must claim formal WCAG conformance.
- The author's interactive OKLCH tool is at oklch.fyi.

## Install (official commands)
- Agents supported by the skills.sh tool: `npx skills add jakubkrehel/oklch-skill` — The skills tool copies the skills/oklch-skill folder (SKILL.md plus four reference files) into your agent's skills folder. Remove: `delete the oklch-skill folder from your agent's skills folder`.

## What runs on the user's machine
- Code on the machine: no
- Network: none
- Install: Five markdown files: SKILL.md and four reference files. No hooks, no scripts.
- At work: Tells the assistant to edit colour values in your CSS and Tailwind theme files.

## Examples (from the pack's own files)
- The skill's own Before / After review table: output format defined in skills/oklch-skill/SKILL.md
- Converting a stylesheet's colours: output format defined in skills/oklch-skill/color-conversion.md

## Mistakes to avoid
- Not: Fix failing contrast by making the text colour less or more vivid. Instead: Change only the lightness (L) of the text, keep chroma and hue. Why: The skill says chroma has almost no effect on contrast
- Not: Trust the assistant's contrast numbers as final. Instead: Check the final pair with a real contrast calculator or a library such as Color.js. Why: The pack ships no code; its lightness gaps are approximations
- Not: Use the same absolute chroma for every hue in a multi-hue palette. Instead: Use the same percentage of each hue's maximum chroma. Why: Hues have different maximum chroma at the same lightness, so equal C looks unequally vivid
- Not: Convert hex colours inside third-party library configs too. Instead: Leave colours that a library expects as hex alone. Why: The skill lists them under what to leave alone
- Not: Ship a high-chroma P3 colour with no fallback. Instead: Put an sRGB value first and the P3 value inside @media (color-gamut: p3). Why: Not every P3 colour exists in sRGB, so it clips on ordinary screens

## May I use it like this?
- commercial-app: yes (MIT)
- client-work: yes (MIT)
- redistribute-files: conditions (MIT: keep the copyright and permission notice in copies of the skill files)

## Which one to pick
- If You need colour work in OKLCH: conversion, palettes, contrast, gamut fallbacks, Tailwind v4 themes: skill:jakubkrehel/oklch-skill
- If You want a full design review of UI code with WCAG accessibility checks, not just colours: skill:rams-design/rams-plugin
- If You want overall art direction and taste for the interface, beyond colour values: skill:Leonxlnx/taste-skill

## Works well with
- tool:colorjs-io: Computes OKLCH conversions, P3 gamut and contrast exactly, which the skill asks to verify with a real calculation
- asset:tailwind-css-colors: Tailwind's default palette is in OKLCH; the skill writes custom @theme scales in the same convention
- tool:axe-core: Automated WCAG checks on the rendered page after colours change

## Works in and needs
- Works in Agents supported by the skills.sh installer: skills folder
- Needs Node.js (for npx): The documented install runs the skills tool through npx

## How to tell it works
Say "Convert the colours in my CSS to OKLCH and check the contrast of my body text". It works if the reply is a Before / After table and the new values look like oklch(0.623 0.188 259.815).
