Explore your app as an agent

How does a coding agent check its own web UI change like a user would?

6 min readView as markdown9 chunks · 2.1k tokens in docspack

A coding agent that changed a web page usually has a build that passes and a test that passes, and no idea what the page does. narro explore gives it a browser to use, one step at a time, and tells it what each step caused. It is the same browser, recording and replay as Recording a web app, driven by commands instead of a person.

The loop

An exploration is a loop of three commands: narro explore start <url> opens the page, narro explore snapshot lists what is on it, and narro explore act <ref> <action> does one thing to one element. Every act prints what changed and what went wrong, then you read it and choose the next step. narro explore stop ends the run and writes the outputs.

narro explore start http://localhost:5173/login
narro explore act e3 fill [email protected]
narro explore act e4 fill --secret APP_PASSWORD
narro explore act e5 click
narro explore stop

start leaves a background process holding the browser, so each later command is a short call to it rather than a new browser. Without --session, a command addresses the session started last; start prints the session id when you run several. The same loop is available to an AI assistant as the explore_start, explore_snapshot, explore_act, explore_ask and explore_stop MCP tools (see AI integration).

Refs and snapshots

A snapshot is the page as an agent can act on it: each button, link, field and heading with a short ref like e12, its role and its name. A ref belongs to the snapshot that issued it. If the element is gone when you use the ref, the act fails with stale-ref and prints a fresh snapshot. It never clicks a different element that happens to sit where the old one was.

Take a new snapshot after anything that changes the page. Acting prints what changed, so most steps do not need an extra snapshot. Use goto, back and scroll for moving around: scroll <ref> brings an element into view, and scroll --direction up|down|top|bottom moves the page.

On a big page, narro explore snapshot --find <text> prints only the lines that contain the text (case-insensitive), each under the landmarks and elements that hold it, with a count. It shows at most 30 matches and counts the rest. The next act still diffs against the whole page.

Dialogs, downloads and uploads

A snapshot shows the DOM, and some things a page does are not in it. Each step lists them under happened, one line each. They are not findings, because they are not defects.

  • An alert, confirm or prompt is answered at once and reported, for example confirm "Delete project?" → accepted. Every dialog is accepted unless start --dialogs dismiss says otherwise. One act can override that with --dialog accept|dismiss, and --dialog-text <text> answers a prompt.
  • A download is saved to .narro/explore/<session id>/downloads/ under the name the server suggests, and the line gives the URL and the saved path.
  • narro explore act <ref> upload <file> sets the files of a file input. If the ref is the button that opens a file chooser, it clicks the button and gives the files to the chooser. A file chooser that some other action opens is reported, with the ref to upload to.

A click whose only effect was one of these is not reported as a dead-click.

Handing over to a person

Some steps are for a person, not an agent: a login the agent must not see, an MFA code, a CAPTCHA. narro explore ask "<message>" shows the message in a banner at the top of the page with a Done button. It waits until the person clicks Done (default 5 minutes, --timeout <seconds> to change it), then settles and prints what changed, like an act. The banner comes back if the page navigates, and it never appears in a snapshot or a diff. ask works only when someone can see the browser, so start with --headed or --connect. Without one of them it fails at once.

Logging in

A page behind a login is the common case, and a password must not reach the agent, the terminal or a file on disk. There are three ways in, from safest to most convenient.

Save the login once with narro auth save <url>. It opens a window, you sign in yourself, and it writes the cookies and storage to .narro/auth/<host>.json. Every later run starts logged in with narro explore start <url> --auth <file>. The file is a credential: add it to .gitignore (the command tells you when it is not).

Or sign in inside the run. narro explore act <ref> fill --secret NAME types the value of the environment variable NAME from the shell that calls it. The value is typed into the page and is scrubbed from every snapshot, finding, log line and recording that leaves the session; a missing variable fails the step before anything is typed.

Or attach to a browser you are already signed in to with --connect, which takes a running Chrome’s CDP endpoint.

When a saved login stops working, the step raises an auth-expired finding rather than a confusing failure on the login page. Run narro auth save again.

