Synthèse automatique
Cette skill guide l'écriture de scripts k6 en JavaScript pour réaliser des tests de charge, de stress, de pic et d'endurance sur des API et des sites web.
Points forts
- Couvre les principaux types de tests (smoke, load, stress, spike, soak) et indique lequel choisir selon l'objectif
- Fournit des modèles concrets de thresholds avec critères de réussite/échec explicites
- Montre l'usage des métriques personnalisées (Trend, Counter, Rate) pour suivre des indicateurs métier
- Inclut un exemple d'intégration dans un pipeline GitHub Actions avec échec en cas de dépassement des seuils
Limites
- Le fichier est tronqué : la section sur l'exécution en ligne de commande et l'analyse des résultats est incomplète
- Aucune indication sur la génération de rapports ou l'export des résultats vers Grafana, InfluxDB ou un autre backend
- Ne traite pas de la corrélation, du paramétrage par données ou de l'authentification au-delà d'un simple exemple de login
À utiliser lorsqu'on veut concevoir ou structurer un test de performance k6 avec paliers de VUs, seuils de validation et exécution automatisée en CI.
À éviter pour des tests pilotés par navigateur ou des scénarios d'interface utilisateur, qui relèvent de Selenium ou d'un outil browser-based.
Analyse de sécurité
SûrThe skill provides guidance for writing and running k6 load tests against APIs and websites. It does not contain destructive commands, exfiltration, obfuscation, or instructions to bypass safety. It includes example bash commands for installing and running k6, but these are standard and legitimate for performance testing. No allowed tools are declared, so the agent is not authorized to execute them, reducing risk further.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
Write a k6 load test script for https://api.example.com/users that ramps to 50 virtual users over 1 minute, holds for 3 minutes, and asserts p95 latency under 500ms and error rate below 1%.I want to find the breaking point of my checkout service before Black Friday. Which k6 test type should I run and can you write the script for it?Add a GitHub Actions workflow that runs my tests/load-test.js k6 script on every push to main and fails the build if my thresholds are breached.name: k6 description: When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium. metadata: author: terminal-skills version: "1.0.0" category: development tags: - load-testing - performance - stress-testing - benchmarking
k6
Overview
You are an expert in k6, the open-source load testing tool built for developer happiness. You help users write k6 test scripts in JavaScript, configure virtual users and durations, set thresholds for pass/fail criteria, and analyze results. You understand k6's execution model, lifecycle hooks, and how to integrate k6 into CI/CD pipelines.
Instructions
Initial Assessment
Before writing a load test, understand:
- Target — What endpoint(s) or service are you testing?
- Goal — What kind of test? (load, stress, spike, soak, smoke)
- Expectations — What response time and error rate are acceptable?
- Scale — How many concurrent users should the test simulate?
Writing k6 Scripts
Always structure scripts with clear stages and thresholds:
// load-test.js — k6 load test with ramping VUs and thresholds.
// Tests the /api/users endpoint under increasing load.
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
stages: [
{ duration: '1m', target: 50 },
{ duration: '3m', target: 50 },
{ duration: '1m', target: 0 },
],
thresholds: {
http_req_duration: ['p(95)<500'],
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://api.example.com/users');
check(res, {
'status is 200': (r) => r.status === 200,
'response time < 500ms': (r) => r.timings.duration < 500,
});
sleep(1);
}
Test Types
Guide users to the right test type:
- Smoke test — Minimal load (1-2 VUs) to verify the script works
- Load test — Expected normal and peak load
- Stress test — Beyond normal capacity to find breaking points
- Spike test — Sudden surge of traffic
- Soak test — Extended duration to find memory leaks and degradation
Thresholds
Always recommend thresholds so tests have clear pass/fail criteria:
// thresholds.js — Common threshold patterns for k6.
// Combine multiple metrics for comprehensive pass/fail.
export const options = {
thresholds: {
http_req_duration: ['p(95)<500', 'p(99)<1000'],
http_req_failed: ['rate<0.01'],
http_reqs: ['rate>100'],
checks: ['rate>0.99'],
'http_req_duration{name:login}': ['p(95)<800'],
},
};
Custom Metrics
// custom-metrics.js — Track business-specific metrics in k6.
// Useful for measuring things beyond HTTP response times.
import { Trend, Counter, Rate } from 'k6/metrics';
const loginDuration = new Trend('login_duration');
const successfulLogins = new Counter('successful_logins');
const loginSuccessRate = new Rate('login_success_rate');
export default function () {
const start = Date.now();
const res = http.post('https://api.example.com/login', JSON.stringify({
username: 'testuser',
password: 'testpass',
}), { headers: { 'Content-Type': 'application/json' } });
loginDuration.add(Date.now() - start);
const success = res.status === 200;
successfulLogins.add(success ? 1 : 0);
loginSuccessRate.add(success);
}
CI Integration
# .github/workflows/load-test.yml — Run k6 load tests in GitHub Actions.
# Fails the pipeline if thresholds are breached.
name: Load Test
on:
push:
branches: [main]
jobs:
k6:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: grafana/k6-action@v0.3.1
with:
filename: tests/load-test.js
Running k6
# run-k6.sh — Common k6 commands for different scenarios.
# Install and run with various output options.
# Install
brew install k6
# Basic run
k6 run load-test.js
# With environment variables
k6 run -e BASE_URL=https://staging.example.com load-test.js
# Override VUs and duration
k6 run --vus 100 --duration 5m load-test.js
# Output to JSON for analysis
k6 run --out json=results.json load-test.js
Scenarios (Advanced)
// scenarios.js — Multiple scenarios running different patterns simultaneously.
// Simulates realistic mixed traffic patterns.
export const options = {
scenarios: {
browse: {
executor: 'constant-vus',
vus: 20,
duration: '5m',
exec: 'browsePage',
},
checkout: {
executor: 'ramping-arrival-rate',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 50,
stages: [
{ duration: '2m', target: 10 },
{ duration: '2m', target: 0 },
],
exec: 'checkout',
},
},
};
export function browsePage() {
http.get('https://api.example.com/products');
sleep(2);
}
export function checkout() {
http.post('https://api.example.com/checkout', JSON.stringify({ item: 'widget' }));
}
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/load-testing-with-k6-mu0qzoki' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/load-testing-with-k6-mu0qzoki/download' --output '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md.part' && mv '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md.part' '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md' && test -s '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/k6' && cp -R '.skill-downloads/load-testing-with-k6-mu0qzoki' '.claude/skills/k6'Cursor
test -f '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md' && test -s '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/k6' && cp -R '.skill-downloads/load-testing-with-k6-mu0qzoki' '.cursor/skills/k6'Codex
test -f '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md' && test -s '.skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/k6' && cp -R '.skill-downloads/load-testing-with-k6-mu0qzoki' '.agents/skills/k6'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/load-testing-with-k6-mu0qzoki'openskills read 'load-testing-with-k6-mu0qzoki'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/load-testing-with-k6-mu0qzoki/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Comparaison de performances ClickHouse
Testing
Évaluez les résultats de tests de performance ClickHouse, analysez les régressions de PR, comparez avec l'historique et vérifiez la fiabilité des mesures.
Analyse des rapports de performance CI
Testing
Analyse les rapports de comparaison de performance CI pour une PR ClickHouse. Recoupe l'historique master pour distinguer les vraies régressions des tests instables.
Méthode Santa
Testing
Vérification adversarial multi-agents avec deux réviseurs indépendants. La sortie est vérifiée deux fois et corrigée itérativement jusqu'à ce que les deux acceptent avant publication.