💻 Coding

k6 Scenario Script from an SLO and Endpoint List (No Invented RPS)

Write a k6 JS scenario from pasted SLOs and endpoints. No invented RPS, thresholds, or routes.

0.0
0Reviews
P
August 26, 2026

Prompt

Act as an SRE writing a k6 JavaScript scenario from an SLO pack and endpoint list. You write k6 v0.54-style JS (options.scenarios, http, check, thresholds) from Inputs. You do not invent an RPS, a VU count, a URL, or a threshold the SLO pack did not state. This is not a JMeter plan, not Locust, and not a k6 cloud config unless Inputs say cloud.
You work only from Inputs. Do not invent stats, citations, quotes, URLs, names, IDs, or records that are not in Inputs.

Inputs:
- k6 version lock: [Version]
- Base URL I may hit: [Base]
- Endpoints (method, path, auth header name only): [Endpoints]
- SLO pack (latency, error rate, window) I can prove: [SLO]
- Arrival rate or VUs I can prove (or NONE): [Load or NONE]
- Think time and timeout I can prove (or NONE): [Timing]
- Environment variable names for secrets (never values): [Env]
- What I must never hit: [Never]
- Threshold syntax I want (http_req_failed, p95): [Thresh]
- Words I must not use: [Banned]

Generate:
1. Honesty ledger: version, base, every path, SLO numbers, load numbers. Forbidden: RPS, VUs, and routes not listed.
2. options.scenarios: one scenario per named load shape. If Load is NONE, emit a placeholder executor with a TODO comment and do not pick 50 rps.
3. Thresholds: only from SLO and Thresh. If SLO has no p95, omit p95 rather than using 200ms.
4. Default function: one request per Endpoints row. Auth from Env var name only. Never print a token.
5. Checks: status and a response key only if Inputs named the key.
6. Never-hit comment: list Never paths so a later editor does not add them.
7. Run notes: k6 version, command line with -e for Env names. No k6 cloud project id unless Inputs gave one.
8. Compliance pass: quote Banned words, invented RPS, invented routes. Cut them.

Constraints:
- k6 JS only. Not JMeter XML, not Locust, not Gatling.
- Never invent RPS, VU count, or a path.
- If Load is NONE, do not pick a default arrivalRate.
- Print env var names, never secret values.
- No emojis.

Instructions

Replace every [bracket] with your details before running. Works on ChatGPT, Claude, and Gemini.

Examples

Example Input

Version: k6 v0.54.0
Base: https://pay.northwind.example
Endpoints: POST /v3/pay {amount, currency} header Authorization; GET /v3/pay/{id} same header. No refund path in this test.
SLO: p95 POST /v3/pay 1.2s over 5m; error rate 1.0 percent. No availability SLO pasted.
Load: NONE (do not assume 80 rps). Staging cap not numbered.
Timing: timeout 3s; no think time named
Env: PAY_TOKEN (value never printed)
Never: /v3/refunds, /internal, production host pay.northwind.com
Thresh: http_req_failed < 0.01 on POST /v3/pay; http_req_duration p95 < 1200 for POST /v3/pay. GET not in SLO so no GET threshold.
Banned: 80 rps, 200 virtual users, soak 2 hours, refund

Example Output

1. Ledger. k6 v0.54.0. Base https://pay.northwind.example. POST /v3/pay, GET /v3/pay/{id}. SLO p95 1.2s, error 1.0 percent on POST. Load: NONE. Timeout 3s. Env PAY_TOKEN. Never refunds, /internal, pay.northwind.com. Forbidden: 80 rps, 200 VUs, 2h soak, invented GET p95.

2. scenarios. Load NONE so executor is commented as NOT IN INPUTS. Do not set arrivalRate. A single-iteration smoke scenario is the only runnable default, labeled smoke not load.

3. thresholds. http_req_failed<0.01 for POST /v3/pay; http_req_duration p(95)<1200 for POST /v3/pay. GET omitted. No availability threshold.

4. Default. POST /v3/pay JSON amount and currency keys from Endpoints, headers Authorization: Bearer ${__ENV.PAY_TOKEN}. GET /v3/pay/${id} using an id returned or NOT IN INPUTS if the POST body has no id field named. timeout 3s.

5. Checks. POST status 200 or 201 only if SLO did not name a status; keep check name 'post status' without inventing 201 vs 200 if unspecified; prefer status < 400 from error-rate framing. No refund body check.

6. Never. Do not request /v3/refunds, /internal, or host pay.northwind.com.

7. Run. k6 v0.54.0 run pay-slo.js -e PAY_TOKEN. No cloud project.

8. Compliance. Cut: 80 rps, 200 virtual users, soak 2 hours, refund. Gaps: arrival rate, VU cap, GET SLO, POST success status code, id field name.

Missing-data policy: if a field was blank, write NOT IN INPUTS rather than guessing. Lock any tool version named in Inputs; if unnamed, write unknown. No invented testimonials, star ratings, or press logos. If legal, clinical, insurance, HR, education-plan, or veterinary content appears, add a one-line not-advice and de-identify banner. Quote banned-word hits and cut them. End with a gaps list of five bullets the user still owes you. Character and byte caps in the job are hard; print counts when relevant. Refuse to backfill DOIs, exam dumps, PHI, PII, or compensation promises not in Inputs.

Reviews (0)

Please login to leave a review.
Loading reviews...