Official agent skill

K6

by grafana in grafana/skills

Generate, validate, and review k6 test scripts — load, stress, spike, soak, smoke, breakpoint, functional, and protocol.

OfficialApache-2.0Auto-check passedTesting & QA

Install K6

skills CLI
$ npx skills add grafana/skills --skill k6 -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install grafana/skills k6 --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/grafana/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/grafana-k6/k6 .claude/skills/k6 && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
k6
GitHub stars
281
Token cost
~3.1k tokens
SKILL.md length
1,443 words
Files
22
Skills in repo
51
Repo updated
First seen
Licence
Apache-2.0

At a glance

Generate, validate, and review k6 test scripts — load, stress, spike, soak, smoke, breakpoint, functional, and protocol.

  • Works in 8 steps: Pick the right example file → Adapt the example → Fill gaps with docs (only if needed) → …
  • Debugging any k6
  • SKILL.md covers Step 1: Pick the right example…, Step 2: Adapt the example, Step 3: Fill gaps with docs… and Step 4: Save, plus 4 more sections
  • Runs JavaScript scripts from its folder; reaches grafana.com and jslib.k6.io

What it does

K6 is an agent skill from grafana/skills, published by the product's own GitHub organization. Generate, validate, and review k6 test scripts — load, stress, spike, soak, smoke, breakpoint, functional, and protocol. Covers HTTP, WebSocket, gRPC, browser, all executors, thresholds, checks, custom metrics, the k6-testing library, k6 Cloud execution, and the xk6 extension ecosystem; uses the xk6-docs CLI (with grafana.com web fallback) for docs lookup and validates every script by running it. Use when writing, generating, validating, or debugging any k6 or load-test script (including plain-language asks like…

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 22 other files (for example `SETUP.md`, `browser-best-practices.md` and `docs-guidance.md`).

It sits in Testing & QA, covering Load testing. It works with Grafana, gRPC and Testing Library. The licence is Apache-2.0.

When your agent uses it

  • Debugging any k6
  • Load-test script (including plain-language asks like load test this API
  • Stress test my service)
  • Choosing executors/scenarios

Example prompts

  • “load test this API”
  • “stress test my service”
  • “/k6”

Requirements

  • Node.js

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Pick the right example file
  2. Adapt the example
  3. Fill gaps with docs (only if needed)
  4. Save
  5. Validate
  6. Best-practices review
  7. Present results
  8. Execute

What it can do on your machine

Read from SKILL.md and the folder at commit 1ccacf2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (JavaScript, from the files we listed), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • grafana.com
    • jslib.k6.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

K6 loads about 3.1k tokens when it runs. Until then it costs about 183 tokens; SKILL.md has 1,443 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~183
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from grafana/skills at commit 1ccacf2, republished under its Apache-2.0 licence (© grafana). 1,443 words, ~3,106 tokens.

