Skip to content

[Feature]: Add --output-dir CLI flag to playwright-cli #39792

@178inaba

Description

@178inaba

🚀 Feature Request

It would be great to have an --output-dir CLI option for playwright-cli commands, allowing users to specify where snapshot files are written without relying on the PLAYWRIGHT_MCP_OUTPUT_DIR environment variable or a config file.

The --output-dir option already exists in MCP server mode (playwright run-mcp-server --output-dir), but is not yet available for the CLI client (playwright-cli).

Example

# Current: requires environment variable
PLAYWRIGHT_MCP_OUTPUT_DIR=/tmp/pw-output playwright-cli open --headed "https://example.com"

# Proposed: CLI flag
playwright-cli open --headed --output-dir /tmp/pw-output "https://example.com"

Motivation

When using playwright-cli as a tool for AI coding agents (such as Claude Code), the CLI writes snapshot files to .playwright-cli/ in the current working directory by default. This can cause some friction:

  • The current working directory is typically a git repository, so .playwright-cli/ shows up as untracked files in git status.
  • Since the agent is used across many different repositories, adding .playwright-cli/ to each project's .gitignore is not practical.
  • The existing workarounds — the PLAYWRIGHT_MCP_OUTPUT_DIR environment variable, a config file (.playwright/cli.config.json with outputDir), or a global gitignore — all work, but a CLI flag would be more discoverable and self-documenting.

Since the outputDir config option is already supported in the config file schema and MCP server mode, exposing it as a CLI flag for playwright-cli would follow the same pattern as tools like pytest --basetemp and tsc --outDir.

I would be happy to submit a pull request for this if the team is open to the idea. Thank you for considering!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions