Skip to content

About

Agent Memory for End to End Testing

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

understudy

understudy — record a flow once, replay it as a test

npm

End-to-end tests for your own web apps, without clicking through every flow by hand. Record a flow once. Understudy remembers it, replays it as a test, notices when the app changes, and runs goals you describe in words. New flows can be built from ones it already has, and follow them when they change.

It works on its own from the command line, and plugs into an AI agent (Claude Code, Codex, Cursor) over MCP. With an agent, Understudy never calls a model itself: the agent is the model.

How it works

record  →  save  →  replay / run  →  findings
  • record: click through a flow in your browser with the Understudy recorder extension, or import a Playwright script. Passwords are never stored: a password field is kept as a name like SECRET.password.
  • save: the flow is replayed in a fresh browser first and kept only if every step passes, so memory holds only flows known to work.
  • replay / run: replay runs a flow by name; run finds the flow for a goal you describe ("go to my basket") and runs it.
  • findings: every run reports console errors, failed requests, values that didn't stick, and whether the flow took a different path than last time.

A step can also wait for a person (a code from your phone), wait for a server response, or check how the flow ended. Anything that buys, books or deletes is marked destructive and only runs when you allow it.

Set up

You need Node 22.13+. Memory is kept in a SQLite file in ~/.understudy unless you choose another database, so there is nothing else to install.

npm install -g @jeffawe/understudy
npx playwright install --only-shell chromium
understudy config set EMBED_KEY="…"   # optional

Settings are written to ~/.understudy/understudy.env, which only you can read. Already keep them in a file? Use understudy config --env-file <path>.

Setting What it's for
UNDERSTUDY_DB optional: where memory is kept. Not set: a SQLite file. See Choosing a database.
EMBED_KEY optional: a Voyage key, to match goals by meaning rather than by flow name
UNDERSTUDY_<NAME> login values, e.g. UNDERSTUDY_SECRET_PASSWORD for SECRET.password. Not set? The terminal asks for it.

Another embedding model works too: set EMBED_URL, EMBED_MODEL and EMBED_DIMS for any OpenAI-style /v1/embeddings endpoint (OpenAI, Ollama…). Recall then lists the closest flows and leaves the pick to you (or your agent), since its "known" cutoffs were set for Voyage.

Choosing a database

Understudy keeps flows, notes and findings in SQLite unless you say otherwise: a file at ~/.understudy/understudy.db, nothing to set up. To use another database, set UNDERSTUDY_DB to its connection URL. The user name and password go in the URL:

understudy config set UNDERSTUDY_DB="mongodb+srv://<user>:<password>@<your-cluster>.mongodb.net"
understudy doctor    # connects, creates its tables or collections, and says what it found
Database UNDERSTUDY_DB
SQLite (default) not set, or sqlite:~/somewhere/understudy.db for another file
MongoDB / Atlas mongodb+srv://<user>:<password>@<cluster>.mongodb.net or mongodb://<user>:<password>@<host>:27017
Postgres (also Neon, Supabase, CockroachDB, RDS…) postgres://<user>:<password>@<host>:5432/<database>
MySQL (also PlanetScale, TiDB…) mysql://<user>:<password>@<host>:3306/<database>
MariaDB mariadb://<user>:<password>@<host>:3306/<database>
SQL Server / Azure SQL sqlserver://<user>:<password>@<host>:1433/<database>
Oracle oracle://<user>:<password>@<host>:1521/<service>
  • The password stays on your machine. config set writes it to ~/.understudy/understudy.env, which only you can read. understudy config shows the database without the password. Using Understudy from an agent? You can put UNDERSTUDY_DB in the env block of its MCP config instead.
  • A password with @ : / ? # or % in it must be URL-encoded (@ is %40): node -p 'encodeURIComponent("my@pass")'.
  • Drivers install themselves. SQLite comes with Understudy. The first time you use MongoDB, Postgres, MySQL/MariaDB, SQL Server or Oracle, Understudy installs its driver into ~/.understudy/drivers (a few seconds, once). Set UNDERSTUDY_NO_INSTALL=1 to install it yourself instead (npm install -g mongodb, pg, mysql2, mssql or oracledb). The same goes for typescript (23 MB), which only reading a Playwright script needs: it installs the first time you import one.
  • It can share a database. In a SQL database its tables are named understudy_flows, understudy_runs, and so on. In MongoDB it uses a database called understudy. UNDERSTUDY_DB_NAME changes that name.
  • Switching database starts with an empty memory: nothing is copied across. MONGODB_URI from older versions still works.
  • Connecting to a local MySQL 8 without TLS? Add ?allowPublicKeyRetrieval=true. A local SQL Server with its own certificate? Add ?trustServerCertificate=true.

No Chrome? understudy record myapp --new-browser --url https://your-app.example records in a browser Understudy opens (run npx playwright install chromium once first).

Use it

understudy record myapp                     # record with the extension
understudy save <hash> "log in as a member" # replay it, keep it if it passes
understudy import myapp login.spec.ts       # or start from a Playwright script
understudy flows myapp                      # what it knows how to do
understudy replay myapp log-in-as-a-member  # run one flow
understudy run myapp "sign in"              # find the flow for a goal, run it
understudy findings myapp                   # what looked broken
understudy emit myapp log-in-as-a-member    # export as a Playwright test

understudy --help lists everything else.

With an agent

Add the MCP server; settings come from your env file, so keys never go in the agent's config or the chat:

claude mcp add understudy -- npx -y -p @jeffawe/understudy understudy-mcp --env-file ~/.understudy/understudy.env
{ "mcpServers": { "understudy": {
    "command": "npx",
    "args": ["-y", "-p", "@jeffawe/understudy", "understudy-mcp", "--env-file", "~/.understudy/understudy.env"]
} } }

The agent can then recall and run flows, save what it explored, split flows into reusable pieces, and write down what it learns. The server tells the agent how to use it, so there's nothing else to load. Mid-run it may ask you to do a step only a person can do; answer in the chat.

Where your data goes

Understudy has no server, no account and no telemetry.

  • Recordings stay in ~/.understudy; the extension sends only to Understudy on 127.0.0.1.
  • Flows, notes and findings go to your database (the SQLite file, unless you chose another).
  • Your embedding model sees only short search texts (flow names, goals), never steps, typed values or cookies.
  • Passwords are never stored.

Recorder privacy policy: understudy.jeffawe.dev/privacy.html.

Learn more

License

Apache-2.0, see LICENSE.

About

Agent Memory for End to End Testing

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages