Install the package
Install Libretto from npm:Libretto requires Node.js 18 or later. It installs Playwright as a direct dependency, so you don’t need a separate Playwright install.
Initialize your workspace
Run
init once per project. This command downloads Chromium if it isn’t already installed, creates the .libretto/ directory structure, writes a .libretto/.gitignore, and copies the agent skill files into .agents/skills/libretto and .claude/skills/libretto.Run
init yourself in a terminal — not through an agent. It may prompt for input and starts a Chromium download that takes a moment.Configure an AI provider
Snapshot analysis requires a vision-capable model. Choose your provider:This writes the selected model to
You can also pass a full model string to use a specific version:Provider credentials are read from your shell environment or a Libretto uses the Vercel AI SDK under the hood. Install only the peer dependency for your chosen provider:
.libretto/config.json. The default models are:| Provider | Default model |
|---|---|
openai | openai/gpt-5.4 |
anthropic | anthropic/claude-sonnet-4-6 |
gemini | google/gemini-3-flash-preview |
vertex | vertex/gemini-2.5-pro |
.env file at the project root. Set the appropriate key:Open a browser
Launch a headed Chromium window and navigate to a URL:To use a named session (recommended when running multiple automations):Use
--headless if you don’t need to see the browser:Take a snapshot
snapshot captures a PNG screenshot and the page HTML, then sends both to your configured vision model. Always provide --objective (what you want the model to find or analyze) and --context (what you know about the current state):Execute Playwright code
Use For longer scripts, pipe from stdin with Let failures throw. Don’t wrap
exec to run Playwright TypeScript against the open page. The code runs in a context that has page, context, browser, state, fetch, and Buffer available as globals:-:exec code in try/catch — surfacing errors is how you debug.Run a workflow file
Once you’ve built a workflow file, run it with Run headless with input parameters:Run with a saved auth profile:The second argument (
npx libretto run:main) is the name of the exported workflow() instance in the file. See the Library API reference for how to structure workflow files.