Colore JS

Search documentation

Find a function or jump to a section.
v2.0.1

Coding agents and CLI

The Colore skill lets you ask your coding agent for color changes in plain words. The agent uses the colore-js CLI to inspect your theme, compute colors, and check contrast in each theme mode. It can also move hard-coded component colors onto theme tokens so they follow the theme.

Install the skill

npx colore-js init

This copies the skill into .agents/skills/colore (read by Cursor, Codex and other Agent Skills clients) and .claude/skills/colore (Claude Code). With the skills CLI you can also run npx skills add mallikcheripally/colore-js.

Try one of these requests in your coding agent.

  • "Rebrand the app to our logo" (attach or point to logo.svg / logo.png)
  • "Add dark mode" or "add chart colors"
  • "The gray text is hard to read"
  • "Make it feel warmer", "more premium", "less like every other AI app"
  • "Make the primary exactly #0f766e"

For larger edits, the skill asks the agent to generate a before-and-after preview before writing changes. The agent finishes by running a contrast audit and reporting what changed and any issues that remain.

CLI

Run the same commands yourself or in CI. Commands that edit a stylesheet leave it on disk as-is until you pass --write.

npx colore-js inspect
npx colore-js theme "#0f766e" --apply app/globals.css --add --preview preview.html
npx colore-js theme "#0f766e" --apply app/globals.css --add --write
npx colore-js adjust app/globals.css --groups surfaces --hue 70 --chroma 0.008 --write
npx colore-js audit app/globals.css
CommandWhat it doesExit code
inspect [dir]Finds the theme file and reports its format, modes, brand, missing tokens, contrast issues and hard-coded component colors with available token suggestions.0
theme [brand] --apply <file>Applies generated colors to recognized shadcn/ui, Tailwind and plain CSS tokens in their existing formats. --only <groups> narrows the edit. Omit the brand with --add to fill gaps using the existing brand.1 if contrast still fails
adjust <file>Moves colors in OKLCH for --groups or --tokens. A number sets a channel, a signed value shifts it, and x scales it.1 if contrast still fails
set <file> <token>=<color>Sets tokens to exact colors in the file's format.1 if contrast still fails
extract <image>Extracts brand and neutral colors from an SVG or PNG.0
preview <file>Generates an HTML preview of sample UI in light and dark. --compare <old.css> adds the previous theme.0
theme <brand>Generates a contrast-checked light and dark theme. Use --format to select an export.0 on success
check <fg> <bg>Checks one color pair using WCAG 2 or APCA. For a failing pair, it suggests a passing foreground when available.1 on failure
audit <file|->Checks inferred text/background pairs, such as --x / --x-foreground, and pairs passed with --pair fg:bg.1 on failure
fix <file|->Rewrites only failing foreground values, keeping each value's format. Prints to stdout unless --write.1 if issues remain
init [dir]Installs the Colore skill for coding agents.0
  • theme --apply --add can add a missing dark block, chart-1 through chart-5, and destructive tokens. Use --only status with --add to add success and warning tokens.
  • adjust --groups supports surfaces, text, brand, accent, borders, status, charts and other.
  • theme --format supports shadcn (the default, in OKLCH), shadcn-hex, shadcn-hsl (v3 bare HSL channels), css, tailwind, json and dtcg.
  • check --intent supports text, largeText, ui and focus. Select --algorithm wcag2 or --algorithm apca, then use --level aa, --level aaa, or --target <ratio or Lc>.

Every command accepts --json for machine-readable output. Edit commands (theme --apply, adjust, set) repair contrast by default, accept --no-fix to skip repair, and can write a before-and-after page with --preview <file.html>.

The brand color stays the brand color

theme keeps your brand color exactly as --primary when it meets the contrast target with white or black text, and picks a readable foreground. In a dark theme, the brand also needs enough contrast against dark surfaces. When Colore needs an accessible shade, it selects one from the generated scale. Use --no-preserve-seed to use the generated scale regardless of the seed's contrast. See generateSystem for details.

Minimal-change fixes

Fixes keep hue and move lightness only as far as needed:

$ npx colore-js check "#3b82f6" "#fff"
#3b82f6 on #ffffff: 3.68:1 FAIL (text needs 4.5:1)
Nearest passing: #2c72e5 (4.52:1)

When a foreground is paired with several backgrounds (for example --muted-foreground on both --muted and --background), the suggestion must pass on all of them. If no single value can, the audit says which backgrounds conflict instead of guessing.

How audit reads CSS

  • Values may be hex, rgb(), hsl(), oklch(), any CSS Color 4 format, or shadcn/ui v3 bare HSL channels (222.2 84% 4.9%).
  • var() references are resolved where they are declared, like the browser: an inherited --card: var(--background) keeps the :root value inside .dark.
  • Foregrounds that are var() references or only inherited are reported as not auto-fixable, with a note.

Docs for agents

  • llms.txt: an index of every current page, with the conventions that differ from other color libraries.
  • llms-full.txt: every page as Markdown in one file.
  • Any docs page is also served as Markdown at its URL plus .md, for example https://colorejs.dev/docs/agents.md.

Library equivalents

import {
  generateSystem, auditCssVariables, fixCssVariables, ensureContrast,
  inspectCssTheme, applyThemeToCss, adjustCssVariables,
} from 'colore-js';

const globalsCss = generateSystem('#7c3aed').toShadcnCss({ format: 'oklch' });
// The report describes the theme type, color format, modes, brand, and missing parts.
const theme = inspectCssTheme(globalsCss);
const rebranded = applyThemeToCss(globalsCss, generateSystem('#0f766e'), { add: true }).css;
const warmer = adjustCssVariables(globalsCss, { groups: ['surfaces'], hue: 70, chroma: 0.008 }).css;
const report = auditCssVariables(globalsCss, { level: 'aa' });
const { css: fixed, changes } = fixCssVariables(globalsCss);
const { color } = ensureContrast('#777777', '#ffffff');
console.log(color.hex()); // #767676

See inspectCssTheme, applyThemeToCss and adjustCssVariables for the theme-file API references.