Documentation

Get started with Invariant in minutes.

Quick Start

# One-command setup

npx @invariant-ai/cli init -y

# Run tests and capture proof

npx invariant run

# Optional: connect to cloud for sync + dashboard

npx invariant login

Local proof works without an account. Login is only required for cloud sync and the online dashboard.

For global install convenience: npm i -g @invariant-ai/cli then use invariant run directly.

Commands Reference

npx @invariant-ai/cli init -y

Initialize Invariant in your project. Installs Playwright, creates sample test, sets up hooks.

npx invariant run

Run all tests and capture proof (screenshots, videos, traces).

npx invariant dashboard

Open local dashboard to view proof reports.

npx invariant login

Connect CLI to Invariant Cloud for sync.

Example Test

import { test, expect } from '@invariant-ai/cli/visual';

test('homepage loads', async ({ page }) => {
  await page.goto('/');
  await expect(page).toHaveTitle(/.+/);
});

test('user can sign up', async ({ page }) => {
  await page.goto('/signup');
  await page.fill('input[name="email"]', 'test@example.com');
  await page.fill('input[name="password"]', 'password123');
  await page.click('button[type="submit"]');
  await expect(page).toHaveURL('/dashboard');
});

AI Prompt Examples

“Write a test for the login flow, then implement the login page”

“Add a test for form validation and fix any failures”

“Create a test for the checkout process, then build it”

MCP Integration (Optional)

Connect Invariant to AI assistants like Claude Code via MCP. This is optional — Invariant works without it.

# Register MCP server

npx invariant mcp install

# Remove MCP server

npx invariant mcp uninstall

Once installed, AI assistants get 4 tools:

  • invariant_run — Run tests and capture proof
  • invariant_status — Get workspace status
  • invariant_latest_report — Get the latest proof report
  • invariant_list_runs — List recent runs

Current Limitations

  • CLI currently uses one active cloud project at a time. Multi-project switching is planned.
  • Automatic hook installation requires jq. If missing, setup skips hooks with a manual step.