Skip to content

Repository files navigation

Scout logo

playwright-scout

Give your coding agent a map of your Playwright suite.

CI npm License: MIT

playwright-scout is an agent skill, static index, and search tool for Playwright projects. It helps coding agents understand existing page objects, helpers, fixtures, tests, tags, routes, and relationships before they change or extend a suite. It can also provide a bounded, source-backed brief for a task.

The CLI and core packages are distributed on npm as playwright-scout and playwright-scout-core. This checkout is version 0.5.1. To try it locally, run npm ci, npm run build, then node packages/cli/dist/bin.js --help.

Scout reads your source code without running your tests or project code, giving agents a reliable map they can query before writing new code. That means new tests can build on what is already there instead of creating duplicates.

Why use it?

As Playwright suites grow, useful code becomes hard to find. Scout gives you a quick map of the suite and lets you ask questions such as:

  • “Do we already have a login helper?”
  • “Which fixture provides an authenticated page?”
  • “Where is checkout coverage implemented?”

That makes it especially useful as a pre-flight step for AI coding agents.

Quick start

Requires Node.js 20 or newer.

npm install -D playwright-scout

# Build or refresh the project index
npx playwright-scout map

# Search for existing code
npx playwright-scout find login
npx playwright-scout find checkout coupon

# Inspect a specific result
npx playwright-scout show LoginPage.login

# Get a small task capsule, then inspect cited evidence as needed
npx playwright-scout context "add expired coupon coverage"
npx playwright-scout show CheckoutPage.applyCoupon
npx playwright-scout impact --file pages/checkout.page.ts

# Optional team-authored business context
npx playwright-scout context "add expired coupon coverage" --business-context docs/business

Scout writes the index to .scout/index.json. Add .scout/ to your repository’s .gitignore; the index can always be regenerated.

Commands

Command What it does Example
init Preview what Scout would index, without writing files. npx playwright-scout init
map Build or refresh the project index. npx playwright-scout map
find Search helpers, methods, tests, fixtures, and tags. npx playwright-scout find login
context Give an agent a bounded task capsule with cited reuse candidates. npx playwright-scout context "authenticated checkout"
show Inspect a result by ID or readable label. npx playwright-scout show LoginPage.login
impact Show known static links for a symbol or source file. npx playwright-scout impact --file pages/checkout.page.ts
plan Create an evidence-based reuse plan for an agent task. npx playwright-scout plan "add checkout coupon coverage"
doctor Experimental: check a narrow set of static config facts. npx playwright-scout doctor
review Experimental: review one file for limited test-code patterns. npx playwright-scout review --file tests/checkout.spec.ts
install-skill Install the agent instructions for a supported coding assistant. npx playwright-scout install-skill --target claude

Common options

  • --json — return structured output for agents and scripts.
  • --root <dir> — run Scout against a different project directory.
  • --if-stale — with map, rebuild the index only when the source has changed.
  • --max-chars <n> — with context, bound the complete response (default 1800 characters). Use show on a cited ID for more evidence.
  • --target <agent> — with install-skill, choose claude, agents, github, cursor, qwen, or all.

See the CLI reference for all options.

By default, the skill is installed inside the current project:

Target Location
agents .agents/skills/playwright-scout/SKILL.md
claude .claude/skills/playwright-scout/SKILL.md
github .github/skills/playwright-scout/SKILL.md
cursor .cursor/skills/playwright-scout/SKILL.md
qwen .qwen/skills/playwright-scout/SKILL.md

Use --global with --target claude to install it at ~/.claude/skills/playwright-scout/SKILL.md instead.

How it works

Scout performs two static-analysis passes:

  1. It parses source files to identify tests, page objects, helpers, fixtures, tags, and navigation routes.
  2. It resolves local imports, exports, and direct fixture providers to connect tests with the code they use.

The result is a deterministic JSON index that can be searched from the CLI or used through the library API.

init previews the Playwright layout and counts before indexing, without writing files. It accepts an optional business-context path and does not create one or change Playwright configuration.

context gives an agent a small task capsule for creation or maintenance work. It lists omissions when the character bound cuts details; show <cited-id> retrieves a specific indexed entry. impact --file reports tests linked by the static index and the reason for each link. These results are advisory: dynamic calls and unsupported fixture shapes can leave relationships unknown. Scout does not infer business coverage requirements from source code.

Teams can optionally point context at a JSON file or directory of versioned business entries covering journeys, terminology, rules, and risks. Scout retrieves only task-relevant entries with file and line citations. These are user-provided data, never proof that a test covers a rule. The path defaults to the project; reading outside it requires an explicit flag.

When reuse or change impact is unclear, the installed skill guides an agent to refresh the index, inspect source-backed matches, and reuse suitable code. For a straightforward local edit with a clear nearby example, it can work directly without Scout queries; context is not a mandatory step.

doctor and review are experimental, opt-in commands. They make suggestions only when asked and never block ordinary suite work. Their findings are based on a deliberately small set of static checks; an empty result is not proof that a framework has no issues.

Using the library

import { buildIndex, searchIndex } from 'playwright-scout-core';

const index = await buildIndex({ root: '/path/to/your/project' });
const matches = searchIndex(index, 'login coupon', { kind: 'any', limit: 10 });

All query commands support --json for structured agent output. See the schema reference for the index format and the CLI reference for all options.

Known limitations

Scout is intentionally focused on static discovery. It does not:

  • run tests or execute project code;
  • make network or LLM calls;
  • support CommonJS-only projects (require / module.exports);
  • fully resolve dynamic test titles or navigation URLs;
  • resolve every fixture shape, indirect call, or runtime dependency;
  • analyze multiple Playwright configs in one run.

Exported aliases of a reassigned let test object (for example, let impl = a; impl = b; export const test = impl) are still indexed as helpers.

For the complete behavior and supported patterns, see the v0.3 guidance specification, v0.2 specification, and evaluation notes. The v0.1 specification remains the baseline for earlier commands.

Evaluation status

The two feasibility pilots had inconsistent results; no efficiency or efficacy claim is made. See the pilot report. Controlled agent runs are paused.

Development

npm ci
npm run check
npm test
npm run build

Try it against the included sample suite:

node packages/cli/dist/bin.js map --root fixtures/sample-suite
node packages/cli/dist/bin.js find login --root fixtures/sample-suite

License

MIT