k6-load-testing
БесплатноБез исполняемых скриптовНе проверенUse whenever HTTP, WebSocket or gRPC load tests should be written in JavaScript with k6, or a k6 threshold passes but the system still feels slow: VU scripts…
от testland★ 18 звёзд на GitHubОб этом скилле
k6-load-testing
k6 tests are .js files with a default-exported function that runs
once per virtual user (VU) per iteration (per k6-running).
This skill covers the load-testing workflow; k6's browser, synthetic
monitoring, and chaos modes share the same script structure but are
out of scope here.
When to use
- The project ships HTTP, WebSocket, or gRPC services that need performance testing.
- The team prefers JavaScript authoring (vs. JMeter's XML, Gatling's Scala/Java, or Locust's Python).
- A CI gate is needed on p(95) latency + error rate - k6's thresholds are designed for this.
- The team is on Grafana Cloud (k6 integrates natively) or wants a self-hosted CLI-only flow.
If the team is already deep in JMeter, the migration cost is non-
trivial - evaluate jmeter-load-testing
in place. For Python / Locust shops and JVM / Gatling teams, see the
Gatling and Locust references in load-testing-overview.
Install
Install via k6 installation (brew, apt/yum, choco, Docker). Pin a specific k6 version in CI rather than "latest".
Authoring
Minimal script
import http from 'k6/http';
import { check, sleep } from 'k6';
export default function () {
const res = http.get('https://quickpizza.grafana.com/');
check(res, { 'status was 200': (r) => r.status == 200 });
sleep(1);
}
(Per k6-running.)
The default-exported function runs once per virtual-user iteration.
check() is a non-failing assertion that contributes to the
checks metric; sleep() simulates think-time between requests.
Options block - stages
Per k6-running, the options export controls the run:
export const options = {
stages: [
{ duration: '30s', target: 20 }, // ramp up to 20 VUs over 30s
{ duration: '1m30s', target: 10 }, // hold ~10 VUs for 90s (gradual scale-down)
{ duration: '20s', target: 0 }, // ramp down to 0
],
};
Three canonical shape patterns:
| Pattern | Stages |
|---|---|
| Smoke test | One stage, { duration: '1m', target: 1 } - sanity check. |
| Average load test | Ramp up → plateau → ramp down (the example above). |
| Stress test | Ramp past expected peak; observe where the system breaks. |
| Spike test | Sudden ramp to high VU; back to normal; verify recovery. |
| Soak test | Long plateau (hours); verify no resource leaks over time. |
Options block - thresholds
Per k6-thresholds, thresholds are "the pass/fail criteria that you define for your test metrics" - the canonical CI gate:
export const options = {
thresholds: {
http_req_duration: ['p(95)<500'], // 95% of requests under 500ms
http_req_failed: ['rate<0.01'], // <1% errors
checks: ['rate>0.99'], // >99% of checks pass
},
};
(Per k6-thresholds.)
The threshold expression syntax is <aggregation_method> <operator> <value>. Available aggregation methods per metric type:
| Metric type | Methods |
|---|---|
| Trend | avg, min, max, med, p(N) (percentile, ms) |
| Counter | count, rate |
| Rate | rate |
| Gauge | value |
A test that fails any threshold exits non-zero - the canonical CI gate signal.
abortOnFail
For long-running stress / soak tests, abort early if a threshold is already violated (k6-thresholds):
thresholds: {
http_req_duration: [
{ threshold: 'p(95)<500', abortOnFail: true, delayAbortEval: '10s' },
],
},
delayAbortEval postpones the abort decision to let metrics
accumulate before evaluating; without it, a 1-second test could
abort on a single slow request.
Running
Ad-hoc (no options block needed)
k6 run --vus 10 --duration 30s script.js
(Per k6-running.)
--vus overrides the script's options; --duration runs for a
fixed time without ramps.
Standard run
k6 run script.js
options block in the script controls everything; the CLI is
hands-off. Preferred for CI.
Useful flags
| Flag | Purpose |
|---|---|
--out json=<file> |
Stream raw metrics to a JSON file. |
| `--summary-export=<fi |
Установить k6-load-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл k6-load-testing?
Use whenever HTTP, WebSocket or gRPC load tests should be written in JavaScript with k6, or a k6 threshold passes but the system still feels slow: VU scripts with checks, stages for ramps, thresholds on p95 latency and errors as the CI gate, and how to read tail latency and coordinated omission.
Как установить скилл k6-load-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл k6-load-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub