Communitygithub.com

three-color-rule

Give a web page three color roles with one job each (base, brand, spark) and keep the spark for the single action the visitor should take. Use when building a new page, landing or app screen and nobody has chosen colors, when a page looks flat, grey or noisy with color, or when asked to audit or check a page's palette, accent color, call-to-action color or text contrast. Works in two modes, create and audit, and ships 100 script-checked palettes for projects with no colors yet. It only decides color. It is not a general design skill.

three-color-rule란 무엇인가요?

three-color-rule is a Claude Code agent skill that give a web page three color roles with one job each (base, brand, spark) and keep the spark for the single action the visitor should take. Use when building a new page, landing or app screen and nobody has chosen colors, when a page looks flat, grey or noisy with color, or when asked to audit or check a page's palette, accent color, call-to-action color or text contrast. Works in two modes, create and audit, and ships 100 script-checked palettes for projects with no colors yet. It only decides color. It is not a general design skill.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Kioys/three-color-rule/tree/HEAD/skills/three-color-rule

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Three-color rule

A page needs three colors, and each one has a job.

RoleJobWhere it goes
BaseCarry the pageBackground and text, plus the neutrals made from them: surface, muted text, lines
BrandSay whose page this isLogo, links, headings or one band
SparkPoint at the one thing that mattersThe primary action. Almost nowhere else

Pages built without this usually end up with base and brand only. Everything is correct and nothing stands out. The spark makes the main action easy to find, and it only works if it is rare.

What this rests on: in lab studies a uniquely colored item is found fast, and each extra item in that color makes it slower to find. Nothing shows that it raises clicks or sales. Never tell the user that it will. Say "easier to find", not "converts better".

This skill has opinions about color only. In audit mode, touch nothing but color. In create mode you do write the whole page, but keep layout, type and copy plain, and say which content you invented.

Step 1. Know the primary action

The question is:

What is the one action a visitor should take on this page?

Ask only this. Do not ask about favorite colors or style.

  • The user answers, or the request already says it ("a landing to sell my course", "I want people to buy X"): use it and do not ask again.
  • The request only implies it, the user does not answer, or you cannot ask: choose the most likely action and say so. In audit mode read the page first and take the buy, sign up, book or contact control. In create mode infer it from the request ("a page for my baking class" implies booking a seat). Never choose silently. Mark it ASSUMED in the report and invite a correction.
  • The page has no action at all (an article, a docs page): say so. The spark then marks the one main link forward, or is not used.

Step 2. Find the colors that exist

Run the script. It needs Node 18 or newer, has no dependencies, and only reads.

node <this-skill-folder>/scripts/colors.mjs <file-or-folder>...
node <this-skill-folder>/scripts/colors.mjs <path> --uses <token-or-color>...
node <this-skill-folder>/scripts/colors.mjs --contrast <text> <background> [<text> <background>...]
node <this-skill-folder>/scripts/colors.mjs --info <color>...
  • The first form lists color tokens, every distinct color grouped by hue family with file and line, contrast ratios, Tailwind color classes, and what it could not resolve. Add --all to see every location.
  • --uses takes the page's own token names, with their dashes, or hex values: --uses --spark --spark-text or --uses "#e7a52e". It lists CSS rules, not elements.
  • --contrast takes hex values in pairs. --info prints lightness, chroma and hue (L, C, H) of hex values, and the hue distance when you give two. Both work before any file exists.
  • In audit mode, scan the page. In create mode the page does not exist yet: scan the project folder the page will live in (styles, theme files, sibling pages) to see if there is a palette to respect. If that folder does not exist or the script says there is nothing to scan, you are in case 1.
  • Hue numbers are OKLCH hue. The family grouping is a hint, and so is the "used Nx" count, which counts CSS declarations. A very dark or very pale shade of the brand or spark can show up under Neutrals: it still belongs to its role. Roles are your decision.
  • If Node is not available, find colors with search, compute contrast with the formula at the end, and mark those ratios "computed by hand".

Then decide which case you are in:

  1. No colors yet (new project, or only black and white). You choose the three colors, starting from the ready palettes in palettes.md. See "Choosing colors".
  2. The project already has a palette or design system (tokens, a Tailwind theme, a UI kit, brand guidelines, a logo). Keep it. Do not replace or rename its colors. Give roles to what exists. Only when no existing color can do a job, propose one new color for that job, pick it with "Choosing colors", give its hex value, compute its contrast, and say clearly that it is new.
  3. The colors live somewhere you cannot read (a remote theme, a CMS setting, a UI library's defaults, Tailwind's default palette, values set by JavaScript). Name each value you could not resolve and where it is referenced. Do not invent hex values and do not compute contrast for them. You can still check roles and counts by name ("bg-amber-500 is on 7 elements").

