Skip to main content
One-shot generation means you give your agent a goal and a URL, and it does the rest. The agent opens a live browser, explores the site, figures out the page structure, and writes a complete workflow file — without you needing to record actions or hand-hold the process. This is the fastest path from idea to working automation when you’re starting from scratch on a site you haven’t automated before.

Example prompt

Use the Libretto skill. Go on LinkedIn and scrape the first 10 posts for content, who posted it, the number of reactions, the first 25 comments, and the first 25 reposts.
Your agent opens a browser window for you to log in, then takes over: exploring the feed, identifying selectors, prototyping interactions, and assembling the final workflow file.

How the agent works

1

Opens a headed browser

The agent starts with:
npx libretto open https://example.com --headed
Headed mode keeps the browser window visible so you can log in before the agent begins exploring.
2

Reviews the site's security posture

Before choosing how to capture data, the agent reads the site-security reference and checks for bot detection, monkey-patched fetch, and challenge pages. This determines whether to use direct fetch() calls, passive network interception, or DOM extraction.
3

Takes a snapshot to understand the page

npx libretto snapshot \
  --objective "Identify feed post elements and their structure" \
  --context "I just loaded the main feed and need the post container selectors."
Snapshot captures a screenshot and the page HTML, then uses an LLM to analyze it — keeping the heavy visual context out of your coding agent’s context window.
4

Uses exec to prototype interactions

The agent tests selectors and interaction patterns before committing them to code:
npx libretto exec "return await page.locator('.feed-shared-update-v2').count()"
Short exec calls let the agent validate each step against the live page without writing and re-running a full script each time.
5

Writes the workflow file

Once the agent has a working path, it generates a TypeScript file that exports a workflow() instance:
import { workflow } from "libretto";

type Output = {
  posts: Array<{
    author: string;
    content: string;
    reactions: number;
    comments: string[];
    reposts: string[];
  }>;
};

export const linkedInFeedScraper = workflow<{}, Output>(
  async (ctx): Promise<Output> => {
    const { page } = ctx;

    await page.goto("https://www.linkedin.com/feed/");
    await page.waitForSelector(".feed-shared-update-v2");

    // Collect first 10 posts
    const postElements = await page.locator(".feed-shared-update-v2").all();
    const posts = [];

    for (const post of postElements.slice(0, 10)) {
      const author = await post.locator(".update-components-actor__name").textContent();
      const content = await post.locator(".feed-shared-text").textContent();
      // ... extract reactions, comments, reposts
    }

    return { posts };
  },
);
6

Validates with a headless run

npx libretto run ./linkedin-feed.ts linkedInFeedScraper --headless
The agent confirms actual returned output, not just process exit status. If the run fails, the browser stays open for inspection.

When to use this approach

  • You’re automating a site for the first time and don’t know its structure
  • The task is self-contained and clearly scoped (“get the first 10 posts”)
  • You want a working script with minimal back-and-forth
  • You don’t need to demonstrate the workflow manually first

Tips

Always use --headed when the site requires login. The browser window opens on your screen so you can authenticate, and then the agent takes over. Without --headed, the agent has no way to get past a login wall.
Give your agent a specific, measurable objective. “Scrape the first 10 posts” is actionable. “Get some LinkedIn data” is not — the agent will have to guess at scope and structure.
Make sure your coding agent has the Libretto skill installed before starting. Run npx libretto init in your project root to set up the workspace and configure snapshot analysis if you haven’t already.

Interactive script building

Show the agent your workflow manually and let it turn your actions into code.

Convert to network requests

Speed up an existing browser script by switching to direct API calls.

Build docs developers (and LLMs) love