Skip to content

feat: add user-configurable browser selection via .claude/playwright.local.json#27

Open
citadelgrad wants to merge 2 commits intolackeyjb:mainfrom
citadelgrad:choose-browser
Open

feat: add user-configurable browser selection via .claude/playwright.local.json#27
citadelgrad wants to merge 2 commits intolackeyjb:mainfrom
citadelgrad:choose-browser

Conversation

@citadelgrad
Copy link

This release adds support for configuring the browser used by the playwright-skill through a per-project configuration file, eliminating the hard dependency on Chrome and allowing users to use their preferred browser.

Problem

The skill previously hardcoded Chrome as the browser, requiring users to have Chrome installed. Users with alternative browsers (Brave, Edge, Firefox) or those preferring Playwright's bundled browsers had no configuration option. The skill also didn't respect any local configuration files.

Solution

Added .claude/playwright.local.md configuration file support with YAML frontmatter for browser settings:

---
browser: chromium | firefox | webkit
channel: chrome | msedge | chrome-beta | msedge-beta
headless: true | false
executablePath: /path/to/browser
slowMo: 100
---

Changes

lib/helpers.js (+206 lines)

  • Added readBrowserConfig() - reads config from .claude/playwright.local.md
  • Added findConfigFile() - searches upward from cwd to find config
  • Added parseYamlFrontmatter() - simple YAML parser for frontmatter
  • Updated launchBrowser() to use config and support channel/executablePath

run.js (+74 lines)

  • Added launchConfiguredBrowser() - auto-injected function for scripts
  • Added getBrowserConfig() - exposes config to scripts
  • Updated installPlaywright() to skip browser download if executablePath set
  • Config-aware browser installation based on user preferences

SKILL.md (+338/-184 lines)

  • Added "Browser Configuration" section with full documentation
  • Updated all code examples to use launchConfiguredBrowser() instead of hardcoded chromium.launch()
  • Added troubleshooting for browser config issues
  • Added optional frontmatter fields per Agent Skills spec:
    • license: MIT
    • compatibility: Requires Node.js
    • metadata: author, version

README.md (+98/-25 lines)

  • Restructured for better flow (moved "What is a Skill?" earlier)
  • Added comprehensive "Configuration" section with examples
  • Added Brave browser paths for macOS/Linux/Windows
  • Merged "Default Settings" into Configuration table
  • Added "Configurable Browser" to Features list
  • Updated Dependencies with Node.js version requirement

Version bump to 4.2.0

  • .claude-plugin/plugin.json
  • skills/playwright-skill/package.json
  • skills/playwright-skill/SKILL.md (metadata.version)

Testing

Verified with:

  • Playwright's bundled Chromium (headless)
  • Brave Browser via executablePath (headless)
  • Config file discovery from nested directories

Breaking Changes

None. Existing scripts using chromium.launch() continue to work. New launchConfiguredBrowser() is additive and recommended for new scripts.

…local.md

This release adds support for configuring the browser used by the playwright-skill
through a per-project configuration file, eliminating the hard dependency on
Chrome and allowing users to use their preferred browser.

## Problem

The skill previously hardcoded Chromium/Chrome as the browser, requiring users
to have Chrome installed. Users with alternative browsers (Brave, Edge, Firefox)
or those preferring Playwright's bundled browsers had no configuration option.
The skill also didn't respect any local configuration files.

## Solution

Added `.claude/playwright.local.md` configuration file support with YAML
frontmatter for browser settings:

```yaml
---
browser: chromium | firefox | webkit
channel: chrome | msedge | chrome-beta | msedge-beta
headless: true | false
executablePath: /path/to/browser
slowMo: 100
---
```

## Changes

### lib/helpers.js (+206 lines)
- Added `readBrowserConfig()` - reads config from .claude/playwright.local.md
- Added `findConfigFile()` - searches upward from cwd to find config
- Added `parseYamlFrontmatter()` - simple YAML parser for frontmatter
- Updated `launchBrowser()` to use config and support `channel`/`executablePath`

### run.js (+74 lines)
- Added `launchConfiguredBrowser()` - auto-injected function for scripts
- Added `getBrowserConfig()` - exposes config to scripts
- Updated `installPlaywright()` to skip browser download if executablePath set
- Config-aware browser installation based on user preferences

