@corralimited/snapdiff-cli
Command-line interface for SnapDiff. Capture screenshots, run visual diffs,
and manage project baselines from the terminal or CI.
npx @corralimited/snapdiff-cli --help
npm install -g @corralimited/snapdiff-cli
Setup
Get an API key at https://snapdiff.ai/dashboard, then export it:
export SNAPDIFF_API_KEY=sd_live_...
(Alternatively, pass --api-key to any command.)
Commands
snapdiff snapshot <url>
Capture a screenshot of a URL.
snapdiff snapshot https://example.com
snapdiff snapshot https://example.com --full-page --width 1440
snapdiff snapshot https://example.com --selector ".hero" --dark-mode
snapdiff diff <before> <after>
Compare two URLs (or ss_xxx screenshot ids) visually.
snapdiff diff https://example.com https://staging.example.com
snapdiff diff https://example.com https://staging.example.com \
--threshold 0.05 --ignore ".timestamp" --ignore "#ad-banner" --full-page
Exits with code 2 when the pages differ (the result JSON is still printed). Useful in CI:
snapdiff diff $PROD_URL $STAGING_URL > diff.json || echo "::warning::Visual change detected"
snapdiff diff-baseline <project> <page> <after>
Compare a URL against the stored baseline for a project + page (+ branch). Server-side baseline
resolution — single round trip.
snapdiff diff-baseline acme-marketing pricing https://staging.acme.com/pricing
snapdiff diff-baseline acme-marketing pricing https://staging.acme.com/pricing --branch feat/redesign
Same exit codes as diff: 0 match, 2 differs, 1 error.
snapdiff projects ls / snapdiff projects get <projectId>
snapdiff projects ls
snapdiff projects get prj_X3V-3SzmJ61WIdxY
Global flags
--api-key <key> | Override the SNAPDIFF_API_KEY env var. |
--api-url <url> | Point at a non-default API base. Mostly for testing. |
Exit codes
0 | Success (e.g. diff matched). |
1 | Error — invalid args, network, API error. Message goes to stderr. |
2 | Diff command ran, but pages did not match. Result JSON is still printed to stdout. |
License
MIT — see LICENSE.