# UserZero
### Your first user is AI.
**UserZero independently verifies your web app by attempting a goal through the rendered interface — with no access to your code.**
[](https://github.com/aafre/userzero/actions/workflows/ci.yml)
[](LICENSE)
[](https://nodejs.org)
[](https://www.typescriptlang.org/)
```bash
userzero run --url http://localhost:3000 "Create my first project"
```
---
```text
Goal Create my first project
Result FAIL
Journey
✓ Opened dashboard
✓ Found "New Project"
✓ Entered project name
✗ Create produced no visible result
Technical evidence
POST /api/projects → 422
console error from ProjectCreateForm.tsx
```
The value is not that UserZero knows your code is broken. It is that **a user discovered the problem independently** — and the recorder can explain what happened underneath.
---
## Why
AI coding agents ship user-facing features in minutes. The same agent is the worst possible judge of whether the feature is usable, because it already knows which button matters, which routes exist, and what success looks like.
Traditional end-to-end tests have the same blind spot from the other direction: they assert predetermined behaviour against selectors you wrote, so they verify what you expected rather than what a person would experience.
UserZero puts a **perception boundary** between implementation and verification.
```mermaid
flowchart LR
subgraph B["🚫 Never crosses the boundary"]
direction TB
SRC["source · routes · diffs
data-testid · hidden DOM
network · console"]
end
subgraph U["Acting user"]
direction TB
A["screenshot
visible text
visible controls
own history"] --> D["decide"]
end
D -->|click · type · scroll| BR["Chromium"]
BR -->|new screen| A
BR -.-> R["Passive recorder
(HTTP · console · exceptions)"]
R -.->|"only after the verdict is frozen"| REP["Report"]
D --> REP
style B stroke-dasharray: 5 5
```
The acting user sees the screen. A passive recorder watches the browser underneath. The recorder's evidence is correlated with the user's actions **only after the verdict is frozen** — so technical evidence can explain a failure, but never cause one.
This is structural, not a prompt instruction. The agent has no browser handle, and [`tests/boundary.test.ts`](tests/boundary.test.ts) fails if anyone gives it one.
---
## Quickstart
```bash
git clone https://github.com/aafre/userzero.git
cd userzero
npm install
npx playwright install chromium
npm run build && npm link # provides the `userzero` command
```
**No API key required.** If you have [Claude Code](https://claude.com/claude-code) installed and signed in, UserZero drives it directly:
```bash
userzero run --url http://localhost:3000 "Create my first project"
```
That's it. UserZero finds `claude` on your `PATH` and uses your existing session.
> Not ready to `npm link`? Every command below also works as `npm run dev -- run --url ... "goal"`.
Prefer an API key? (recommended for CI)
```bash
export ANTHROPIC_API_KEY=sk-ant-...
userzero run --url http://localhost:3000 --brain sdk "Create my first project"
```
With `ANTHROPIC_API_KEY` set, the SDK backend is chosen automatically — `--brain` is only needed to force a specific one.
### Choosing a backend
| `--brain` | Requires | Best for |
|---|---|---|
| `auto` *(default)* | — | Uses `ANTHROPIC_API_KEY` if set, else the `claude` CLI |
| `claude` | Claude Code ≥ 2.1.248 on `PATH` | Local development on an existing subscription |
| `sdk` | `ANTHROPIC_API_KEY` | CI, containers, reproducible billing |
> The `claude` backend runs as a **contained subprocess**: an allowlisted tool roster of exactly `Read`, restricted mode, no MCP servers, and a working directory containing nothing but the current screenshot. UserZero verifies all of that against the process's own startup report before sending it a single turn — and aborts the run if any of it is wrong. See [the perception boundary](#the-perception-boundary).
---
## Usage
```bash
userzero run --url http://localhost:3000 "Create my first project"
userzero run --url http://localhost:3000 --goal "Invite a teammate" --headless
userzero run --url http://localhost:3000 --brain sdk --max-actions 25 "Upgrade to Pro"
```
| Flag | Default | |
|---|---|---|
| `--url` | — | the running application **(required)** |
| `--goal` | — | the outcome to attempt; may be positional |
| `--brain` | `auto` | model backend: `auto`, `claude`, `sdk` |
| `--headless` | off | run without a visible window |
| `--max-actions` | `15` | action budget |
| `--timeout` | `120` | seconds |
| `--config` | `.userzero/config.yaml` | config file path |
Configuration file
Optional `.userzero/config.yaml`, overridden by CLI flags:
```yaml
url: http://localhost:3000
brain: auto
model: claude-opus-5 # defaults to "sonnet" for the claude backend
browser:
headless: false
limits:
max_actions: 15
timeout_seconds: 120
same_action_retries: 2
auth:
storage_state: .userzero/auth.json
out_dir: .userzero/runs
```
For an authenticated app, save a Playwright [`storageState`](https://playwright.dev/docs/auth) to `.userzero/auth.json` and the user will start signed in.
---
## Results
| Status | Meaning | Exit |
|---|---|:---:|
| 🟢 `PASS` | goal reached, with visible evidence | `0` |
| 🟡 `PASS_WITH_FRICTION` | reached, but the user hit friction | `0` |
| 🔴 `FAIL` | the interface visibly prevented completion | `1` |
| 🔴 `STALLED` | no reasonable next action was found | `1` |
| ⚪ `BLOCKED` | an external prerequisite (CAPTCHA, SSO, payment) | `2` |
| ⚪ `INCONCLUSIVE` | UserZero or the environment failed | `2` |
Two rules the taxonomy exists to protect:
1. **A `PASS` requires evidence the user could point at on screen.** Success without visible proof is never a pass.
2. **UserZero's own failures are never reported as your application's.** A crashed model session is `INCONCLUSIVE`, not `FAIL`.
Every run writes `.userzero/runs//`:
```text
report.md the journey, in user-facing language
result.json structured verdict + steps
trace.jsonl append-only event log
screenshots/ one per action, plus a final frame
```
---
## The perception boundary
The acting user receives **only**: a screenshot, the visible text, the controls it can see, and its own history.
It never receives source, routes, `data-testid`, network traffic, console output, hidden DOM, or coding-agent context.
For the `claude` backend, containment is an **allowlist that the subprocess itself confirms**:
| Guarantee | How |
|---|---|
| One tool, `Read` | `--tools Read` — an allowlist, so a tool added in a future release cannot appear |
| Cannot read your repo | `--restricted` confines file tools to the working directory |
| Working directory holds one file | a fresh temp dir containing only `screen.png` |
| No MCP servers, no ambient settings | `--strict-mcp-config`, `--restricted` |
| Not a coding agent | `--system-prompt` replaces Claude Code's identity |
| No shell, ever | the resolved native binary is spawned with `shell: false`; page text goes to **stdin**, never `argv` |
Before the first turn, UserZero reads the process's startup report and checks the roster, working directory and MCP list are exactly what it asked for. A mismatch aborts the run — it is never retried.
```json
{"type":"brain_session_started","tools":["Read","StructuredOutput"],
"mcpServers":[],"perceptionBoundary":"verified"}
```
---
## How it works
One journey runs as **one continuous session**, so the user remembers what it just did:
> *"The 'Create project' button is now greyed out, and a new panel appeared reading 'Continue with Acme Identity'."*
A fresh process per decision cannot notice that. Noticing what just changed is most of what a real user does.
---
## Development
```bash
npm run typecheck
npm test # 51 tests, no external network, ~3s
npm run build
npx tsx tests/fixtures/probe.ts # what the user can see in each fixture
npx tsx tests/fixtures/continuity.ts # opt-in: live session-continuity check
```
[`tests/fixtures/`](tests/fixtures/) holds seven controlled applications covering the acceptance scenarios — a healthy flow, hidden backend validation, a dead interaction, a recoverable form, an inscrutable UI, an environment failure, and a third-party block. Scenarios A–D deliberately present an *identical* initial screen; only behaviour distinguishes them, so a run that "passes" by pattern-matching the layout is caught.
---
## Scope
V0.1 answers exactly one question:
> **Can an independent AI user accomplish this goal through the rendered interface?**
It does **not** compare against a previous version. Experience-regression is deliberately deferred until this loop proves reliable.
---
## License
[MIT](LICENSE)