Which existing color is which

Go in this order:

  1. Set aside status colors (a hue used only for error, success or warning) and content colors (inside a code sample, a photo, a chart). They are not roles. The script still counts them as hue families.
  2. Base is the page background, the text color, and every low-chroma neutral.
  3. If one hue is left, it is the brand and the spark is missing, even when that hue is on the button. One color cannot say "this is us" and "click here" at once. The fix gives the button to a new spark, and gives the brand a visible job if the button was its only one (logo, links, a heading or a band).
  4. If two hues are left, the spark is the rarer, brighter one that sits on the action. The other is the brand.

The test is the action, not the count. A page does not pass because it already has three colors. It passes when the primary action has a color that nothing else on its screen has. If the buy button is filled with the same color as the text, the action has no color of its own, and that is missing-spark, your first finding, whatever the palette or the brand guidelines say. Read the structure before you count colors: find the primary action on each screen, look at what fills it, and look at what else on that screen uses the same color.

When the project has brand guidelines. Keep their colors and their names. They do not excuse a missing spark. Some brands are neutral on purpose: black and white are the identity, and one hue is a rare accent ("a dot, a line, an icon"). Then:

  • The neutrals are base and brand together. The one hue is the brand's accent. Do not rename it.
  • If the guidelines allow that accent on the action and its label passes L4, it is the spark. Use it.
  • If they do not allow it, or the label cannot pass, the page still needs a spark. Look for one the brand already owns before you invent one: read the brand documents, the brand skill if there is one, and other materials in the repo (social templates, video cards, decks). A color the brand already uses somewhere else is the best candidate. Only if there is none, take one from palettes.md.
  • Recommend it plainly, with its hex value, where it goes (file and line) and its contrast. Say in one line that it adds a color to the page and that the brand owner decides. Do not bury it as an optional last step.
  • If the brand's own documents already say something about that color (for example "this accent is for video only" or "the primary button is white"), quote the line with its file and line number, and list the documents that would have to change together with the page. Still make the recommendation.
  • In a neutral brand, L1b compares the spark with the brand's accent hue, and the 90 degrees of hue is not required for a color the brand already owns.
  • An official red accent is allowed. The "no red spark" rule is for colors you choose, not for a brand's own red. When red is both identity and error state, report the overlap once, without a fix, and check that errors also carry a non-color cue (an icon or a text message).

The limits

L1. Three roles. Every color on the page belongs to base, brand or spark. Shades of one hue count as the same color (a hover shade, a darker spark for text, a dark brand band).

L1b. Brand and spark are told apart by more than hue. About 1 man in 12 confuses red and green, so hue alone is not enough.

  • The brand color and the spark color have a contrast ratio of at least 3:1 with each other. Check with --contrast <brand> <spark>.
  • The primary action is also the only filled button on its screen. Other buttons are outlined or plain text, and the brand never fills a button next to it. A pressed toggle or a selected chip counts as a filled button: show selection with a border instead.
  • If an existing palette cannot reach 3:1 between brand and spark, do not change the palette for that. Report it as weak-pair and make sure the filled-button cue is there. With that cue in place the page still passes: the finding stays in the report and needs no fix.

L2. No fourth color. Outside the three roles only these are allowed:

  • neutrals derived from the base (surface, muted, line, shadow);
  • status colors (error, success, warning), used only to show a status, never as decoration;
  • content with its own colors: photos, third-party logos, code or terminal samples, charts. List them as content. They do not count, but their text must still pass L4.

Browser defaults count too: an unstyled link is blue, then purple. Give links a role color.

L3. Spark budget. The numbers below are a working convention, chosen so they can be counted. Research shows fewer is better and gives no exact maximum. Code cannot see a viewport, so use this counting convention and say you used it: the top of the page (header plus hero) is one screen, each following section is one screen, the footer belongs to the last one.

  • Count rendered elements in the markup, not CSS rules. One rule can color ten elements.
  • Every shade of the spark hue counts, except the ink color used for text on top of a spark fill.
  • At most one spark-filled element per screen, and it is the primary action or leads to it.
  • At most two small spark marks per screen: a highlight or underline on a word, one word or number in a spark shade, a dot, a line up to 4px thick, an icon up to 24px.
  • The primary action is spark-filled on the first screen, and again on every later screen that repeats it. When the same action shows twice on one screen (navigation and hero), the one in the page body gets the spark and the one in the navigation gets the brand color or an outline.
  • No spark on sentences, on secondary links or buttons, or as a section background.
  • The primary action sits in the flow of the content and looks like a button. A colored box set apart from the content, a strip across the top or a block in a side rail reads as an advertisement, and people skip those. Report it as misplaced-spark.
  • A screen with no primary action may have zero spark. That is correct.
  • A fixed bar that only appears after the main button has scrolled away (a sticky buy bar on mobile) counts as its own screen. Buttons that a script adds in another state (a result, an error) are counted in that state, not together with the default one.
  • When the first screen shows the action only as a text link or a label, filling it with the spark is the fix, and you may add the padding it needs to read as a button. That is the one layout change allowed in audit mode. Say that you did it.
  • Hover, focus and text-selection styles do not count toward the budget. They still must pass L4.

L4. Contrast (WCAG 2.x AA).

  • Normal text: at least 4.5:1 against the background it really sits on. This includes hover states.
  • Large text: at least 3:1. Large means 24px and up, or 18.66px and up at weight 700 or more. 1rem is 16px unless the page changes it. For clamp() use the smallest value.
  • Non-text parts that carry meaning, at least 3:1: icons without a text label, form field borders, focus rings.
  • Not required: the edge of a button that has a readable text label, and pure decoration (dots, rules, underlines, card borders). An amber button on an off-white page is fine when its label passes.
  • Compute a ratio only when both values are known. Otherwise write not computed: <reason> (unresolved token, filter, opacity, gradient, image, browser default).
  • The script labels pairs RELIABLE, LIKELY or ASSUMED. Check every ASSUMED line against the markup before you use it, passing or failing, and recompute with --contrast. The script does not list text that inherits its color: add the pairs for body text on each surface yourself.
  • A light spark (yellow, amber, lime) needs dark text on it and usually fails as a text color on a light base. For spark-colored text, add a darker shade of the same hue.

L5. Every color has a job. Report a token that is defined and never used, and a color that is used but fits no role. If the brand's only uses are a focus ring or a hover, it has no visible job: give it one (logo, links, a heading or a band).

Guide, not a limit, because code cannot measure it: by area, base covers most of the page, brand some, spark the least.

If the page has a dark theme, each theme gets the same three roles and is checked on its own: say which theme a finding applies to, and split the contrast table by theme. A new spark may use one value for both themes when it passes L4 in both. In create mode, do not add a dark theme unless asked.

Choosing colors

Use this in case 1, and in case 2 for the one color you add.

Start from a ready palette. palettes.md, next to this file, has 100 palettes in 19 groups. Some groups are by kind of business (clean product, food, money and trust, care and community), some by look (warm paper, dark and technical, bold and acid, luxury), and some by source (published themes and design systems, colorblind-safe sets, print inks, safety standards, enhanced contrast). Each is a base, a brand and a spark. Every one is checked by script: text contrast, brand against spark at 3:1, and brand against spark under simulated color blindness. The spark is checked as a button fill, not as a text color.

The file is long. Read the group headings first, then only the groups that could fit. Each group has a "Basis" line that says how strong its grounding is. Tell the user what the Basis line says, in one sentence, whatever its strength. "Strong" describes where the values or the guidance come from, not a tested hue choice. When the group is marked weak, say it is a convention, not a finding.

  • In case 1, read palettes.md, pick the row whose "Good for" matches what the page is for, and use its values as they are. Pick by purpose, not by taste. Say which palette you picked, by name, and name one alternative, the second-best fit, so the user can switch with one word. Take it from another group when one fits, and from the same group when that is the better match. If the audience has a reading need (many older readers, a public service, poor screens), prefer the "Enhanced contrast" group or offer it as the alternative. When no "Good for" matches exactly, take the nearest kind of business or the nearest mood and say it was the nearest.

  • If the user describes a mood or colors ("dark with an acid touch", "something for a bakery"), pick the closest row. If they name exact colors, use theirs and only borrow the missing roles.

  • If the user has a logo or one fixed color, still pick the row by purpose first. Replace its brand with their color and recheck the pairs and the hue distance with the script. If the row's spark is now less than 90 degrees from their color, or no row fits by purpose, use the row whose brand hue is nearest to their color instead. The alternative you offer keeps their color too.

  • In case 2, do not replace the project's palette with one of these. Use the file only as a source for the one missing color.

  • Build your own with the three rules below only when no row fits.

  • Base: an off-white or a near-black. Aim for ink text at 7:1 or better (the limit is still 4.5:1). Make surface, muted and line from the same hue.

  • Brand: take it from the logo or product if there is one. Otherwise one hue, dark enough that white text on it passes 4.5:1.

  • Spark: a different hue from the brand, at least 90 degrees away in hue, lighter or more saturated (higher L or C), and at least 3:1 in contrast against the brand. Check with --info <brand> <spark> and --contrast <brand> <spark> before you write anything. Choose it for how it stands out from what is around it. No hue is "the best button color". On a dark theme only yellow, lime, mint and cyan stay vivid at the lightness this needs. Keep it away from the page's status colors: do not use a red that reads as "error", and if the page shows errors next to a button, check the two do not look alike.

State the hex values and one reason for each. Check the text pairs with one --contrast call before you write the page, and again with the script after.

Create mode

Use when the user wants a new page or screen.

  1. Do Step 1 and Step 2.
  2. Put the colors in tokens in :root, named by role. Use the project's token names if it has them. This block is the maximum: delete any token you do not use.
:root {
  /* base: background, text and their neutrals */
  --base-bg: ;
  --base-surface: ;
  --base-ink: ;
  --base-muted: ;
  --base-line: ;
  /* brand: identity */
  --brand: ;
  --brand-hover: ;
  --brand-ink: ;   /* text on top of brand */
  /* spark: the primary action */
  --spark: ;
  --spark-hover: ;
  --spark-ink: ;   /* text on top of spark */
  /* status: only if the page shows a status */
  --error: ;
  --success: ;
}

With Tailwind, map the same tokens into the theme (@theme in v4, theme.extend.colors in v3) and use those names instead of palette classes like bg-blue-500. 3. Write the page. No raw color value outside the token block. transparent, currentColor, inherit and a shadow made from the ink color with alpha are fine. 4. Run the script on the result and fix until L1 to L5 hold. For L3, list the spark rules with --uses, then count the elements they match on each screen. 5. Reply with this report:

Primary action: <action> (<file>:<line> of each place it appears) [answered by user | taken from the request | ASSUMED - tell me if it is another one]
Colors: base <hex, hex>, brand <hex>, spark <hex> - one reason each; say "from your palette", "ready palette <name>, alternative <name>" or "new"
Spark is on: <element> (<file>:<line>) for each screen that has spark; name the screen convention you used
Contrast: <table of text pairs and meaningful non-text parts, with ratio and pass/fail>
Invented content to replace: <names, prices, dates, links>
Not checked: <what you could not verify, at least "not rendered in a browser" if true>

Audit mode

Use when the page exists. Report only. Change nothing unless the user asks.

  1. Do Step 1 and Step 2.
  2. Assign roles with "Which existing color is which". If there is no spark, that is the first finding.
  3. Walk the page screen by screen and check L1 to L5.
  4. Reply in the chat in this shape. Write a file only if asked.
# Three-color audit: <page>

Primary action: <action> (<file>:<line> of each place it appears) [answered by user | taken from the request | ASSUMED - tell me if it is another one]
Base:  <tokens or colors>
Brand: <tokens or colors>
Spark: <tokens or colors, or "none">
(with a dark theme, repeat these three lines per theme)

## Findings
1. [missing-spark] <file>:<line> - <what is wrong> -> <the fix>
2. ...

## Contrast
| Text | Background | Ratio | AA | Where |

## Not checked
<what could not be resolved or seen, and why>

## Smallest fix
<the fewest changes that make the page pass, in order>

Tags:

  • missing-spark: the page has no spark, or a screen shows the primary action without it.
  • misplaced-spark: there is a spark, but it is on something other than the primary action.
  • spark-overuse: more than the budget on one screen.
  • extra-color: a fourth color (L2), including a browser default such as an unstyled link or a default focus ring.
  • no-job: unused token, or a color or role with no job (L5).
  • weak-pair: brand and spark are under 3:1 against each other, or the primary action is not the only filled button on its screen (L1b).
  • contrast: an L4 failure with known values.
  • unresolved: a value you could not read.

Rules for the report:

  • Every finding has a file and a line. For a CSS problem give the rule's line and the lines of the elements it styles. For something missing, give the line where it should be.
  • Spark findings come first.
  • When a limit passes, say so in one line. Do not pad.
  • In "Smallest fix", a new color comes with its hex value, the word NEW, and its computed contrast.
  1. Offer to apply the smallest fix, and wait. If nobody can answer, stop at the report. When you apply it, you may add or remove tokens and add or change declarations that set a color. Nothing else.

Do not

  • Do not replace an existing palette because you would have picked another one.
  • Do not invent a value for a color you could not resolve.
  • Do not report a contrast failure from an assumed background without checking it.
  • Do not use the spark to decorate. If two things on a screen are sparked, neither is.
  • Do not promise results. This makes the action easier to find. Whether more people take it can only be learned by testing on the real page.
  • Do not redesign.

Contrast by hand (only without the script)

For each of R, G, B from 0 to 255: c = value / 255, then c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ^ 2.4. Luminance L = 0.2126 R + 0.7152 G + 0.0722 B. Ratio = (L_lighter + 0.05) / (L_darker + 0.05).

관련 스킬