---
name: nocticas
description: Author, run, and pin browser-automation tests with Nocticas — an AI browser agent with two engines (agentic, natural-language; and deterministic, scripted) exposed over MCP tools. Use this when the user wants to test or QA a web flow, smoke-test a UI, reproduce a bug in a browser, automate a web task, or turn a passing run into a fast CI gate.
---

# Nocticas — browser automation & E2E testing

Nocticas drives a real headless Chromium against any URL. Two engines, one service:

- **Agentic** — give a natural-language **objective** ("log in as the demo user, create a client named Acme, confirm it appears"). Claude drives the browser like a human QA tester and returns a pass/fail verdict. Use it to **explore and author** a flow, or for smoke tests.
- **Deterministic** — give a fixed **script** of steps (goto/click/fill/press/waitFor/expect…). No model in the loop: fast, repeatable, hard assertions, costs ~nothing. Use it as the **CI gate**.

The intended lifecycle is **author with agentic → pin to deterministic**. Reach for Nocticas whenever the task is "make sure this web flow works" or "do this thing in a browser."

## Connect (once)

If the Nocticas MCP tools (`start_run`, `get_run`, …) aren't already available, the user connects the server once:

```
claude mcp add --transport http nocticas https://app.nocticas.com/api/mcp \
  --header "x-nocticas-key: <their-api-key>"
```

(Keys are minted on the Account page at app.nocticas.com.) Everything below is also available over plain REST (`POST /runs`, `GET /runs/:id`) with the same `x-nocticas-key` header — prefer MCP when you're the agent in the loop, REST for CI/scripts.

## The core workflow: author → verify → pin

1. **Author (agentic).** `start_run({ mode: "agentic", target, objective })`. Either poll `get_run(id)` until the status is terminal (`passed`/`failed`/`error`), or pass `wait: true` to block until it finishes and get the full result + final screenshot back in one call. Read the `steps` — each carries the element it acted on (`id`/`testid`/`name`/`role`) plus a screenshot you can pull with `get_screenshot`. **Declare `expect[]` post-conditions up front** (below) so the pass is harness-verified, not just the agent's word.
2. **Verify (do NOT trust a lone PASS — see Guardrails).** The strongest verification is built in: pass **`expect[]` post-conditions** on the agentic run — `expect: [{selector, state: "text", value: "Client created"}, …]`. After the agent declares pass, the **harness executes each as a real Playwright assertion** (no model); a failing one **flips the verdict to fail**, all passing stamps it "✓ post-conditions verified". Free. Assert **durable** end-state (the new row, the saved value, the landed page's heading) — not transient toasts/banners, which can fade before the harness asserts. On top of that: re-read the step trail, check a screenshot, and for any state-changing flow cross-check the real effect (e.g. the row exists in the DB / the API returns it) — a post-condition can only see the UI.
3. **Pin (deterministic).** Turn the passing flow into a deterministic `script` by converting each acted element into a selector (prefer `testid` > `id` > `name`). `start_run({ mode: "deterministic", target, script })`. This is the run you put in CI — fast, no model, hard assertions, and only a fraction of an agentic run's credits. See `get_guide(doc:"pinning")` for the full recipe.

## Choosing an engine

- **Agentic** when the path isn't pinned yet, the UI changes often, or you're reproducing/exploring. Costs a flat per-run credit price.
- **Deterministic** for a known, stable path you want to gate on. Cheap and exact. If a deterministic step's selector drifts, add a `fingerprint` (copy it from the agentic step's `element`) so **self-healing locators** rebind instead of failing.

## Guardrails — the difference between a real gate and a false-green factory

