CLI
Trigger VisualQ audits from any CI/CD pipeline with the @visualq/cli package.
The VisualQ CLI (@visualq/cli) is a zero-dependency command-line client for the CI REST API. Use it in GitLab CI, Jenkins, CircleCI, Bitbucket Pipelines, Azure Pipelines, or local scripts to trigger quality audits and fail the pipeline when checks do not pass.
For GitHub-hosted repositories, the dedicated GitHub Action adds native check runs and PR comments. For other CI systems, the CLI is the recommended integration surface.
Install
Run directly with npx (no install step):
npx @visualq/cli run --api-key $VISUALQ_API_KEY --project my-websiteOr install globally:
npm install -g @visualq/cli
visualq run --api-key $VISUALQ_API_KEY --project my-websiteAuthentication uses an API key with scope ci or mcp_full. Keys scoped mcp_read cannot trigger runs.
Quick start
export VISUALQ_API_KEY=vq_your_key_here
# Visual regression test (default CI use case)
visualq run --project my-website --environment staging
# Check an existing run
visualq status run_abc123
# List projects accessible with your key
visualq projectsWhen the API key is project-scoped, --project is optional — the key's associated project is used automatically.
Commands
| Command | API type | Description |
|---|---|---|
visualq run | test | Compare screenshots against baselines (VRT) |
visualq baseline | baseline | Capture new visual baselines |
visualq perf | perf | Run a performance audit (Lighthouse / Core Web Vitals) |
visualq seo | seo | Run an SEO audit |
visualq a11y | a11y | Run an accessibility audit |
visualq security | security | Run a security scan |
visualq analytics | tracking | Run an analytics / tracking plan audit |
visualq status <runId> | — | Print run status and results as JSON |
visualq projects | — | List projects accessible with your API key |
visualq help | — | Show usage help |
visualq --version | — | Print CLI version |
All run commands (run, baseline, perf, …) trigger POST /api/ci/run, poll GET /api/ci/status/{runId} until completion (unless --no-wait), and exit with a non-zero code when the run fails or checks do not pass.
Options
These options apply to all run commands unless noted otherwise.
| Option | Env var | Default | Description |
|---|---|---|---|
--api-key <key> | VISUALQ_API_KEY | (required) | API key sent as X-API-Key |
--project <slug> | — | — | Project slug (optional with project-scoped keys) |
--scenarios <list> | — | all scenarios | Comma-separated scenario labels |
--browsers <list> | — | chromium | Comma-separated: chromium, firefox, webkit |
--environment <env> | — | project default | Environment name or slug |
--perf-budgets <json> | — | — | JSON budgets — perf only. Keys: lcp, fcp, cls, tbt, ttfb, score |
--api-url <url> | VISUALQ_API_URL | https://visualq.ai | API base URL |
--no-wait | — | wait enabled | Trigger the run and exit immediately with { "runId", "status": "started" } |
--commit <sha> | auto in CI | — | Git commit SHA |
--branch <name> | auto in CI | — | Git branch name |
--pr <number> | auto in CI | — | Pull request / merge request number |
--pr-url <url> | auto in some CI | — | Pull request URL |
--jira-key <key> | — | — | Jira issue key to link results (e.g. PROJ-123) |
--ci <provider> | auto in CI | — | CI provider name (e.g. gitlab, github-actions) |
--locale <code> | VISUALQ_LOCALE, LANG | auto-detect | Output language for log messages (en, fr, …) |
status and projects accept --api-key, --api-url, and --locale only.
Environment variables
| Variable | Description |
|---|---|
VISUALQ_API_KEY | API key (alternative to --api-key) |
VISUALQ_API_URL | Override API base URL (alternative to --api-url) |
VISUALQ_LOCALE | Output language (alternative to --locale) |
CI auto-detection
When running inside a supported CI environment, the CLI automatically fills --commit, --branch, --pr, --pr-url (where available), and --ci. Explicit flags always take priority.
| CI provider | Detected when | Commit | Branch | PR / MR |
|---|---|---|---|---|
| GitLab CI | $GITLAB_CI | $CI_COMMIT_SHA | $CI_COMMIT_REF_NAME | $CI_MERGE_REQUEST_IID |
| GitHub Actions | $GITHUB_ACTIONS | $GITHUB_SHA | $GITHUB_HEAD_REF or $GITHUB_REF_NAME | Parsed from $GITHUB_REF (refs/pull/N/) |
| CircleCI | $CIRCLECI | $CIRCLE_SHA1 | $CIRCLE_BRANCH | Parsed from $CIRCLE_PULL_REQUEST URL |
| Jenkins | $JENKINS_URL | $GIT_COMMIT | $GIT_BRANCH (strips origin/) | $CHANGE_ID |
| Travis CI | $TRAVIS | $TRAVIS_COMMIT | $TRAVIS_BRANCH | $TRAVIS_PULL_REQUEST |
| Bitbucket Pipelines | $BITBUCKET_COMMIT | $BITBUCKET_COMMIT | $BITBUCKET_BRANCH | $BITBUCKET_PR_ID |
| Azure Pipelines | $BUILD_BUILDID | $BUILD_SOURCEVERSION | $BUILD_SOURCEBRANCH | $SYSTEM_PULLREQUEST_PULLREQUESTID |
On GitLab CI, --pr maps to the merge request IID (the number shown as !123 in the UI), not the internal MR ID.
Examples
Visual regression on staging
visualq run \
--api-key $VISUALQ_API_KEY \
--project my-website \
--environment staging \
--scenarios "Homepage,Login"Capture baselines after deploy
visualq baseline \
--api-key $VISUALQ_API_KEY \
--project my-website \
--environment productionPerformance audit with budgets
visualq perf \
--api-key $VISUALQ_API_KEY \
--project my-website \
--perf-budgets '{"lcp":2500,"cls":0.1,"score":75}'The CLI exits with code 1 when any budget threshold is exceeded.
SEO, accessibility, security, analytics
visualq seo --api-key $VISUALQ_API_KEY --project my-website
visualq a11y --api-key $VISUALQ_API_KEY --project my-website --browsers chromium,firefox
visualq security --api-key $VISUALQ_API_KEY --project my-website
visualq analytics --api-key $VISUALQ_API_KEY --project my-websiteFire-and-forget (manual status check)
visualq run --api-key $VISUALQ_API_KEY --project my-website --no-wait
# {"runId":"run_abc123","status":"started"}
visualq status run_abc123 --api-key $VISUALQ_API_KEYLink results to Jira
visualq run \
--api-key $VISUALQ_API_KEY \
--project my-website \
--jira-key PROJ-456CI/CD integration examples
GitLab CI
visual-regression:
stage: test
image: node:20
script:
- npx @visualq/cli run --project "$VISUALQ_PROJECT" --environment staging
variables:
VISUALQ_API_KEY: $VISUALQ_API_KEY
VISUALQ_PROJECT: my-website
rules:
- if: $CI_MERGE_REQUEST_IIDCommit SHA, branch, MR number, and provider are auto-detected — no extra flags needed.
Jenkins
stage('Visual Regression') {
environment {
VISUALQ_API_KEY = credentials('visualq-api-key')
}
steps {
sh '''
npx @visualq/cli run \
--api-key "$VISUALQ_API_KEY" \
--project my-website \
--environment staging
'''
}
}SEO gate before merge
seo-audit:
stage: test
image: node:20
script:
- npx @visualq/cli seo --project my-website --environment staging
variables:
VISUALQ_API_KEY: $VISUALQ_API_KEY
VISUALQ_PROJECT: my-websiteSee Other CI systems for CircleCI, Jenkins declarative pipeline, and curl-based patterns.
Polling and timeouts
By default, run commands poll every 5 seconds for up to 5 minutes. While waiting, the CLI prints progress lines prefixed with [visualq].
When the run completes:
- VRT / baseline / a11y / security / analytics — fails if
summary.failed > 0 - perf — fails if performance budgets are exceeded (
perfBudgetResult.pass === false) - seo — fails if
seoFailed > 0
Use --no-wait to skip polling and handle status yourself with visualq status.
Exit codes
| Code | Meaning |
|---|---|
0 | Success — all checks passed, budgets met, or --no-wait triggered |
1 | Failure — missing API key, trigger error, visual diffs, failed checks, budget violation, SEO failures, run error, timeout, unknown command |
Out of scope
The CLI covers CI-triggerable audits via /api/ci/run. It does not replace the VisualQ dashboard for:
| Capability | Where to use it |
|---|---|
| FRT scenario authoring and feature runs | VisualQ UI or MCP (run_frt_feature) |
| Full quality audit (all pillars at once) | VisualQ UI (POST /api/tests/full-suite) |
| Approve visual diffs | VisualQ UI or MCP (approve_vrt_results) |
| Project setup, pages, schedules, billing | VisualQ UI |
For agent-driven workflows beyond CI triggers, see the MCP integration.
Related
- API keys — create and scope keys
- REST API — raw HTTP reference for
/api/ci/* - CI endpoints — request/response schemas
- GitHub Action — native GitHub integration
- Environments — staging / production base URLs