### SKILL.md (+338/-184 lines)
- Added "Browser Configuration" section with full documentation
- Updated all code examples to use `launchConfiguredBrowser()` instead of
  hardcoded `chromium.launch()`
- Added troubleshooting for browser config issues
- Added optional frontmatter fields per Agent Skills spec:
  - license: MIT
  - compatibility: Requires Node.js
  - metadata: author, version

### README.md (+98/-25 lines)
- Restructured for better flow (moved "What is a Skill?" earlier)
- Added comprehensive "Configuration" section with examples
- Added Brave browser paths for macOS/Linux/Windows
- Merged "Default Settings" into Configuration table
- Added "Configurable Browser" to Features list
- Updated Dependencies with Node.js version requirement

### Version bump to 4.2.0
- .claude-plugin/plugin.json
- skills/playwright-skill/package.json
- skills/playwright-skill/SKILL.md (metadata.version)

## Testing

Verified with:
- Playwright's bundled Chromium (headless)
- Brave Browser via executablePath (headless)
- Config file discovery from nested directories

## Breaking Changes

None. Existing scripts using `chromium.launch()` continue to work.
New `launchConfiguredBrowser()` is additive and recommended for new scripts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@lackeyjb
Copy link
Owner

@citadelgrad this a great add, thank you! Curious why use markdown for the config file though? I think it would simplify things to use a JSON file. Then we could remove all the frontmatter parsing

@citadelgrad
Copy link
Author

@lackeyjb Using frontmatter is a required part of the offical standard. And since this plugin is on the Claude Code Offical plugins list. I figured we should verify everything against the standard.

https://agentskills.io/specification#frontmatter-required

@lackeyjb
Copy link
Owner

The spec for frontmatter is for the SKILL.md file itself. The playwright config file that you propose doesn't need to adhere to this since it's just a config for a script (run.js).

  Addresses review feedback - simplifies config by using JSON instead of
  YAML frontmatter in markdown. Removes custom frontmatter parser (~35 lines)
  in favor of JSON.parse().
@citadelgrad
Copy link
Author

This release adds support for configuring the browser used by the playwright-skill through a per-project configuration file, eliminating the hard dependency on Chrome and allowing users to use their preferred browser.

Problem

The skill previously hardcoded Chrome as the browser, requiring users to have Chrome installed. Users with alternative browsers (Brave, Edge, Firefox) or those preferring Playwright's bundled browsers had no configuration option. The skill also didn't respect any local configuration files.

Solution

Added .claude/playwright.local.json configuration file support with these options:

Option Values Description
browser chromium, firefox, webkit Browser engine (default: chromium)
channel chrome, msedge, etc. Use installed Chrome/Edge
headless true, false Run without visible window (default: false)
executablePath Path string Custom browser executable path
slowMo Number (ms) Slow down operations for debugging

Changes

lib/helpers.js

  • Added readBrowserConfig() - reads config from .claude/playwright.local.json
  • Added findConfigFile() - searches upward from cwd to find config
  • Updated launchBrowser() to use config and support channel/executablePath

run.js

  • Added launchConfiguredBrowser() - auto-injected function for scripts
  • Added getBrowserConfig() - exposes config to scripts
  • Updated installPlaywright() to skip browser download if executablePath set
  • Config-aware browser installation based on user preferences

SKILL.md

  • Added "Browser Configuration" section with full documentation
  • Updated all code examples to use launchConfiguredBrowser() instead of hardcoded chromium.launch()
  • Added troubleshooting for browser config issues
  • Added optional frontmatter fields per Agent Skills spec

README.md

  • Restructured for better flow
  • Added comprehensive "Configuration" section with JSON examples
  • Added Brave browser paths for macOS/Linux/Windows
  • Added "Configurable Browser" to Features list

Version bump to 4.2.0

Testing

Verified with:

  • Playwright's bundled Chromium (headless)
  • Brave Browser via executablePath (headless)
  • Config file discovery from nested directories
  • Unit tests for JSON config parsing

Breaking Changes

None. Existing scripts using chromium.launch() continue to work. New launchConfiguredBrowser() is additive and recommended for new scripts.

@citadelgrad citadelgrad changed the title feat: add user-configurable browser selection via .claude/playwright.local.md feat: add user-configurable browser selection via .claude/playwright.local.json Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants