donatj / alike-color-finder
Find similar colors in CSS and CSS-like data.
Requires
- php: >=7.4
- composer-runtime-api: ^2.2
- donatj/flags: ^1.6
Requires (Dev)
- corpus/coding-standard: ^0.9.0
- donatj/drop: ^1.1
- friendsofphp/php-cs-fixer: ^3.95
- php-parallel-lint/php-parallel-lint: ^1.4
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^8.5 || ^9.6 || ^10.5
- squizlabs/php_codesniffer: ^3.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v0.9.0
- v0.8.0
- v0.7.1
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-ci/add-coveralls-coverage
- dev-fix/composer-binary-autoloader
- dev-docs/modernize-readme
- dev-refactor/psr4-test-layout
- dev-chore/add-composer-metadata
- dev-chore/sort-composer-packages
- dev-chore/add-phpcs
- dev-chore/php-cs-fixer
- dev-chore/reduce-phpstan-baseline
- dev-copilot/handle-modern-hdr-color-formats-again
- dev-phpunit-deprecations
- dev-copilot/handle-modern-hdr-color-formats
This package is auto-updated.
Last update: 2026-09-30 16:27:08 UTC
README
Alike Color Finder is a command-line tool for CI that detects nearly identical colors before they become visual drift. It scans CSS and CSS-like files, directories, or standard input; reports color pairs at or below a chosen difference tolerance; and can fail a build when it finds them.
It understands hex and named colors; rgb(), rgba(), hsl(), hsla(), hwb(), lab(), lch(), oklab(), oklch(), and color() functions; and CSS Color Level 4 wide-gamut spaces including Display P3, Rec2020, and ProPhoto RGB.
Choose CIEDE2000 + alpha (the default), CIE94 + alpha, or an absolute color-difference strategy with --strategy.
Prefer a browser? A web-based interface is also available.
Why
Nearly identical colors tend to accumulate in long-lived stylesheets. This began as a small script for finding them, then grew into a tool that can enforce a color-consistency rule in CI.
It is intended to make accidental color drift visible before it ships.
Requirements
- PHP 7.4+ with CLI and SPL support
Installation
Install alike globally:
composer global require donatj/alike-color-finder
Or add it to a project as a vendor binary:
composer require --dev donatj/alike-color-finder
Usage
The examples below use a global installation. For a project dependency, invoke vendor/bin/alike instead.
Scan files or directories:
alike main.css shared.scss styles/
Or pipe CSS through standard input:
css-generating-process | alike
The default ciede2000 strategy reports colors whose difference is at most 4. Lower --tolerance to require closer matches, or choose cie94 or actual with --strategy.
alike --tolerance 1 styles/
Continuous integration
By default, alike exits with 2 when it finds a qualifying color pair or encounters an extraction error, which is suitable for most CI systems. Set --exit-code to another status, or to 0 to report findings without failing the build.
Options
Run alike --help for the complete CLI reference. The core options are:
| Option | Description |
|---|---|
--strategy |
Difference strategy: ciede2000 (default; perceptual alias), cie94, or actual. |
--tolerance |
Maximum computed difference considered alike; defaults to 4. |
--exit-code |
Exit status used when findings or extraction errors occur; defaults to 2. Set to 0 to disable failure. |
--pattern |
Regular expression for files discovered when scanning a directory. |
Example output
Scanning a CSS file:
alike main.css
(4) #e3e3e3 (4) #e4e4e4 Δ: 0.352
#e3e3e3 #e4e4e4
(4) #e3e3e3 (4) #e5e5e5 Δ: 0.705
#e3e3e3 #e5e5e5
(4) #e4e4e4 (4) #e5e5e5 Δ: 0.352
#e4e4e4 #e5e5e5
(2) #454545 * (3) #444444 Δ: 0.437
#454545 #444444
#444
Total alike colors: 4 - Average Δ: 2.167 - Total colors: 17 - Distinct colors: 5
Credits
- SupplyHog, Inc - CIEDE2000 Calculations