What the collectors report

Each step is checked while it runs, and a finding names the step that caused it and carries the evidence: the message, the URL, the element. The rules below are generated from the package, so this list is the set an agent can read back.

RuleSeverity
console-errorerror
page-errorerror
request-failederror
slow-stepwarning
dead-clickwarning
layout-shiftwarning
auth-expirederror
step-errorerror

Accessibility violations are reported as a11y:<axe rule id>, for example a11y:label, with axe’s impact mapped to the severity. An accessibility finding belongs to the page, so it is reported once per page and element for the whole run; every other finding is an event and is kept per step. An error that Narro sees while a step runs is a finding or an error on the step, and is not swallowed.

Outputs

stop writes three files to .narro/explore/<session id>/ and prints the briefing:

  • briefing.md is what happened, as evidence to act on: a summary line, then each finding with the step that caused it and a replay link.
  • findings.json is the same findings as data, sorted with errors first.
  • run.narrocast is the whole run, one chapter per step, and plays in the replay player or on a slide like any other cast.

To watch a run, open the cast, or start with --headed to see the window while it happens. Password fields and fields filled with --secret are masked in the recording; other fields stay readable so the replay is useful. Secret values never appear in any of the three files.

Latency

A step waits for the page to settle before it reports: network quiet, no mutations for a moment, and no more than a cap. A page that never settles (polling, a websocket, a spinner) returns at the cap and the step is marked settled: false; the next step works as usual. Slow work is reported rather than hidden: a step that takes longer than the threshold raises slow-step.

The accessibility scan runs on navigation and on large changes, not after every click, so most steps pay only for the action, the settle and a snapshot.

IntroductionWhat is Narro, and should I be writing markdown or React?
InstallationWhat do I install, and what does the project look like afterwards?
First deckWhat does a working React deck look like, end to end?
Markdown modeHow do I split a slide, style one word, or reveal a line — without leaving the markdown file?
Writing AI promptsWhat do I tell an AI so the deck it writes actually builds?
Rules for AI agentsWhat do I paste into my repo so an agent stops writing decks that build wrong?
React APIWhich component or hook do I import, and what does it take?
CLIWhich command do I run, and what are its flags?
Markdown APIHow do I read, edit, or validate a deck file from my own code instead of by hand?
Component referenceWhat props does this component take, and which package do I import it from?
Verifying a deckHow do I know my deck is actually correct?
AnimationHow do I reveal a list one line at a time, or move between slides with something other than a cut?
NavigationHow does the audience move through the deck, and how do I present it?
Canvas & positioningHow do I put something at an exact position instead of in the flow?
Images & mediaHow do I use an image as a background, tint it, or embed a video?
ArchitectureWhich package owns what, and why is the seam where it is?
Zooming canvasHow do I zoom and pan across one big canvas instead of cutting between slides?
Transform modeHow do I zoom and pan across one big canvas instead of cutting between slides?
Import & exportHow do I get this deck out as PPTX, PDF, or one file I can email?
VideoHow do I turn a story into a video, and keep it right when the words, the product or the source changes?
Recording a web appHow do I put a demo of my product in a deck or on a landing page without shipping a video of it?
Embedding a replayHow do I embed a recorded demo of my app in my React app, my Astro site, or any other page?
TerminalHow do I put a terminal demo in a deck, a README or a video, and find out when the tool it demonstrates stops saying what the demo says?
AI integrationHow do I wire an AI assistant up to Narro so it can write and build decks?
ThemingHow do I change the colours, fonts, and overall look of a deck?
Deck templatesHow do I define one house style with named layouts my slides can reference, like a PowerPoint master?
TroubleshootingSomething is wrong with my deck. What is it, and how do I fix it?
LimitationsWhat can't Narro do, and what do I do instead?
PDF documentsHow do I send a polished offer or invoice from a markdown file?
Explore your app as an agentHow does a coding agent check its own web UI change like a user would?
Study PDFsHow do I turn researched notes into a printable study sheet with formulas and index cards?