Capture a screenshot and HTML analysis of the current page using an AI model.The
snapshot command is the primary page observation tool. It captures a screenshot and the full HTML of the current page, then sends the screenshot and a condensed (token-optimized) version of the HTML to an AI model for analysis against your stated objective.
Use snapshot before guessing at selectors, after workflow failures, and whenever the visible page state is unclear.
Required flags
The session to snapshot.
What you want the AI to find, analyze, or explain. A single objective can
include multiple questions or analysis tasks. You don’t need to run separate
snapshots for each question.
Background information that helps the AI understand the current state of the
page. Describe what you just did, what you expected to happen, and what the
page should contain.
Optional flags
Target a specific page ID within the session. Use
npx libretto pages --session <name> to list page IDs when a popup or new tab is open. See pages for details.What snapshot produces
For each run,snapshot saves three files under .libretto/sessions/<session>/snapshots/<snapshot-id>/:
| File | Contents |
|---|---|
page.png | Full-page screenshot |
page.html | Raw page HTML |
page.condensed.html | Token-optimized condensed HTML sent to the model |
When to use snapshot
- Before writing a selector. Use snapshot to confirm the element structure rather than guessing.
- After a workflow step fails. Inspect the exact page state the failure left behind.
- When the page has rendered content that isn’t obvious from the URL alone.
- When you need answers to multiple questions about a page in a single call.
Timeout
Snapshot sends a request to an external AI API and waits for the full analysis response. Depending on page complexity and model speed, this can take 30–90 seconds or more.Configuration
Snapshot analysis requires a configured AI model. Runnpx libretto setup on first setup, or use npx libretto ai configure <provider> to set or change the model later. Credentials are read from environment variables or a .env file at your project root.
Supported providers: openai, anthropic, gemini, vertex.
Examples
exec
Run Playwright code to prototype interactions after using snapshot to identify elements.
run & resume
Run a full workflow file and use snapshot to debug failures.