agentleFS
CloudflareKnown publishercloudflare/kumo-astro/packages/kumo-screenshot-worker/AGENTS.md

kumo-astro / kumo-screenshot-worker

AGENTS.md4 starsChanged 9 months agoMITView on GitHub

Cloudflare Worker that uses Puppeteer + Browser Rendering to capture screenshots of Kumo docs pages. Used for visual regression testing. Parent: See root AGENTS.md for monorepo context. Never commit secret values. .dev.vars is gitignored at the root level. All requests require X-API-Key: <API_KEY> header. Returns { results: ScreenshotResult[] } where each result has a base64-encoded image or an error string. Limits: max 50 pages per batch, max 64 KB per css/js action payload. When captureSections: true, the worker looks for…

  • Reads credentials

The file

We split this AGENTS.md into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All requests require X-API-Key: <API_KEY> header.

    line 48
  2. Very specific:

    When captureSections: true, the worker looks for elements with data-vr-demo, data-vr-section, and data-vr-title attributes in the DOM.

    line 71
  3. Very specific:

    URL validation: all URLs are validated as https:// (or http://localhost).

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Screenshot Worker (@cloudflare/kumo-screenshot-worker)

Cloudflare Worker that uses Puppeteer + Browser Rendering to capture screenshots of Kumo docs pages. Used for visual regression testing.

Parent: See root AGENTS.md for monorepo context.

STRUCTURE

kumo-screenshot-worker/
├── src/
│   └── index.ts          # Worker entry — auth, validation, screenshot logic
├── wrangler.jsonc        # Worker config (no secrets committed)
├── tsconfig.json         # Workers + DOM lib (DOM needed for evaluate() callbacks)
├── .dev.vars.example     # Template for local secrets
└── AGENTS.md             # This file

SETUP

Local dev:

cp .dev.vars.example .dev.vars   # then fill in API_KEY
pnpm --filter @cloudflare/kumo-screenshot-worker dev

Deploy:

# Set secret (one-time per environment):
pnpm --filter @cloudflare/kumo-screenshot-worker exec wrangler secret put API_KEY

# Deploy:
pnpm --filter @cloudflare/kumo-screenshot-worker deploy

SECRETS

NameHow setDescription
API_KEYwrangler secret put API_KEYShared secret sent as X-API-Key request header

Never commit secret values. .dev.vars is gitignored at the root level.

API

All requests require X-API-Key: <API_KEY> header.

POST /batch

{
  "baseUrl": "https://kumo-ui.com",
  "pages": [
    {
      "url": "/components/button",
      "captureSections": true,
      "viewport": { "width": 1440, "height": 900 }
    }
  ]
}

Returns { results: ScreenshotResult[] } where each result has a base64-encoded image or an error string.

Limits: max 50 pages per batch, max 64 KB per css/js action payload.

Section Capture

When captureSections: true, the worker looks for elements with data-vr-demo, data-vr-section, and data-vr-title attributes in the DOM. These are set via vrSection and vrTitle props on ComponentExample.astro in the docs site.

SECURITY NOTES

  • URL validation: all URLs are validated as https:// (or http://localhost). Private IP ranges and cloud-metadata endpoints are blocked to prevent SSRF.
  • Selector injection prevention: sectionSelector from the request is passed as a parameter to page.evaluate(), never interpolated into eval strings.
  • action.js: executes arbitrary JavaScript in the browser context. This is intentional — callers are trusted via API_KEY. Never expose the worker without the auth check.
  • CORS: currently * (permissive). Acceptable for server-to-server use. Restrict to specific origins if the worker is ever called from a browser.

COMMANDS

pnpm --filter @cloudflare/kumo-screenshot-worker dev        # Local dev server
pnpm --filter @cloudflare/kumo-screenshot-worker deploy     # Deploy to Cloudflare
pnpm --filter @cloudflare/kumo-screenshot-worker typecheck  # TypeScript check
pnpm --filter @cloudflare/kumo-screenshot-worker lint       # oxlint

NOTES

  • tsconfig.json includes "DOM" in lib — required so TypeScript understands the DOM code inside page.evaluate() callbacks, even though the Worker host has no DOM.
  • Buffer usage requires nodejs_compat flag in wrangler.toml (already set).
  • A fresh browser page is created per URL to prevent cookie/localStorage/style bleed between pages.
  • External endpoint: kumo-screenshot-worker.design-engineering.workers.dev

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.