puppeteer

puppeteer is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 1,826 tokens per session, scanned A, original, CC0-1.0.

A set of Node.js guidelines for Puppeteer, a tool that controls a web browser through code.

In plain words
What is it for?
Use it to build web scraping, browser automation, and browser-based tests with reliable page interactions and cleanup.
Why use it?
It helps avoid brittle browser scripts, timing errors, leaked browser processes, and difficult-to-maintain automation code.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it to build web scraping, browser automation, and browser-based tests with reliable page interactions and cleanup.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer
About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,570 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for puppeteer

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer/github.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for puppeteer

Your own site · 80×15
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/puppeteer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,826 This file is loaded in full into every session.
When invoked 1,826 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01826 $0.01826
Opus 5 $0.00913 $0.00913
Sonnet 5 $0.00365 $0.00365
Haiku 4.5 $0.00183 $0.00183

Measured 5d ago against content hash 4e70b935f234, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

puppeteer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/puppeteer.mdc · 231 lines

How it starts

The opening of the file, as written. The whole thing — 231 lines — stays where its author put it; the contents beside it link to each section on GitHub.

puppeteer Best Practices

Puppeteer is the definitive library for headless browser automation in Node.js. Adhere to these guidelines to build reliable, fast, and maintainable scripts.

1. Foundation: Async/Await & Browser Management

Always use async/await for clear, sequential asynchronous code. Manage browser instances carefully.

// ❌ BAD: Synchronous or callback-hell
// puppeteer.launch().then(browser => { ... });

// ✅ GOOD: Clear async/await structure
import puppeteer from 'puppeteer';

async function runAutomation() {
  const browser = await puppeteer.launch({ headless: 'new' }); // Always use 'new' headless mode
  const page = await browser.newPage();

  try {
    // ... automation logic ...
  } catch (error) {
    console.error('Automation failed:', error);
  } finally {
    await browser.close(); // Ensure browser always closes
  }
}

runAutomation();

2. Interactions: Embrace page.locator()

page.locator() is the modern, robust way to interact with elements. It automatically handles waiting for elements to be visible, enabled, and stable, eliminating race conditions.

// ❌ BAD: Manual waiting and brittle selectors
// await page.waitForSelector('.my-button');
// await page.click('.my-button');
// await page.$eval('h1', el => el.innerText); // No auto-waiting for element presence

// ✅ GOOD: Use page.locator() for all interactions
async function interactWithPage(page) {
  // Click a button
  await page.locator('button.submit-btn').click();

  // Fill an input field
  await page.locator('input[name="username"]').fill('myUsername');

  // Extract text with auto-waiting
  const title = await page.locator('h1.page-title').evaluate(el => el.innerText);
  console.log('Page Title:', title);

  // Wait for an element to appear without interacting
  await page.locator('.loading-spinner').wait({ state: 'hidden' }); // Wait for it to disappear
}

3. Efficiency & Performance

Optimize Puppeteer scripts by reducing unnecessary resource loading and leveraging parallel execution.

Read the full file on GitHub · 231 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 231 lines · 1,826 tokens per session scan A 4e70b935f234

Subscribe to this mod's changes

puppeteer is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,570 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,826 tokens to every session, about $0.0091 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.