- **Never trust a single PASS on a multi-step objective.** Declare **`expect[]` post-conditions** on the run (harness-executed assertions that gate the pass — the built-in antidote), cross-check the side effect, or write the objective as a narrow, single-assertion check. File a `submit_feedback({ assessment: "verdict_wrong" })` when a verdict is wrong — it trains the system.
- **Keep ≥1 un-mocked / un-replayed integration canary per flow.** `mock_route` (canned responses) and `replayHar` (recorded network) make runs fast and stable but they DON'T exercise the live backend — Nocticas stamps those verdicts loudly (🔌 mocked, ⚠️/🛑 replayed) for exactly this reason. A suite where every gate is mocked is a false-green factory. Mock the flaky dependency, not the thing under test.
- **Re-pin when you see 🩹 (self-heal).** A healed step still passes but means your selector is drifting; `get_heal_report` lists your rotting pins. Re-pin them.
- **Order matters for mocks.** A `mock_route` must precede the step that fires its request (a mock registered after the request is a silent no-op).

## Auto-download media — a standard step on EVERY run

Treat this as part of the run flow, not an afterthought: **the moment a run concludes, download all its media to a local folder.** It's frictionless —

1. **Provision a local artifacts dir once** (e.g. `nocticas-runs/`) so there's somewhere to put them.
2. **On conclusion, grab the manifest.** `start_run(wait:true)` and a terminal `get_run` both return a **`media`** block inline: keyless download URLs for every screenshot + the video (+ trace/HAR) **and** a ready-to-run **`download_all`** bash command. Run `download_all` as-is (it `mkdir`s `nocticas-runs/<id>/` and `curl`s the whole set), or fetch the URLs with your HTTP tool. (`get_artifacts(run_id)` returns the same manifest if you want it on demand.)
3. **Why:** Nocticas's copy is **transient** — a 30-day artifact TTL **plus** a per-tier storage quota that FIFO-evicts the oldest runs. So **the copy you download is the durable one** for the user. Download promptly.

**Fallbacks (if you can't download):**
- You still have the **final screenshot inline** from `wait:true`.
- The **run record** (verdict / steps / cost) always persists in `get_run`, even after the media is reclaimed.
- A link **404** = that artifact was already evicted → re-run to regenerate it.
- Keyless links **expire in ~15 min** → re-call `get_artifacts(run_id)` to refresh.
- **No shell / can't write files?** Fetch the keyless URLs with your HTTP tool and keep them with the run.

(`get_screenshot` returns one screenshot inline if you just want to *look*; `get_video` is the single-file video link.)

## Useful features (opt-in)

- **`recordVideo: true`** — saves a `.webm` of the session, served as a run artifact (`get_run` → `videoUrl`, or `get_video` for a keyless download link) and embedded in the dashboard. Great for debugging a flaky/failing flow. Surcharged **5 credits per minute** (rounded up), billed only for the actual minutes and only if a recording is produced. Note that video captures keystrokes + transient on-screen states, so test/throwaway credentials are a good idea when recording — your call.
- **`wait_for_email`** — a Mailgun-backed test inbox (register a label once via `set_inbox_alias` — or `PUT /account/inbox-aliases/<label>` — then use addresses `nocticas-<label>-<anything>@mail.nocticas.com`) that unblocks OTP / magic-link / sign-up flows; codes and links are auto-extracted.
- **HAR record/replay** (deterministic) — `recordHar:"name"` captures the live network on a passing run; `replayHar:"name"` serves it back for a hermetic, no-model gate (un-recorded requests abort, never silently go live).
- **`expect_screenshot`** — pixel-diff visual regression against a per-project baseline.

## Credits & cost

Runs are charged in **credits** (the customer-facing unit). Agentic is a flat per-run price; deterministic is a small flat rate. Check the balance with the `/usage` view. If a run is refused for credits you'll get a distinct `insufficient_credits` signal (a 402 over REST) — that's "out of credits," not a test failure; don't treat it as a broken build.

## When you need more

`get_guide(doc:"pinning")` (turn a passing run into a cheap deterministic gate), `get_guide(doc:"integration")` (auth, endpoints, file uploads, the full tool reference), `get_guide(doc:"changelog")` (what changed — check at the start of a session; the tools self-report changes via a banner on every result).
