run-k6-script
Skill1 starsChanged 3 months agoMITView on GitHub
Type: skill (deterministic) · Used by: perf-run-one, perf-sweep · Status: LIVE (P1) You will execute a single k6 test script and save its output. Follow these steps exactly. Required inputs (caller must supply all three): - script_path — path to the .js script file - run_id — a unique string identifier for this run (e.g. demo-web_benchmark_stg_20260605T143022Z) - env — stg or prod (case-insensitive) Reject and STOP if any of the following are true: - script_path does not start with live/…
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- k6-browser-testSkill
- k6-load-testSkill
- k6-playwright-converterSkill
- 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-ledgerSkill
- run-playwright-suiteSkill
- scope-reviewSkill
- scrub-har-secretsSkill
- triage-func-verdictSkill
- triage-perf-verdictSkill
- verify-k6-scriptSkill
- verify-playwright-suiteSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 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.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Create reports/<run_id>/ if it does not exist.
- Very specific: line 63
Use the k6 x mcp tool to execute k6 commands when available.
- Very specific: line 80
If this was a browser script AND reports/<run_id>/trace.har exists (regardless of exit code):
- Very specific: line 82
P1–P3 interim (scrub-har-secrets not yet live): Delete reports/<run_id>/trace.har unconditionally.
- Very specific: line 84
If K6_BROWSER_SCREENSHOTS_OUTPUT was set and screenshots exist, save them under reports/<run_id>/screenshots/.
- Very specific: line 88
Verify reports/<run_id>/summary.json exists and is valid JSON.
≈ “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
run-k6-script
Execute one k6 script and save the raw JSON summary artifact.
Type: skill (deterministic) · Used by: perf-run-one, perf-sweep · Status: LIVE (P1)
Prompt
You will execute a single k6 test script and save its output. Follow these steps exactly.
1 — Validate inputs
Required inputs (caller must supply all three):
script_path— path to the .js script filerun_id— a unique string identifier for this run (e.g.demo-web_benchmark_stg_20260605T143022Z)env—stgorprod(case-insensitive)
Reject and STOP if any of the following are true:
script_pathdoes not start withlive/(absolute or../paths are forbidden)- The resolved file does not exist under the
live/directory envisprodAND the script is not abenchmarkprofile (1-VU benchmark is the only prod-allowed profile — check the filename forbenchmarkor check the caller's profile field)run_idis empty or missing
2 — Prepare the output directory
Create reports/<run_id>/ if it does not exist. Do this as part of the same command that
invokes k6 (step 4's mkdir -p reports/<run_id> && prefix) — never as a separate step run
first, since a separate step is easy to skip and k6 run --summary-export=... fails outright
(cannot open the export path) if the directory isn't there yet.
3 — Detect script type
Inspect the script file for browser test indicators:
import { browser } from 'k6/browser'— browser scriptimport { chromium } from 'k6/browser'— browser script- Any other
.js— HTTP script
4 — Build and run the k6 command
HTTP script:
mkdir -p reports/<run_id> && \
k6 run \
--summary-export=reports/<run_id>/summary.json \
--tag run_id=<run_id> \
--tag env=<env> \
<script_path>Browser script (add env var for headless + HAR capture):
mkdir -p reports/<run_id> && \
K6_BROWSER_HEADLESS=true \
K6_BROWSER_HAR_EXPORT=reports/<run_id>/trace.har \
k6 run \
--summary-export=reports/<run_id>/summary.json \
--tag run_id=<run_id> \
--tag env=<env> \
<script_path>Use the k6 x mcp tool to execute k6 commands when available. If the MCP tool is unavailable, fall back to a Bash call with the same command.
Capture stdout, stderr, and the exit code.
5 — Handle exit codes
| Exit code | Meaning | Action |
| 0 | All thresholds passed | Continue |
| 97 | k6 abort / crash (exit-97=FAIL per compare-core rule) | Write reports/<run_id>/run-error.txt with stderr; mark run as FAILED; STOP |
| 99 | Thresholds failed (k6 threshold violation) | Continue — parse-k6-json-summary will surface these |
| Any other non-zero | Unexpected error | Write reports/<run_id>/run-error.txt with stderr; mark run as FAILED; STOP |
Gate parity:
run-k6-actionenforce mode also usesexit_code_on_red: 99(perf-gate.yaml). 99 always means "red verdict", 97 always means "crash" — on both delivery surfaces. 97 is never used to signal red.
6 — HAR scrub (ALL browser runs — unconditional)
If this was a browser script AND reports/<run_id>/trace.har exists (regardless of exit code):
- P4+: Pass the HAR file to the
scrub-har-secretsskill before persisting anywhere. Save the scrubbed result asreports/<run_id>/trace.scrubbed.har. Delete the rawtrace.har. - P1–P3 interim (scrub-har-secrets not yet live): Delete
reports/<run_id>/trace.harunconditionally. Do NOT persist a raw HAR. Record the deletion inreports/<run_id>/run-error.txtwith noteHAR deleted (scrub-har-secrets not yet live at this phase).
If K6_BROWSER_SCREENSHOTS_OUTPUT was set and screenshots exist, save them under reports/<run_id>/screenshots/.
7 — Confirm output
Verify reports/<run_id>/summary.json exists and is valid JSON. If the file is missing or empty, mark the run as FAILED with an error message.
8 — Return
Return a summary object:
{
"run_id": "<run_id>",
"script_path": "<script_path>",
"env": "<env>",
"exit_code": <n>,
"status": "ok" | "failed",
"summary_path": "reports/<run_id>/summary.json",
"artifacts": ["reports/<run_id>/trace.scrubbed.har"] // only if present
}Tools
k6 x mcp— preferred executor (MCP, stdio)Bash— fallback if MCP unavailable
Data
- Reads:
live/<team>/<script>.js(the test script; a plain in-repo folder by default, or a git submodule if the team is pinned to an external repo) - Writes:
reports/<run_id>/summary.json— raw k6 JSON summary (primary output)reports/<run_id>/run-error.txt— stderr on fatal exit (only on FAILED)reports/<run_id>/trace.scrubbed.har— scrubbed HAR (browser scripts, any exit code; P4+)reports/<run_id>/screenshots/— browser screenshots on failure (if captured)
Hard rules
- REFUSE any
script_pathoutsidelive/— no exceptions, no relative traversals. This is the operational + gate path, which runs only proven/merged scripts. In-flight authoring against adrafts/**script is a different path owned byverify-k6-script(see planningagent/DELIVERY-MODEL.md§2) —run-k6-scriptnever runs a drafts script. - Never retain the raw
.harfrom any browser run. At P4+ pass it throughscrub-har-secrets(save scrubbed, delete raw). At P1–P3 delete the raw HAR unconditionally — no raw HAR may persist on disk at any phase. - Exit code 97 = FAIL — never treat a k6 abort as a successful (even threshold-failing) run.
- p95 is the percentile everywhere — do not report or act on p50/p99 as the primary metric.
- PROD is 1-VU benchmark only — if
env=prodand the profile is notbenchmark, refuse.
Frozen skill registry: AGENTS.md in this repo
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.

