# Visual testing without CI: let your agent do it

Canonical: https://snapvisor.io/docs/agents/visual-testing-without-ci

> Let Claude Code, Cursor or any MCP client screenshot your running app, push the images to Snapvisor, and report the visual diff back to you, with no CI pipeline and no Git repository link. Free plan.



Your coding agent can run Snapvisor itself. It takes screenshots of the app it just changed, uploads them as a build, waits for the diff, and tells you what moved. You do not need a CI pipeline, and the project does not need a connected GitHub or GitLab repository.

This page is the recipe. The [MCP server guide](/agents/mcp-server) covers connecting and the tool list.

Not a developer? [Watch your website](/watch-your-website) does this from the project settings, with no agent and no code.

## What you need [#what-you-need]

* An agent with a browser tool it can screenshot with (Playwright, Chrome DevTools, a headless browser script). With a shell, the upload is a plain HTTP request. Without one (claude.ai, ChatGPT), the agent sends each screenshot through the `uploadScreenshotForProject` tool instead, see [step 5](#5-upload-with-curl).
* The Snapvisor MCP server connected. A personal access token is the simplest for a coding agent, see [Authentication](/agents/mcp-server#authentication). The token must be scoped to the account that will own the project, and you must be an administrator of that account, because `createProject` needs both.
* A running copy of your app that the agent can open.

## The loop [#the-loop]

The tool names below are the operations the server exposes. In an MCP client you call each one as `external_<name>` (for example `external_getMe`) inside the `execute_typescript` tool, after `search_tools` shows its signature. See [How the tools are exposed](/agents/mcp-server#how-the-tools-are-exposed).

```text
getMe → createProject (once) → screenshot the app → createBuildForProject →
upload each file with curl → updateBuildForProject (final: true) →
poll getBuild → listBuildDiffs → tell the user
```

### 1. Connect and find your account [#1-connect-and-find-your-account]

Call `getMe`. It returns the accounts the token can reach; the account slug is the `owner` every other tool takes.

### 2. Create the project, once [#2-create-the-project-once]

Call `createProject` with the account slug and a project name. No repository link is needed. On later runs `listProjects` finds it, so the agent should look before it creates.

### 3. Screenshot the running app [#3-screenshot-the-running-app]

The agent captures the pages or states it changed with its own browser tooling and saves them as PNG files. Use stable, descriptive names such as `home.png` or `settings-billing.png`: the name is what a later build is compared by. Capture at a fixed viewport so two runs of the same page match.

### 4. Create the build [#4-create-the-build]

Hash each file (`sha256sum home.png`) and call `createBuildForProject` with:

* `commit`: the output of `git rev-parse HEAD`.
* `branch`: the output of `git branch --show-current`.
* `prNumber`: optional. Without a connected repository this is only a label shown on the build; no pull request is looked up and no status check is posted.
* `screenshots`: one `{ key, contentType }` per file, where `key` is the file's sha256 and `contentType` is `image/png`.

The response lists, for every file the server does not already have, a `postUrl` and a set of `fields`. A file the server already has is not listed, so there is nothing to upload for it.

### 5. Upload with curl [#5-upload-with-curl]

This step is not a tool call. For each listed file, send a `multipart/form-data` POST to its `postUrl`, with every entry of `fields` first and the file last, as `file`:

```bash
curl -sS --fail "$POST_URL" \
  --form-string "$FIELD_1_NAME=$FIELD_1_VALUE" \
  --form-string "$FIELD_2_NAME=$FIELD_2_VALUE" \
  -F "file=@home.png;type=image/png"
```

Repeat one `--form-string name=value` for every entry of `fields`, in the order returned. Use `--form-string` rather than `-F` so a value starting with `@` or `<` is sent literally instead of being read as a file. Each URL is single use, expires after 30 minutes, and accepts files up to 50 MB.

**No shell?** A client that cannot make that POST can send each screenshot as a tool call instead: `uploadScreenshotForProject` takes the build number, the screenshot's `name` and its bytes base64-encoded, and returns the `key` to use in the next step. One call per screenshot, up to 700 KB each; a larger file needs the POST above.

### 6. Finalize [#6-finalize]

Call `updateBuildForProject` with the build number and a `screenshots` array of `{ key, name }`, one per file. `final` defaults to `true`, which starts diff processing. `finalizeProjectBuilds` is only for parallel builds that were sent in several shards.

### 7. Poll for the result [#7-poll-for-the-result]

Call `getBuild` while `status` is `pending` or `progress`. It settles on `no-changes`, `changes-detected`, or an error state (`error`, `aborted`, `expired`).

### 8. Read the diff and report [#8-read-the-diff-and-report]

On `changes-detected`, call `listBuildDiffs`. Tell the user which screenshots changed, whether each change looks intended given the edit just made, and give the build link from the response. On `no-changes`, say so in one line.

The agent should not approve changes on its own. Approving is a human decision: the user approves the build themselves, or asks the agent to call `createReview`.

## Shortcut: let Snapvisor take the screenshots [#shortcut-let-snapvisor-take-the-screenshots]

When the pages are public, the agent can skip steps 3 to 6 and have Snapvisor open and screenshot them itself. Call `captureScreenshotsForProject` with the account slug, the project and a `pages` list, 1 to 10 entries of:

* `name`: the screenshot name builds are compared by, such as `home` or `pricing`. Each name must be unique in the call.
* `url`: a public `http` or `https` address.
* `width` (320 to 3840, default 1280) and `height` (240 to 2160, default 800): the viewport.
* `fullPage`: capture the whole scrollable page (default `true`) or only the viewport.

It also takes an optional `branch` and an optional build `name`. The call answers right away with the new build; poll `getBuild` from step 7 as usual.

A capture series is compared with its own last approved capture. Left out, `branch` is `captures`, which is not auto-approved: the first capture is the baseline, each later capture shows what changed and waits for your approval (`createReview`, or the build page), and only an approved capture becomes the new baseline. A rejected or unreviewed capture never does, so a broken page stays flagged until you fix it or approve it. For monitoring instead, pass a branch the project auto-approves, by default its base branch such as `main`: each capture is then approved automatically and becomes the baseline at once, and `getBuild` returns `autoApproved: true`.

If a page cannot be captured, the build ends in `error` and no screenshot is stored. Call `getBuildCapture` with the build number: it names each failed page and the reason (an address that does not answer, a 404, a timeout), and lists any host it refused to load. The build page shows the same reason, so a person who opens the build sees it too.

Limits:

* Only public addresses. A URL pointing at `localhost`, a private network or a cloud metadata address is refused when the call is made. A page that redirects there fails, and an image or script hosted there is not loaded (`getBuildCapture` lists its host). So this cannot reach an app running on your own machine. Use the full loop above for that.
* No login. The page is opened in a fresh browser with no cookies, so a page behind sign-in shows its sign-in screen.

## How the baseline is chosen without a repository [#how-the-baseline-is-chosen-without-a-repository]

With no connected repository, Snapvisor has no commit history to walk, so a branch name alone does not select a baseline. The rules, in order:

1. If you pass `referenceCommit`, only a build on that commit can be the baseline, and it must be eligible: finished, passed, not a partial (subset) build, not rejected, and approved. A reference or orphan build counts as approved; any other build needs an approved review. Approval is not checked when the reference branch is auto-approved, which by default is the project's default branch. If no eligible build exists for that commit, rule 3 is skipped and Snapvisor does not substitute another build, so the new build is compared against nothing and every screenshot shows as added, unless a build in `parentCommits` matches (rule 2).
2. Otherwise, `parentCommits` is searched. List the build's own commit first and then its ancestors, closest first. Snapvisor drops the first entry, so the build's own commit is never matched. The closest remaining commit that has a finished, passed, non-rejected build wins, approved or not.
3. Otherwise, when no `referenceCommit` was sent, the build is compared against the latest approved build on `referenceBranch` (the project's default base branch when `referenceBranch` is not set). If none is approved, it falls back to the latest completed build on that branch. The only build excluded is the new build itself, so a build on the default branch is compared against the previous build on that same branch. A build on any other branch is compared against the default branch, not against its own earlier builds. Set `referenceBranch` to that branch's own name to chain them.
4. Otherwise, a previous approved build on the same commit and branch is used, so running twice without committing does not leave both builds without a baseline.

The first build of a project has nothing to compare to and needs no approval. It is recorded as a reference build on the default branch or an orphan build elsewhere, and both count as approved baselines, so the next build can compare against it. The loop does not depend on approving changes on later builds.

To pin a specific baseline, call `findBaselineForProject` first. Its required input is `commits`, a list of ancestor commit SHAs, closest first. It also takes an optional `name` (default `default`) and `mode` (`ci` or `monitoring`, default `ci`). The first commit with an eligible build wins. The response is `{ baseline }`, where `baseline` is the build, or `null` when none of the commits has an eligible build. Pass the SHA at `baseline.head.sha` as `referenceCommit` and `baseline.head.branch` as `referenceBranch`.

## What the Free plan includes [#what-the-free-plan-includes]

The build loop above runs on the Free plan: `getMe`, `createProject`, `listProjects`, `getProject`, `createBuildForProject`, `uploadScreenshotForProject`, `updateBuildForProject`, `finalizeProjectBuilds`, `findBaselineForProject`, `getBuild`, `listBuilds` and `listBuildDiffs`, plus `captureScreenshotsForProject` and `getBuildCapture` for the shortcut. Screenshots count against the plan's monthly allowance like any other build.

Every other tool (review, approve, comments, team, domains, automation, settings, billing) is on every plan too. See [Pricing](/pricing).

## Nudge your agent to run it [#nudge-your-agent-to-run-it]

Nothing here is enforced. An agent only runs a visual check if something reminds it. Both snippets below are a reminder, not a gate, and the agent can ignore either.

### A repo rule [#a-repo-rule]

Paste this into `CLAUDE.md` or `AGENTS.md`, or into `.cursor/rules/snapvisor.mdc` (with `alwaysApply: true` in its front matter):

```markdown
## Visual check (Snapvisor)

After you change UI code, run a Snapvisor visual check before you say the work is done:
screenshot the affected pages of the running app, create a build with the Snapvisor MCP
tools (createBuildForProject), upload the files with curl, finalize with
updateBuildForProject, then read getBuild and listBuildDiffs and tell me what changed.
Skip it for changes that cannot affect rendering. Do not approve changes yourself.
Skill: snapvisor-visual-check. Recipe: https://snapvisor.io/docs/agents/visual-testing-without-ci
```

### A Claude Code hook [#a-claude-code-hook]

This adds a reminder to the agent's context after it edits a UI file. It is a reminder, not a gate: it does not block the agent and it does not run Snapvisor. The hook exits 0 and only returns `additionalContext`, which Claude Code passes to the agent next to the tool result. Add it to `.claude/settings.json`:

```json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "node -e \"let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{const p=(JSON.parse(s).tool_input||{}).file_path||'';if(/[.](tsx|jsx|vue|svelte|css|scss|html)$/.test(p))console.log(JSON.stringify({hookSpecificOutput:{hookEventName:'PostToolUse',additionalContext:'A UI file changed. Before you finish, consider a Snapvisor visual check (skill: snapvisor-visual-check).'}}))})\""
          }
        ]
      }
    ]
  }
}
```

Never make this hook exit with code 2 or return `decision: "block"`: that turns the reminder into a gate. A `Stop` hook is a poor fit here: stderr from a hook that exits 0 is not shown, and `additionalContext` on `Stop` makes the agent continue its turn.

## Install the skill [#install-the-skill]

The Snapvisor repository ships a Claude Code skill that walks the agent through this loop. Copy `.claude/skills/snapvisor-visual-check/SKILL.md` into your project's `.claude/skills/snapvisor-visual-check/`, or into `~/.claude/skills/snapvisor-visual-check/` to use it in every project.

