Get started with Invariant in minutes.
# 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.
npx @invariant-ai/cli init -yInitialize Invariant in your project. Installs Playwright, creates sample test, sets up hooks.
npx invariant runRun all tests and capture proof (screenshots, videos, traces).
npx invariant dashboardOpen local dashboard to view proof reports.
npx invariant loginConnect CLI to Invariant Cloud for sync.
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');
});“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”
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 proofinvariant_status — Get workspace statusinvariant_latest_report — Get the latest proof reportinvariant_list_runs — List recent runsjq. If missing, setup skips hooks with a manual step.