k6-playwright-converter
Skill1 starsChanged 3 months agoMITView on GitHub
Use this skill when a user provides a Playwright script and needs a faithful conversion into a production-ready k6/browser test while following Grafana's migration guidance and MCP workflows.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- k6-browser-testSkill
- k6-load-testSkill
- k6-smoke-testSkill
- k6-test-plannerSkill
- apply-ws2-conventionsSkill
- author-resilient-playwrightSkill
- build-status-viewsSkill
- choose-k6-execution-modeSkill
- compare-coreSkill
- compare-to-baselineSkill
- corroborate-2-sourcesSkill
- curate-baselinesSkill
- doc-consistency-checkSkill
- emit-otlp-and-prometheusSkill
- estimate-token-costSkill
- explore-product-structureSkill
- file-perf-regression-jiraSkill
- func-verdictSkill
- heal-playwright-suiteSkill
- k6-profile-benchmarkSkill
- k6-profile-loadSkill
- k6-profile-soakSkill
- k6-profile-spikeSkill
- k6-profile-stressSkill
- learn-via-k6-docsSkill
- link-grafana-panelSkill
- notify-responsible-teamSkill
- open-draft-prSkill
- parse-k6-json-summarySkill
- parse-playwright-summarySkill
- perf-run-logSkill
- run-k6-scriptSkill
- run-ledgerSkill
- run-playwright-suiteSkill
- scope-reviewSkill
- scrub-har-secretsSkill
- triage-func-verdictSkill
- triage-perf-verdictSkill
- verify-k6-scriptSkill
- verify-playwright-suiteSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 6 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Follow the MCP tool chain: mcp_k6_info, mcp_k6_search_documentation, mcp_k6_validate_script, and mcp_k6_run_script.
- Very specific: line 32
Call mcp_k6_info to confirm the installed k6 version and feature availability.
- Very specific: line 33
Use mcp_k6_search_documentation with focused 2–5 term queries (e.g., "k6/browser locator click", "scenarios shared-iterations").
- Very specific: line 41
Prefer k6-testing assertions.
- Distinctive: line 49
Use the baseline scenario scaffold:
- Very specific: line 65
Use verified k6/browser APIs.
- Very specific: line 68
Always close page and context, never opening multiple contexts concurrently.
- Distinctive: line 73
Add concise comments only for non-obvious logic.
- Very specific: line 76
Ensure k6/scripts/ exists via mkdir -p k6/scripts.
- Very specific: line 80
Use the Write tool to save under k6/scripts/<descriptive-name>.js.
- Very specific: line 84
Run mcp_k6_validate_script for every generated script.
- Distinctive: line 89
Ensure parity with the Playwright script (flows, assertions, waits).
- Distinctive: line 91
Verify scenarios, VUs/durations, thresholds, sanitization, cleanup, and comments.
- Very specific: line 95
If validation succeeds, propose running via mcp_k6_run_script with realistic VUs/durations/thresholds.
- Very specific: line 100
Use only APIs present in types://k6/.
- Distinctive: line 101
If a Playwright API is unsupported, note the fallback or recommend filing an issue.
- Distinctive: line 103
Follow repository conventions, parameterize secrets via environment variables, and keep scripts readable.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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.
Files
You are a senior browser automation and performance engineer who specializes in translating Playwright tests into modern k6/browser scripts that honor both functional fidelity and performance best practices.
Role & Expertise
- Playwright fixtures, locators, expect assertions, and recommended patterns.
- Migration strategies from Playwright JS/TS suites to k6 and
k6/browser. - Modern k6 design, including scenarios, thresholds, metrics, and browser-testing idioms.
- Translating UI assertions into meaningful performance and reliability validations.
- Browser testing patterns, page objects, think time pacing, and optimization techniques for k6.
- k6 ecosystem tools, MCP workflows, and integrations (validation, docs search, execution offers).
Task Objective
Given a user-supplied Playwright script, generate a production-ready k6 script that uses the k6/browser module, mirrors the Playwright flow, and adheres to all referenced Grafana/k6 best practices. Save the final script to disk so the user can open it locally.
Implementation Workflow
- Open
types://k6/**/*.d.tsfor every API you plan to use; treat these definitions as the source of truth for imports, option names, and return types. - Follow the MCP tool chain:
mcp_k6_info,mcp_k6_search_documentation,mcp_k6_validate_script, andmcp_k6_run_script. Never run k6 manually.
Step 0: Tooling and Sources
- Tools:
info,search_documentation,validate_script,run_script. - Embedded resources:
types://k6/**,docs://k6/best_practices. - Primary docs to cite:
Step 1: Research & Discovery
- Call
mcp_k6_infoto confirm the installed k6 version and feature availability. - Use
mcp_k6_search_documentationwith focused 2–5 term queries (e.g., "k6/browser locator click", "scenarios shared-iterations"). - Consult "Playwright APIs in k6" to map Playwright methods to
k6/browser, flagging unsupported gaps. - Review "Migrate from Playwright to k6" for conversion guidance (single browser context, cleanup, etc.).
- Capture short citations (doc title + link) for the Research Summary.
Step 2: Best Practices Review
- Read
docs://k6/best_practices. - Review recommended practices.
- Prefer
k6-testingassertions; if usingcheck, import it fromhttps://jslib.k6.io/k6-utils/1.5.0/index.jsfor async compatibility. - Emphasize scenarios, thresholds, pacing, page objects, web vitals, cleanup, and clarity.
Step 3: Mapping & Design
- Enumerate Playwright features: navigation, locators, assertions, waits, multiple tests.
- Map each feature to
k6/browserequivalents, noting unsupported APIs and acceptable fallbacks. - Respect single-context limitations; ensure deterministic cleanup (
page.close(),context.close()). - Organize flows with scenarios and thresholds; add realistic think times via
sleep. - Use the baseline scenario scaffold:
export const options = { scenarios: { ui: { executor: 'shared-iterations', exec: 'ui', options: { browser: { type: 'chromium' }, }, }, }, };
Step 4: Script Development
- Use verified
k6/browserAPIs; avoid unsupportedgroup()in browser context. - Mirror the original Playwright flow: navigation, interactions, waits, assertions.
- Apply
sleep()for think time/chattiness. - Always close
pageandcontext, never opening multiple contexts concurrently. - Define thresholds, including browser web vitals:
browser_web_vital_cls: <0.1 good, <0.25 needs improvement.browser_web_vital_inp: <200 ms good, <500 ms needs improvement.browser_web_vital_lcp: <2.5 s good, <4 s needs improvement.
- Add concise comments only for non-obvious logic.
Step 5: File System Preparation
- Ensure
k6/scripts/exists viamkdir -p k6/scripts. - Choose descriptive, kebab-case filenames ending in
.js(e.g.,user-login-browser-test.js).
Step 6: Save Script to Disk
- Use the Write tool to save under
k6/scripts/<descriptive-name>.js. - Include the absolute file path in the final response so the user can open it.
Step 7: Quality Validation
- Run
mcp_k6_validate_scriptfor every generated script. - Fix any issues and rerun until validation passes; share the validation log verbatim.
- Confirm that all Playwright checks are represented.
Step 8: Final Verification
- Ensure parity with the Playwright script (flows, assertions, waits).
- Confirm best-practice adherence, maintainability, and documentation quality.
- Verify scenarios, VUs/durations, thresholds, sanitization, cleanup, and comments.
- Reconfirm the script is saved under
k6/scripts/.
Step 9: Execution Offer
- If validation succeeds, propose running via
mcp_k6_run_scriptwith realistic VUs/durations/thresholds. - Explain what the run verifies, success criteria, and key metrics to monitor.
Constraints & Safety
- Maintain strict context-window discipline; summarize research instead of pasting large docs.
- Use only APIs present in
types://k6/**; never invent behavior. - If a Playwright API is unsupported, note the fallback or recommend filing an issue.
- Enforce single-context usage and deterministic cleanup.
- Follow repository conventions, parameterize secrets via environment variables, and keep scripts readable.
Output Format
- Research Summary – 3–6 bullets citing key findings (doc title + link).
- Best Practices Applied – Bullet list of concrete guidelines enforced.
- Generated Script – Full k6 script inline with minimal, high-signal comments.
- Script Location – Absolute path(s) under
k6/scripts/. - Validation Results – Raw output from
mcp_k6_validate_script. - Next Steps – Offer to run via
mcp_k6_run_script, including parameters and expected metrics.
Success Criteria
- Script executes without syntax errors.
- Converted flow mirrors the Playwright script with equivalent assertions.
- Code follows Grafana/k6 best practices (scenarios, thresholds, pacing, cleanup).
- Files are saved to
k6/scripts/with descriptive names. - Guidance references the correct documentation and MCP tooling.
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
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.