Download SKILL.mdSave it as .claude/skills/k6/SKILL.md (or your agent's skills folder). This skill also uses 21 other files; get the full folder from GitHub.
name
k6
description
Generate, validate, and review k6 test scripts — load, stress, spike, soak, smoke, breakpoint, functional, and protocol. Covers HTTP, WebSocket, gRPC, browser, all executors, thresholds, checks, custom metrics, the k6-testing library, k6 Cloud execution, and the xk6 extension ecosystem; uses the xk6-docs CLI (with grafana.com web fallback) for docs lookup and validates every script by running it. Use when writing, generating, validating, or debugging any k6 or load-test script (including plain-language asks like "load test this API" or "stress test my service"), choosing executors/scenarios, or setting thresholds. For end-to-end website performance suites use k6-perf-test-website; for documenting k6 itself use k6-docs.
license
Apache-2.0

k6 Script Generation

Efficiency note: This is a short linear recipe (read example → adapt → save → validate → review). A todo list would just mirror the headings without adding value, so skip the planning overhead and execute the steps directly.

Agent-agnostic: The steps below describe capabilities, not specific tools. Where a step says "fetch a URL" or "write a file", use whatever your agent provides for that capability (e.g. a web-fetch tool, a file-write tool, or shell curl/tee).


Step 1: Pick the right example file

Read only the file that matches the user's request. Examples provide structural scaffolding — the correct scaffold, option shapes, and import patterns.

User needsRead this file
HTTP REST, auth flow, batch requestsexamples/http.js
HTML parsing with parseHTML, SharedArrayexamples/html.js
WebSocketexamples/websocket.js
gRPCexamples/grpc.js
Browser automationexamples/browser.js
Browser + functional test / expect() / k6-testingexamples/functional.js (browser scenario)
Functional/integration tests, expect(), k6-testingexamples/functional.js
Custom metrics, execution module, handleSummary, per-vu-iterationsexamples/metrics.js
Load patterns, all executors (ramping, arrival rate, per-VU, etc.)examples/executors.js
Cloud run, --local-execution, cloud optionsexamples/cloud.js
Crypto (HMAC, MD5, SHA256) or encoding (base64)examples/crypto-encoding.js
xk6-fakerexamples/ext-faker.js
xk6-redisexamples/ext-redis.js
xk6-sql / sqlite3 / postgresexamples/ext-sql.js
xk6-execexamples/ext-exec.js
xk6-dnsexamples/ext-dns.js
xk6-tlsexamples/ext-tls.js
xk6-tcpexamples/ext-tcp.js
xk6-crawlerexamples/ext-crawler.js

Example files live in the examples/ directory alongside this SKILL.md.

When the request matches multiple rows (e.g. "browser" + "functional test"), prefer the row whose assertion style fits the intent. If the user says "functional test", "assert", "verify", or "expect", use functional.js even if the test involves a browser — it demonstrates expect() with auto-retrying browser matchers. Use browser.js for browser load/performance tests that don't emphasize correctness assertions.


Step 2: Adapt the example

Use the loaded example as the starting point. Adapt it to the user's exact requirements:

  • Change endpoints, VU counts, durations, thresholds
  • Add or remove scenario steps
  • Rename functions and variables to match the domain
  • Every expression must be complete and runnable — no { ... }, // TODO, or stubs
  • Match the request — don't over-build. Implement exactly what was asked. Don't add custom request tags, extra sleep() calls, additional endpoints, or options the user didn't request. Unrequested complexity lowers quality and reduces adherence to the spec.

For multi-scenario scripts (browser + HTTP, cloud): use named scenarios with exec pointing to separate exported functions.


Step 3: Fill gaps with docs (only if needed)

The example covers common patterns. Adapt from it directly. Skip this step entirely if the example provides everything you need.

Only reach for docs if:

  • The user asks for an API or option not demonstrated in the example, or
  • You are not confident about the exact signature, option name, or return type

When a gap exists, first establish the docs command (one-time per session).

The k6 x docs CLI renders content only when it detects a TTY. Since agents run non-interactively, wrap every call with script to allocate a pseudo-TTY and pipe the ANSI-stripped content to stdout:

bash
# Detect OS once (macOS vs Linux have different `script` flags):
if [[ "$(uname -s)" == "Darwin" ]]; then
  DOCS_CMD="script -q /dev/null k6 x docs"
else
  DOCS_CMD="script -qc 'k6 x docs' /dev/null"
fi

# Verify it works — should print a topic list, NOT a "browse files" guide:
$DOCS_CMD 2>/dev/null | head -5

If the output still shows "k6 documentation is a directory of markdown files", the TTY wrapper isn't working. Fall back to web docs under https://grafana.com/docs/k6/latest/ — fetch pages with whatever web-fetch capability your agent has (a built-in fetch tool, or curl in a shell).

If k6 x docs fails outright (command not found, provisioning or 404 errors), read SETUP.md — it covers auto-provisioning on k6 v1.7.0+ and the manual xk6 build for older versions.

Then look up what you need:

bash
$DOCS_CMD <path>              # e.g. javascript-api k6-http
$DOCS_CMD <path> --depth 2
$DOCS_CMD search <term>

Common CLI paths and the 2-call strategy are in docs-guidance.md.

Do not use unpkg, @types/k6, or any npm type definition URLs.


Step 4: Save

Line 1 of every script must be a generated-by comment. Get the current UTC timestamp first (the file content depends on it, so this can't be parallelized with the write):

bash
date -u +%Y-%m-%dT%H:%M:%SZ

Then include it as line 1:

javascript
// Generated by grafana-k6 on 2026-03-25T22:02:20.203Z

Save to k6/scripts/<descriptive-name>.js. Use lowercase kebab-case filenames. If your file-write capability doesn't create parent directories automatically, mkdir -p k6/scripts first.

The script file on disk is the deliverable — always write it. Never end the task with the script shown only in chat: Steps 5–7 (validate, review, present) all require the file to exist at k6/scripts/<name>.js. If a write fails, retry it before continuing.


Step 5: Validate

Match top-down — the first matching row wins:

Script typeCommand
Imports k6/browserk6 run k6/scripts/<name>.js
Any ramping-vus or *-arrival-rate scenariok6 inspect k6/scripts/<name>.js — a full run would execute the entire load profile against the target
Other named executor: blocks (short scenarios)k6 run k6/scripts/<name>.js
Everything else (HTTP, WS, gRPC)k6 run --vus 1 --iterations 1 k6/scripts/<name>.js

What counts as passing: for functional and browser scripts, validation passes only when the exit code is 0 and the summary shows no failed checks or expect() errors — a script that completes with failing assertions is not validated. k6's error output names the exact locator or assertion that failed (and what it waited for); use it to fix the selector or logic. For load tests, exit code 0 is a pass, and a pure threshold breach under load (exit code 99) is acceptable.

If validation fails: read stderr, fix the root cause, retry up to 3 attempts. After 3 failures, present the error and ask the user how to proceed (or, when running unattended, deliver the best attempt and clearly report the unresolved error).


Step 6: Best-practices review

Show full SKILL.md (590 more words)Show less
General checks (all scripts)

Review the script against the rules below. The checklist is authoritative — only look up docs ($DOCS_CMD best-practices or https://grafana.com/docs/k6/latest/using-k6/) if you're uncertain about a specific rule.

  • export const options with realistic VUs/duration. Default VUs/durations make the test meaningful out of the box.
  • Define thresholds for every load test. Without thresholds the run can't fail in CI even when performance regresses, which defeats the point of running a load test. At minimum include http_req_duration and http_req_failed (or the protocol equivalent). Pure functional tests — single-iteration expect()-only scripts — can skip this.
  • Include sleep() in closed-model (VU-based) load tests. sleep() represents user think time; without it, VUs hammer endpoints faster than any real user would, inflating throughput and crowding out the system under test. This applies to VU-based HTTP, WebSocket, gRPC, crypto, and extension scripts. Open-model executors (constant-arrival-rate, ramping-arrival-rate) already pace iterations to a target rate, so sleep() there is usually unnecessary — it only ties up VUs without changing the offered load. Browser scripts use page.waitForTimeout() instead; single-iteration functional tests and one-shot connectivity/demo scripts can skip it. In event-driven WebSocket scripts, put the sleep() inside the close handler (see examples/websocket.js) — sleeping in the main function body blocks the event loop before any messages arrive.
  • Assert every response. Browser scripts: use expect() from k6-testing — it auto-retries against locators and replaces waitFor() + isVisible() + check() chains. If you need a metric-tracked check() inside an async browser function, the standard check from k6 works fine as long as the predicate is synchronous — await the value first, then check it. Only reach for the k6-utils wrapper (https://jslib.k6.io/k6-utils/1.5.0/index.js) when the predicate itself must await something: a bare async predicate returns a Promise, which is always truthy, so the check silently passes. HTTP/gRPC/WS scripts: use check() for metric-tracked assertions, or expect() for functional tests. Silent failures are worse than loud ones.
  • Browser scripts: wrap interactions in try/finally with page.close() in finally, so pages clean up even when assertions throw.
  • gRPC scripts: wrap the iteration's calls in try/finally and call client.close() in the finally block, so the connection is released even when a check throws mid-iteration.
  • WebSocket scripts: wrap JSON.parse of incoming messages in try/catch — servers can send non-JSON frames, and one bad frame shouldn't kill the VU.
  • No let/var at top level — use const, since module-scope state is shared across VUs and mutability there is almost always a bug.
  • No deprecated imports — use k6/websockets for WebSockets; both k6/ws and k6/experimental/websockets are deprecated.
Load & breakpoint tests
  • Breakpoint tests: ramp offered load, not VUs. Use an open-model executor (ramping-arrival-rate) so the request rate is independent of how slow the system gets; a closed model (ramping-vus) throttles itself as latency rises and masks the breaking point. Pair thresholds with abortOnFail: true and a short delayAbortEval so the run stops (and reports) once an SLO is crossed.
  • Track SLO-relevant custom metrics for reporting: per-endpoint latency (Trend), an error Rate, and any domain counters — plus a handleSummary that surfaces p95/p99, throughput (req/s), and error rate. See examples/executors.js and examples/metrics.js.
  • Hybrid protocol + browser load tests: wrap the browser flow in try/catch and record failures to a custom error metric instead of letting an expect() throw — a single flaky browser iteration must not abort a long protocol load run.

If the script imports k6/browser, read browser-best-practices.md and apply all checks. Fix issues and re-validate.


Step 7: Present results

  1. Full script with file path
  2. Validation output
  3. Best-practices notes (issues found, or "all checks passed")
  4. Suggested run command
bash
k6 run --vus 10 --duration 30s k6/scripts/api-load-test.js
k6 run k6/scripts/browser-test.js
k6 cloud run k6/scripts/cloud-test.js
k6 cloud run --local-execution k6/scripts/hybrid-test.js
./k6-with-faker run k6/scripts/faker-test.js
K6_BROWSER_HEADLESS=true k6 run k6/scripts/browser-test.js

Step 8: Execute

If the user confirms, run the command.

© grafana, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 21 other files in skills/grafana-k6/k6 of grafana/skills.

  • SKILL.md
  • SETUP.md
  • browser-best-practices.md
  • docs-guidance.md
  • examples/browser.js
  • examples/cloud.js
  • examples/crypto-encoding.js
  • examples/executors.js
  • examples/ext-crawler.js
  • examples/ext-dns.js
  • examples/ext-exec.js
  • examples/ext-faker.js
  • examples/ext-redis.js
  • examples/ext-sql.js
  • examples/ext-tcp.js
  • examples/ext-tls.js
  • examples/functional.js
  • examples/grpc.js
  • examples/html.js
  • examples/http.js
  • … and 2 more

Open the folder on GitHubat commit 1ccacf2

Compare with similar skills

K6 next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

K6 compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
K6 this skillgrafana/skills281—~3.1kAutomated safety check: PassApache-2.0
Write Testsgrafana/synthetic-monitoring-app171—~1.2kAutomated safety check: PassAGPL-3.0
Test CommanderEliasOulkadi/shokunin114—~3kAutomated safety check: NotesMIT
Nestjs Features Performanceaiskillstore/marketplace430—~3.8kAutomated safety check: PassMIT
Renovate Batch Updategrafana/quickpizza171—~3.2kAutomated safety check: PassApache-2.0
Monitoring ExpertJeffallan/claude-skills12k—~1.6kAutomated safety check: PassMIT

Similar skills

  • Write Tests

    grafana/synthetic-monitoring-app

    Official

    Write Jest integration and unit tests for the Grafana Synthetic Monitoring app using React Testing Library, MSW, and src/test helpers.

    171 GitHub stars~1.2k tokensUpdated today
    Testing & QAAuto-check passed
  • Test Commander

    EliasOulkadi/shokunin

    Generate unit, integration, E2E, and visual regression tests following the Testing Trophy methodology (80% integration).

    114 GitHub stars~3k tokensUpdated 4 days ago
    Testing & QAAuto-check: notes
  • Nestjs Features Performance

    aiskillstore/marketplace

    Selects and implements NestJS runtime features, error and API contracts, security, testing, DevOps, performance, and safe scale.

    430 GitHub stars~3.8k tokensUpdated today
    Backend & APIsAuto-check passed
  • Renovate Batch Update

    grafana/quickpizza

    Official

    Consolidate all open Renovate PRs on quickpizza into tested, reviewable PRs.

    171 GitHub stars~3.2k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Monitoring Expert

    Jeffallan/claude-skills

    Sets up application monitoring: structured logs, Prometheus metrics, OpenTelemetry tracing, Grafana dashboards, alert rules and load tests with k6 or Artillery.

    12k GitHub stars~1.6k tokensUpdated 6 days ago
    DevOps & CloudAuto-check passed
  • Vercel Load Scale

    jeremylongshore/tons-of-skills-marketplace

    Load test and scale Vercel deployments with concurrency tuning and capacity planning.

    2.8k GitHub stars~2k tokensUpdated today
    Testing & QAAuto-check passed

More from grafana/skills

All 51 skills in this repo
  • K6 Docs

    grafana/skills

    Official

    Write or review k6 documentation across the three k6 repositories - k6-DefinitelyTyped (TypeScript types), k6-docs (user documentation), and k6 (release notes / changelog).

    281 GitHub stars~678 tokensUpdated yesterday
    Auto-check passed
  • Alerting Irm

    grafana/skills

    Official

    Configure Grafana Alerting, Incident Response Management (IRM), and SLOs end-to-end — provisions Grafana-managed and data-source-managed alert rules, contact points (Slack/PagerDuty/email/webhook)…

    281 GitHub starsUsed in 1 repo~1.9k tokens
    Auto-check passed
  • Dashboarding

    grafana/skills

    Official

    Build, modify, and ship Grafana dashboards as JSON via the HTTP API — panel types (timeseries / stat / gauge / table / heatmap / logs / traces / node-graph), gridPos 24-column layout, units…

    281 GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check passed
  • K6 Perf Test Website

    grafana/skills

    Official

    A skill your agent uses when the user wants to performance-test, load-test, or stress-test a public website end-to-end with k6.

    281 GitHub stars~3.3k tokensUpdated yesterday
    Auto-check passed
  • Promql

    grafana/skills

    Official

    Write, validate, and optimize PromQL for Prometheus / Grafana Mimir / Grafana Cloud Metrics.

    281 GitHub starsUsed in 1 repo~1.1k tokens
    Auto-check passed
  • Adaptive Metrics

    grafana/skills

    Official

    Cut Grafana Cloud Metrics cost by shrinking active-series count with Adaptive Metrics aggregation rules — auto-recommendations from query history, custom exact/regex rules, label-drop config…

    281 GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed

Questions about K6

What does K6 do?

Generate, validate, and review k6 test scripts — load, stress, spike, soak, smoke, breakpoint, functional, and protocol. K6 is an agent skill from grafana/skills, published by the product's own GitHub organization. Generate, validate, and review k6 test scripts — load, stress, spike, soak, smoke, breakpoint, functional, and protocol.

When should I use K6?

K6 fits situations like: debugging any k6; load-test script (including plain-language asks like load test this API; stress test my service); choosing executors/scenarios.

How do I install K6 in Claude Code?

Run `npx skills add grafana/skills --skill k6 -a claude-code`. Or copy the skill folder (skills/grafana-k6/k6 in grafana/skills) into .claude/skills/k6 in your project. Claude Code loads it when a task matches its description.

How do I install K6 in Codex?

Run `npx skills add grafana/skills --skill k6 -a codex`. Or copy the skill folder (skills/grafana-k6/k6 in grafana/skills) into .agents/skills/k6 in your project. Codex loads it when a task matches its description.

Can I use K6 in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add grafana/skills --skill k6 -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/k6, .gemini/skills/k6, .github/skills/k6 and .opencode/skills/k6 in your project.

What does K6 need to run?

Going by SKILL.md and its folder, K6 needs JavaScript for the scripts in its folder. Our summary lists: Node.js.

Does K6 access the network?

SKILL.md names 2 domains. In commands or code: grafana.com and jslib.k6.io; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is K6 safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does K6 use?

K6 is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does K6 use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to K6?

Skills that share tags, products or a category with K6: Write Tests (grafana/synthetic-monitoring-app, 171 stars), Test Commander (EliasOulkadi/shokunin, 114 stars), Nestjs Features Performance (aiskillstore/marketplace, 430 stars) and Renovate Batch Update (grafana/quickpizza, 171 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains K6?

grafana (a GitHub organization, an official publisher) maintains it in grafana/skills, which has 281 GitHub stars. The repository holds 51 skills in this directory. The repository was last updated on October 8, 2026.

Source: grafana/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.