- User says: "build a complete k6 test plan with SLA"
Tool Discovery Protocol
At the beginning of the workflow, detect and use interaction tools in this order:
- If
AskUserQuestion exists, use it for required inputs.
- Else if
mcp:sampling or create_message exists, use native IDE modal interaction.
- Else if
confirm_action exists, use it for critical confirmations.
- Else emit the exact fallback and end the turn:
> [?] MISSING REQUIREMENT: Missing target, scenario, SLA, or protocol detail
missing: target, scenario type, SLA requirements, protocol
why: deterministic planning cannot proceed without baseline planning inputs
next_question: What target URL or endpoint should this plan use?
Do not continue plan generation after fallback.
Interoperability Fallback Contract
When fallback is required, always use this portable payload shape:
> [?] MISSING REQUIREMENT: <short missing requirement summary>
missing: <comma-separated missing fields>
why: <why plan generation cannot continue deterministically>
next_question: <single, specific question that unblocks the next step>
Do not emit final plan content after this fallback.
Core Rules
Edge case hardening: When user input is ambiguous or conflicts with best practices:
- If SLA thresholds conflict (e.g., "p95<100ms" for a high-latency service), ask clarification.
- If scenario and SLA are mismatched (e.g., "smoke test with SLA p99<50ms"), flag and ask confirmation.
- For gRPC plans: Always ask about TLS, metadata, and failure handling explicitly.
Round contract:
- Round 1: one consolidated baseline question block with all minimum required questions.
- Round 2: one optional tie-break block only when a critical ambiguity remains after Round 1.
- If required inputs are still unresolved after Round 2, emit the interoperability fallback and end the turn.
Provisional plan policy:
- Default behavior is strict certainty: do not generate provisional assumptions in final plan output.
- If critical data is missing, return
unknown for unresolved fields and ask one unblocker question.
- Only generate provisional plans when the user explicitly asks for assumption-based output.
- If scenario type is ambiguous, do not generate a provisional plan; ask clarification using the Clarification Output Contract.
Clarification-mode hard stop:
- When clarification mode is triggered, emit only the canonical clarification block and stop.
- Do not append plan scaffolding, executor hints, thresholds, stage ideas, protocol tactics, or builder handoff details.
- Treat any plan-like token leakage as a contract violation.
Additional questions must be integrated into the same question system, not handled as a separate side flow:
- Add an HTTP method question when
protocol=http and the method cannot be inferred safely.
- Add one or more authentication questions when auth is required or unknown and executable output depends on it.
- Add more questions only inside Round 1 or the single Round 2 tie-break block when other critical ambiguities or missing requirements are detected.
- Do not finalize the plan or builder handoff until all required questions from this same system are resolved.
Load Profile Defaults (when profile is not specified):
minimal: 5 VUs, 1m duration, smoke testing
standard: 25 VUs, 9m duration, realistic load
aggressive: 120 VUs, 14m duration, stress testing
Output Format: Primary output is a textual execution plan with:
- Recommended executor type
- VU count and stages
- Duration estimate
- SLA-derived thresholds
- Protocol-specific recommendations
- Data integration suggestions (CSV/JSON)
- Exactly one deterministic
Next recommended step
Determinism: Same inputs produce identical outputs every time.
Compact-by-default responses:
- Keep plan output concise and practical.
- Avoid long explanatory prose unless user requests detail.
- Prefer short verified bullets and direct next action.
Verified Evidence Policy
- Report only values backed by user-provided inputs or direct runtime/tool evidence.
- Do not present inferred values as final facts.
- If unresolved, mark as
unknown and ask one unblocker question.
- Keep assumptions out of final summaries unless user explicitly requests assumption-based mode.
Terminology Contract
- Scenario type means the test objective shape (
load, stress, spike, soak, smoke).
- Profile means default intensity presets (
minimal, standard, aggressive) used when explicit vus/duration are missing.
- Round means one consolidated question block in the adaptive question system; baseline questions are Round 1 and the optional tie-break is Round 2.
- Scenario type selects the executor strategy; profile sets default intensity values.
Language Policy
- If user language is explicit, answer in that language.
- If language is not explicit, default to English.
- Keep command names, k6 metric keys, and code identifiers in English.
Cloud Runtime Compatibility Gate
Cloud planning must be version-aware before emitting cloud commands, cloud options, or cloud validation guidance.
Required detection flow:
- Resolve executable target.
- Run
k6 version.
- Parse semantic version.
- Classify runtime family deterministically:
V0_53_TO_V1_5 for >=0.53.0 and <1.6.0
V1_6_PLUS_V1_X for >=1.6.0 and <2.0.0
V2_0_PLUS for >=2.0.0
Gate behavior:
- If exact version is unknown or parse fails, stop cloud planning and ask for exact k6 version.
- Do not invent synthetic cloud-family labels.
- Preserve
k6_version and runtime_family in builder handoff metadata.
Cloud Planning Inputs
When cloud behavior is requested, ask these inputs in the same active question flow:
- Execution mode:
cloud-run, cloud-streaming-local-execution, or local-only.
- Routing needs: stack routing, project routing, both, or none.
- Whether zonal distribution is required.
- If distribution is required, collect full
{ loadZone, percent } entries.
Cloud Authentication Readiness
When cloud execution or cloud-ready handoff is requested, plan for an explicit auth path:
- Prefer
K6_CLOUD_TOKEN for non-interactive execution.
- If token-based auth is not available, require an interactive login path via
k6 cloud login before execution.
- Treat missing auth readiness as a blocker for cloud execution handoff, but not for non-executable planning discussion.
- Keep auth and routing guidance in environment variables or explicit login steps; never assume a live cloud session exists.
Cloud Version-Gated Behavior
V0_53_TO_V1_5:
- Allow only
k6 cloud login, k6 cloud run, and k6 cloud run --local-execution.
- Do not emit stack/project workflow assumptions unless user explicitly targets >= v1.6.0.
- Do not emit v2-only cloud options.
V1_6_PLUS_V1_X:
- Allow the restricted v1 path above plus stack routing via
options.cloud.stackID and K6_CLOUD_STACK_ID.
- Keep cloud options constrained to proven v1 evidence.
V2_0_PLUS:
- Allow verified v2 cloud options and cloud context vars.
- Require stack routing for cloud command guidance.
Cloud Distribution Validation
When options.cloud.distribution is present:
- Every entry must include
loadZone and percent.
- Every
percent must be an integer.
- Sum of all
percent values must be exactly 100.
- If any rule fails, stop runnable handoff and emit clarification/validation failure. Do not normalize automatically.
Dashboard Policy
Apply deterministic recommendation:
- CI/headless:
K6_WEB_DASHBOARD=false
- Local browser troubleshooting:
K6_WEB_DASHBOARD=true
- Local non-browser: default
K6_WEB_DASHBOARD=false unless explicit opt-in
- Otherwise default
false
Dynamic Capacity Protocol
Run this protocol before finalizing any plan that could lead to executable current-host k6 output or validation handoff. For pure cloud-run, local host capacity is advisory only and must not block the remote cloud recommendation unless the user also asks for local execution.
Cross-skill required fields:
execution_context
machine_profile
projected_load
capacity_estimate
risk_status
safe_limit_recommendation
scale_out_recommendation
High-risk gate rule (mandatory):
- Before generating or orchestrating any script that projects more than
500 VUs on the current host, run host audit silently with node skills/k6-plan/scripts/audit-host.js.
- If Node.js is unavailable, use the Python fallback:
python3 skills/k6-plan/scripts/audit-host.py.
- Parse stdout JSON and use that as the primary
machine_profile evidence for this request.
Contextual deterministic formulas:
vus_max = (logical_cpu * cpu_factor) + (free_ram_gb * ram_factor)
arrival_rate_max = floor(vus_max / max(projected_load.expected_iteration_duration_seconds, 1))
Default context factors:
local: cpu_factor=50, ram_factor=10
ci: cpu_factor=30, ram_factor=6
container: cpu_factor=25, ram_factor=5
cloud: cpu_factor=60, ram_factor=12
distributed: compute per node, then aggregate
Evaluation order:
- Build
execution_context from the declared environment (local, ci, container, cloud, or distributed) plus user constraints.
- Determine whether the active load generator is the current host or remote cloud-managed infrastructure.
- Derive
machine_profile from current evidence only for current-host execution paths: logical_cpu, free_ram_gb, fd_limit, ephemeral_port_budget, environment type, and declared user restrictions.
- If projected load is expected to exceed
500 VUs on the current host, run host audit (node skills/k6-plan/scripts/audit-host.js, fallback python3 skills/k6-plan/scripts/audit-host.py) and overwrite missing or stale machine evidence with audit output.
- Add optional telemetry when available: prior k6 saturation, observed memory per VU, prior stable arrival rate, or prior port exhaustion signals.
- Derive
projected_load from the requested or defaulted executor shape: target VUs, arrival rate, duration, stages, and expected_iteration_duration_seconds for arrival-rate executors.
projected_load.expected_iteration_duration_seconds must come from explicit user input, prior measured telemetry, or a conservative [assumption-based] estimate called out in the plan.
- If that field is unavailable, do not present
arrival_rate_max as fully deterministic.
- Calculate
capacity_estimate.vus_max and capacity_estimate.arrival_rate_max from the current machine_profile using the contextual deterministic formulas when the current host generates load. Never use a universal fixed VU ceiling.
- Classify
risk_status as SAFE, AT_RISK, or HIGH_RISK against the current estimate for current-host execution.
- Derive
safe_limit_recommendation and scale_out_recommendation, including additional_cpu_percent, additional_ram_gb, and additional_nodes.
- If execution mode is pure
cloud-run and remote worker capacity is not verified, report remote capacity as unknown and keep local capacity advisory-only for optional local validation.
Incomplete-data rules:
- If critical machine inputs are missing, ask one clarification question when that is the cheapest unblocker.
- If the scenario is otherwise clear, continue with a conservative
[assumption-based] estimate instead of inventing a global default capacity.
- Mark every derived field that depends on missing telemetry as
[assumption-based] and state the missing evidence explicitly.
- For pure
cloud-run, missing local machine evidence must not block remote execution planning; report remote capacity as unknown unless cloud worker constraints are explicitly provided.
Plan-stage behavior:
- Include all required fields above in the final plan.
- If
risk_status is AT_RISK or HIGH_RISK, append the canonical alert exactly as written below.
- Do not recommend runnable single-node execution above
safe_limit_recommendation.
- When projected load exceeds current capacity, recommend either a reduced safe limit or distributed execution.
- If
risk_status is HIGH_RISK, stop local runnable guidance and return only a reduced local limit or distributed recommendation.
- For pure
cloud-run, local host risk may inform optional dry-run advice but must not block the remote cloud recommendation.
Canonical alert format:
LOAD GENERATOR CAPACITY ALERT
Risk Detected: The requested scenario ([X] VUs) exceeds the load generator operating limit ([Y] VUs).
Impact: Possible metric skew, TCP port exhaustion, or k6 process collapse.
Recommendation: Reduce the scenario to [Z] VUs or use distributed infrastructure with at least [N] additional nodes.
Determinism rules:
Y must come from the current capacity_estimate.
Z must come from the current safe_limit_recommendation.
N must come from the current scale_out_recommendation.additional_nodes.
- The same request and machine evidence must produce the same capacity classification.
HTTP Method Question
Before producing a final HTTP plan, add the method question to the same active question system:
- Confirm primary method (
GET, POST, PUT, PATCH, DELETE) when endpoint behavior depends on method.
- If method is missing and cannot be inferred, ask it as an additional required question before finalizing.
- Reflect confirmed method in scenario steps, checks, and threshold rationale.
Auth Discovery Questions
Before finalizing plan output or builder handoff parameters, add auth questions to the same active question system:
- Detect whether authentication is required (Bearer token, API key, basic auth, mTLS, session cookie, or none).
- If auth is required or still unknown for executable output, ask for auth mechanism and required variable names as additional required questions.
- Never hard-code credentials in examples or generated scripts.
- Prefer environment variables (
__ENV) for auth inputs and list required variables.
SLA-Scenario Coherence Validation
When both scenario and sla are available, run this coherence pass before finalizing output. This pass does not block plan generation; it produces explicit warnings and a confirmation prompt when needed.
load scenario:
- If p95 target is higher than 500ms, emit INFO about potentially relaxed latency target.
- If error bound is higher than 5%, emit WARNING about overly permissive failure rate for load tests.
stress scenario:
- If latency target is ultra-strict (for example p99<100ms), emit WARNING about unrealistic stress constraints.
- If error bound is stricter than 1%, emit WARNING because stress tests intentionally probe failure boundaries.
spike scenario:
- If planned duration is greater than 10m, emit WARNING that spike tests should be short and abrupt.
soak scenario:
- If SLA is stricter than load baseline defaults, emit WARNING that soak validates endurance, not peak latency.
smoke scenario:
- If SLA includes strict percentile constraints (for example p99<50ms), emit WARNING that smoke does not validate sustained latency behavior.
After warning emission, ask one confirmation question:
Do you want to keep these thresholds for this scenario type, or adjust them now?
If user confirms to proceed, continue with the plan and keep a compact assumptions entry tagged [provided override].
SLA Consistency Across Multi-Environment
When planning for multiple environments (dev/staging/prod):
- Threshold values MUST BE IDENTICAL across all environments.
- VU counts MAY VARY per environment.
- Duration MAY VARY per environment.
- Performance SLA targets (p95, p99, error bounds) MUST NOT VARY per environment.
Rationale: SLA is a commitment and must remain coherent across environments. Relaxing SLA by environment creates non-comparable results and hides production risk.
Canonical cross-skill warning (must match k6-builder exactly):
WARNING: SLA must be identical across environments to maintain testing coherence.
Canonical enforcement flow (planning stage):
- Detect single declared SLA plus per-environment threshold divergence request.
- Emit the canonical warning string above.
- Ask one confirmation question:
Do you want to normalize all environment thresholds to the same SLA now?
- If user confirms normalization:
- Continue planning with identical thresholds across dev/staging/prod.
- If user rejects normalization:
- Keep the plan as non-runnable planning guidance only.
- Add assumptions tag
[provided override] and explicit note:
Builder-stage enforcement will reject runnable artifacts with per-environment SLA relaxation.
- Do not present relaxed thresholds as compliant defaults.
Clarification Output Contract
When required inputs are missing and a clarification response is needed (not a provisional plan), use this exact format and nothing else:
missing: <comma-separated list of missing fields>
why: <one sentence explaining why these fields are required to proceed>
next_question: <single, specific question that unblocks the next step>
Rules:
- Use exactly these three fields — no additions, no removals.
- Do not mix plan fragments, partial executor recommendations, or scenario guesses into the clarification response. The clarification block must be self-contained.
- Keep
why strictly unblocker-focused. Do not mention executor names, thresholds, VU counts, stages, protocol tactics, or builder handoff details.
- In clarification mode, avoid plan-like tokens in prose (
executor, thresholds, stages, vus, ramping, constant-vus, arrival-rate).
- If multiple fields are missing, list them all in
missing but ask only the single most-blocking question in next_question.
- After emitting the clarification block, end the response. Do not add caveats or partial analysis below it.
Required k6 Invariants
Always enforce these validations before returning the plan:
Thresholds are required
- Parse thresholds from SLA if provided.
- If SLA is not provided, derive profile-based defaults and show them explicitly.
Load profile is required
- Plan must include explicit VUs and duration (or explicit stage set with equivalent duration and target VUs).
- If
vus/duration are missing, derive from profile defaults and state assumptions.
- When request is multi-environment (dev/staging/prod), VU counts must be explicit and distinct per environment.
Runnable URL hard-coding is forbidden
- Do not generate runnable scripts with fixed live target URLs.
- Require
__ENV.BASE_URL (or equivalent) for executable output.
- If target is missing, ask for it instead of using a default live URL.
Parameter coherence is required
- Derived or explicit profile values must map to explicit
vus and duration, or explicit staged equivalents.
- If write methods are planned (
POST/PUT/PATCH), payload assumptions and expected status must be explicit.
Secrets and runnable safety are required
- Never hard-code credentials or tokens in runnable snippets.
- Require environment variables (
__ENV) for auth inputs.
Protocol-specific technical quality is required
- gRPC plans must always include:
grpc_req_duration metric, client.connect() in setup or default, and guaranteed client.close() on all execution paths (teardown or try/finally). Omitting any of these from a gRPC plan is a planning error.
- HTTP plans must always include:
http_req_duration threshold, explicit timeout guidance, and checks for response validation.
- Browser plans must always include: page/context lifecycle management and at least one Web Vitals metric recommendation.
- These are not stylistic preferences — they are required outputs for their respective plan types.
Journey/state fidelity is required
- For multi-step user journeys, preserve the full requested sequence in order; do not merge, reorder, or drop steps.
- Include a session/data-state handling strategy when the journey depends on auth/session, cart state, or correlated user data.
- If the user provides an end-to-end KPI (for example checkout p95<5s), include it explicitly in Thresholds and map it to the relevant k6 metric.
- Correlation map required for flows with 3+ steps that extract data: For every step that produces a value consumed by a later step, the plan must document it explicitly using this structure:
correlation_map:
- step: login → extracts: access_token → used_by: [createOrder, applyCoupon, pay, verify]
- step: createOrder → extracts: orderId → used_by: [applyCoupon, pay, verify]
- step: applyCoupon → extracts: discountApplied → used_by: [pay, verify]
- For each extraction: name the variable, its source (JSON field or response header), and every downstream step that consumes it. Generic mention of "correlation" without this level of detail is insufficient — it is a planning error for flows with 3+ chained data dependencies.
Cloud compatibility invariants are required (when cloud mode is requested)
- Exact k6 version must be detected and classified before cloud guidance.
- Output must match runtime family cloud allowlist.
- Distribution math must pass strict 100% validation.
- Cloud auth and routing guidance must use environment variables (
K6_CLOUD_TOKEN, K6_CLOUD_STACK_ID, K6_CLOUD_PROJECT_ID).
Output Contract
Every response must include these sections in order:
- Planning Inputs Summary
- Executor Recommendation
- Load Profile (explicit or derived)
- Thresholds (SLA-derived or defaults)
- Protocol-Specific Notes
- Guardrail Validation
- Next recommended step
Dynamic capacity reporting requirements:
Planning Inputs Summary must include execution_context.
Load Profile must include projected_load and machine_profile.
Protocol-Specific Notes must include capacity_estimate, risk_status, safe_limit_recommendation, and scale_out_recommendation.
- When
risk_status is AT_RISK or HIGH_RISK, Protocol-Specific Notes must include the canonical capacity alert with current calculated values.
Guardrail Validation checklist (minimum):
Scenario to Executor Mapping
SLA Parsing Rules
Simple Conditions (single metric)
p95<Xms → 95th percentile latency threshold
p99<Xms → 99th percentile latency threshold
error<X% or rate<X% → Error rate threshold
Comma-Separated Lists (implicit AND)
p95<500ms,p99<900ms,error<1% → All conditions must be met
- Commas separate independent thresholds
- All listed thresholds are combined in final configuration
Explicit AND Conditions (multiple conditions on same metric)
p95<500ms AND p95>100ms → p95 must be between 100ms and 500ms
- Multiple constraints on the same metric (range validation)
- Translates to multiple threshold entries for the same k6 metric
Note: OR logic is not supported in this skill behavior. All conditions are treated as mandatory (AND).
Parsing Examples
- Input:
p95<400ms,error<1% → p95 AND error rate thresholds
- Input:
p95<500ms AND p99<900ms → Both percentiles required
- Input:
p99<200ms → p99 threshold must be emitted exactly (no conversion to p95-only)
- Input:
p95<2s → Single threshold with p99 inferred (see sla-defaults.md)
Defaults per profile when SLA is not provided:
minimal: p95<800ms, error<2%
standard: p95<500ms, error<1%
aggressive: p95<300ms, p99<700ms, error<0.5%, checks>99%
Protocol-Specific Generation
gRPC
- Use
grpc.Client(), client.load(), client.connect(), client.invoke()
- Metrics:
grpc_req_duration, grpc_req_failed
- Always close connections on all execution paths (teardown or
try/finally)
- Handle metadata for authentication
- Connection lifecycle guidance is mandatory:
- Create/load client once, outside the hot iteration path.
- Do not reconnect on every iteration unless explicitly justified.
- Prefer
teardown() for client.close() to avoid leaked connections.
- TLS guidance must be explicit:
- Secure endpoints should use TLS-enabled connection options.
- Non-TLS/plaintext mode must be marked as test-only assumption.
- Metadata guidance must include concrete key examples and env-var-driven token usage.
- Timeout guidance must include both connection timeout and request timeout recommendations.
- Flag anti-pattern: reconnect-per-iteration as a performance and reliability risk.
Browser
- Use
browser.newContext(), context.newPage(), page.goto(), page.waitForSelector()
- Always close page/context at iteration end
- Prefer
data-testid selectors
- Collect Web Vitals when relevant
Progressive Disclosure
Keep this file focused on core planning workflow. Place deep guidance in:
skills/k6-plan/references/README.md
Workflow
When user invokes this skill:
- Parse provided parameters (
target, scenario, sla, profile, protocol, duration, vus, output).
- Run Tool Discovery Protocol when critical inputs are missing.
- Start the Adaptive Question System with baseline questions when
target, scenario, sla, or protocol are missing.
- If clarification mode is selected, emit only the canonical
missing/why/next_question block and end the response immediately.
- In clarification mode, reject any appended plan fragments, executor suggestions, threshold snippets, staged load drafts, or builder handoff notes.
- Apply load profile defaults based on
profile.
- Add an HTTP method question to the same question system when protocol is HTTP and the method is still ambiguous.
- Add auth questions to the same question system when auth is required, unknown, or otherwise blocks executable output.
- Add more questions in the same system if other critical ambiguities or missing requirements are detected.
- Select executor based on scenario type.
- Parse SLA thresholds or apply deterministic defaults.
- Run the Dynamic Capacity Protocol using current machine evidence and projected workload only when the selected execution path uses the current host as the load generator.
- If cloud execution or cloud-ready handoff is requested, add explicit cloud auth readiness guidance (
K6_CLOUD_TOKEN or k6 cloud login) before execution advice.
- For journey-style plans, preserve the full requested sequence and add session/data-state handling strategy.
- Validate explicit or derived VUs and duration.
- Generate textual plan with recommendations.
- Validate output structure using the Output Contract section order.
- Add exactly one deterministic
Next recommended step based on first unresolved dependency.
- If
output=script or user explicitly requests runnable code, route to k6-builder with accumulated plan parameters (target, scenario, sla, protocol, profile, method, auth, duration, vus) plus the current capacity assessment fields.
- Return the plan and assumptions summary.
Local Evaluation Workspace Policy
For official skill evaluation runs in this repository:
- Store artifacts under
skills/k6-plan/k6-plan-workspace/iteration-N/.
- Keep each run isolated inside its own
iteration-N directory.
- Treat benchmark outputs, grading files, timing files, and generated responses as non-versioned execution artifacts.
1---2name: k6-plan3description: Plan deterministic k6 performance tests from goals, SLA, and protocol context. Use when users ask to plan a load test, set up a stress/spike/soak strategy, or request a full k6 test blueprint. Route implementation output requests to k6-builder.4license: MIT5---6- User says: "build a complete k6 test plan with SLA"78## Tool Discovery Protocol910At the beginning of the workflow, detect and use interaction tools in this order:11121. If `AskUserQuestion` exists, use it for required inputs.132. Else if `mcp:sampling` or `create_message` exists, use native IDE modal interaction.143. Else if `confirm_action` exists, use it for critical confirmations.154. Else emit the exact fallback and end the turn:1617```md18> [?] MISSING REQUIREMENT: Missing target, scenario, SLA, or protocol detail19missing: target, scenario type, SLA requirements, protocol20why: deterministic planning cannot proceed without baseline planning inputs21next_question: What target URL or endpoint should this plan use?22```2324Do not continue plan generation after fallback.2526## Interoperability Fallback Contract2728When fallback is required, always use this portable payload shape:2930```md31> [?] MISSING REQUIREMENT: <short missing requirement summary>32missing: <comma-separated missing fields>33why: <why plan generation cannot continue deterministically>34next_question: <single, specific question that unblocks the next step>35```3637Do not emit final plan content after this fallback.3839## Core Rules4041<rules>421. **Adaptive Question System**: When critical parameters are missing, start with the baseline planning questions and continue in the same question flow with any additional required questions:43 - What is the target URL/endpoint? (if `target` missing)44 - What scenario type do you need? Options: load, stress, spike, soak, smoke (if `scenario` missing)45 - What are your SLA requirements? Example: p95<500ms,error<1% (if `sla` missing)46 - What protocol should this test use? Options: http, grpc, browser (if `protocol` missing)47 48 **Edge case hardening**: When user input is ambiguous or conflicts with best practices:49 - If SLA thresholds conflict (e.g., "p95<100ms" for a high-latency service), ask clarification.50 - If scenario and SLA are mismatched (e.g., "smoke test with SLA p99<50ms"), flag and ask confirmation.51 - For gRPC plans: Always ask about TLS, metadata, and failure handling explicitly.5253 Round contract:54 - **Round 1**: one consolidated baseline question block with all minimum required questions.55 - **Round 2**: one optional tie-break block only when a critical ambiguity remains after Round 1.56 - If required inputs are still unresolved after Round 2, emit the interoperability fallback and end the turn.5758 **Provisional plan policy:**59 - Default behavior is strict certainty: do not generate provisional assumptions in final plan output.60 - If critical data is missing, return `unknown` for unresolved fields and ask one unblocker question.61 - Only generate provisional plans when the user explicitly asks for assumption-based output.62 - If scenario type is ambiguous, do not generate a provisional plan; ask clarification using the Clarification Output Contract.6364 Clarification-mode hard stop:65 - When clarification mode is triggered, emit only the canonical clarification block and stop.66 - Do not append plan scaffolding, executor hints, thresholds, stage ideas, protocol tactics, or builder handoff details.67 - Treat any plan-like token leakage as a contract violation.6869 Additional questions must be integrated into the same question system, not handled as a separate side flow:70 - Add an HTTP method question when `protocol=http` and the method cannot be inferred safely.71 - Add one or more authentication questions when auth is required or unknown and executable output depends on it.72 - Add more questions only inside Round 1 or the single Round 2 tie-break block when other critical ambiguities or missing requirements are detected.73 - Do not finalize the plan or builder handoff until all required questions from this same system are resolved.74752. **Load Profile Defaults** (when `profile` is not specified):76 - `minimal`: 5 VUs, 1m duration, smoke testing77 - `standard`: 25 VUs, 9m duration, realistic load78 - `aggressive`: 120 VUs, 14m duration, stress testing79803. **Output Format**: Primary output is a textual execution plan with:81 - Recommended executor type82 - VU count and stages83 - Duration estimate84 - SLA-derived thresholds85 - Protocol-specific recommendations86 - Data integration suggestions (CSV/JSON)87 - Exactly one deterministic `Next recommended step`88894. **Determinism**: Same inputs produce identical outputs every time.90915. **Compact-by-default responses**:92 - Keep plan output concise and practical.93 - Avoid long explanatory prose unless user requests detail.94 - Prefer short verified bullets and direct next action.95</rules>9697## Verified Evidence Policy98991. Report only values backed by user-provided inputs or direct runtime/tool evidence.1002. Do not present inferred values as final facts.1013. If unresolved, mark as `unknown` and ask one unblocker question.1024. Keep assumptions out of final summaries unless user explicitly requests assumption-based mode.103104## Terminology Contract105106- **Scenario type** means the test objective shape (`load`, `stress`, `spike`, `soak`, `smoke`).107- **Profile** means default intensity presets (`minimal`, `standard`, `aggressive`) used when explicit `vus`/`duration` are missing.108- **Round** means one consolidated question block in the adaptive question system; baseline questions are Round 1 and the optional tie-break is Round 2.109- Scenario type selects the executor strategy; profile sets default intensity values.110111## Language Policy1121131. If user language is explicit, answer in that language.1142. If language is not explicit, default to English.1153. Keep command names, k6 metric keys, and code identifiers in English.116117## Cloud Runtime Compatibility Gate118119Cloud planning must be version-aware before emitting cloud commands, cloud options, or cloud validation guidance.120121Required detection flow:1221231. Resolve executable target.1242. Run `k6 version`.1253. Parse semantic version.1264. Classify runtime family deterministically:127 - `V0_53_TO_V1_5` for `>=0.53.0` and `<1.6.0`128 - `V1_6_PLUS_V1_X` for `>=1.6.0` and `<2.0.0`129 - `V2_0_PLUS` for `>=2.0.0`130131Gate behavior:1321331. If exact version is unknown or parse fails, stop cloud planning and ask for exact k6 version.1342. Do not invent synthetic cloud-family labels.1353. Preserve `k6_version` and `runtime_family` in builder handoff metadata.136137## Cloud Planning Inputs138139When cloud behavior is requested, ask these inputs in the same active question flow:1401411. Execution mode: `cloud-run`, `cloud-streaming-local-execution`, or `local-only`.1422. Routing needs: stack routing, project routing, both, or none.1433. Whether zonal distribution is required.1444. If distribution is required, collect full `{ loadZone, percent }` entries.145146## Cloud Authentication Readiness147148When cloud execution or cloud-ready handoff is requested, plan for an explicit auth path:1491501. Prefer `K6_CLOUD_TOKEN` for non-interactive execution.1512. If token-based auth is not available, require an interactive login path via `k6 cloud login` before execution.1523. Treat missing auth readiness as a blocker for cloud execution handoff, but not for non-executable planning discussion.1534. Keep auth and routing guidance in environment variables or explicit login steps; never assume a live cloud session exists.154155## Cloud Version-Gated Behavior1561571. `V0_53_TO_V1_5`:158 - Allow only `k6 cloud login`, `k6 cloud run`, and `k6 cloud run --local-execution`.159 - Do not emit stack/project workflow assumptions unless user explicitly targets >= v1.6.0.160 - Do not emit v2-only cloud options.1612. `V1_6_PLUS_V1_X`:162 - Allow the restricted v1 path above plus stack routing via `options.cloud.stackID` and `K6_CLOUD_STACK_ID`.163 - Keep cloud options constrained to proven v1 evidence.1643. `V2_0_PLUS`:165 - Allow verified v2 cloud options and cloud context vars.166 - Require stack routing for cloud command guidance.167168## Cloud Distribution Validation169170When `options.cloud.distribution` is present:1711721. Every entry must include `loadZone` and `percent`.1732. Every `percent` must be an integer.1743. Sum of all `percent` values must be exactly `100`.1754. If any rule fails, stop runnable handoff and emit clarification/validation failure. Do not normalize automatically.176177## Dashboard Policy178179Apply deterministic recommendation:1801811. CI/headless: `K6_WEB_DASHBOARD=false`1822. Local browser troubleshooting: `K6_WEB_DASHBOARD=true`1833. Local non-browser: default `K6_WEB_DASHBOARD=false` unless explicit opt-in1844. Otherwise default `false`185186## Dynamic Capacity Protocol187188Run this protocol before finalizing any plan that could lead to executable current-host k6 output or validation handoff. For pure `cloud-run`, local host capacity is advisory only and must not block the remote cloud recommendation unless the user also asks for local execution.189190Cross-skill required fields:191192- `execution_context`193- `machine_profile`194- `projected_load`195- `capacity_estimate`196- `risk_status`197- `safe_limit_recommendation`198- `scale_out_recommendation`199200High-risk gate rule (mandatory):201202- Before generating or orchestrating any script that projects more than `500` VUs on the current host, run host audit silently with `node skills/k6-plan/scripts/audit-host.js`.203- If Node.js is unavailable, use the Python fallback: `python3 skills/k6-plan/scripts/audit-host.py`.204- Parse stdout JSON and use that as the primary `machine_profile` evidence for this request.205206Contextual deterministic formulas:207208- `vus_max = (logical_cpu * cpu_factor) + (free_ram_gb * ram_factor)`209- `arrival_rate_max = floor(vus_max / max(projected_load.expected_iteration_duration_seconds, 1))`210211Default context factors:212213- `local`: `cpu_factor=50`, `ram_factor=10`214- `ci`: `cpu_factor=30`, `ram_factor=6`215- `container`: `cpu_factor=25`, `ram_factor=5`216- `cloud`: `cpu_factor=60`, `ram_factor=12`217- `distributed`: compute per node, then aggregate218219Evaluation order:2202211. Build `execution_context` from the declared environment (`local`, `ci`, `container`, `cloud`, or `distributed`) plus user constraints.2222. Determine whether the active load generator is the current host or remote cloud-managed infrastructure.2233. Derive `machine_profile` from current evidence only for current-host execution paths: `logical_cpu`, `free_ram_gb`, `fd_limit`, `ephemeral_port_budget`, environment type, and declared user restrictions.2244. If projected load is expected to exceed `500` VUs on the current host, run host audit (`node skills/k6-plan/scripts/audit-host.js`, fallback `python3 skills/k6-plan/scripts/audit-host.py`) and overwrite missing or stale machine evidence with audit output.2255. Add optional telemetry when available: prior k6 saturation, observed memory per VU, prior stable arrival rate, or prior port exhaustion signals.2266. Derive `projected_load` from the requested or defaulted executor shape: target VUs, arrival rate, duration, stages, and `expected_iteration_duration_seconds` for arrival-rate executors.227 - `projected_load.expected_iteration_duration_seconds` must come from explicit user input, prior measured telemetry, or a conservative `[assumption-based]` estimate called out in the plan.228 - If that field is unavailable, do not present `arrival_rate_max` as fully deterministic.2297. Calculate `capacity_estimate.vus_max` and `capacity_estimate.arrival_rate_max` from the current `machine_profile` using the contextual deterministic formulas when the current host generates load. Never use a universal fixed VU ceiling.2308. Classify `risk_status` as `SAFE`, `AT_RISK`, or `HIGH_RISK` against the current estimate for current-host execution.2319. Derive `safe_limit_recommendation` and `scale_out_recommendation`, including `additional_cpu_percent`, `additional_ram_gb`, and `additional_nodes`.23210. If execution mode is pure `cloud-run` and remote worker capacity is not verified, report remote capacity as `unknown` and keep local capacity advisory-only for optional local validation.233234Incomplete-data rules:235236- If critical machine inputs are missing, ask one clarification question when that is the cheapest unblocker.237- If the scenario is otherwise clear, continue with a conservative `[assumption-based]` estimate instead of inventing a global default capacity.238- Mark every derived field that depends on missing telemetry as `[assumption-based]` and state the missing evidence explicitly.239- For pure `cloud-run`, missing local machine evidence must not block remote execution planning; report remote capacity as `unknown` unless cloud worker constraints are explicitly provided.240241Plan-stage behavior:242243- Include all required fields above in the final plan.244- If `risk_status` is `AT_RISK` or `HIGH_RISK`, append the canonical alert exactly as written below.245- Do not recommend runnable single-node execution above `safe_limit_recommendation`.246- When projected load exceeds current capacity, recommend either a reduced safe limit or distributed execution.247- If `risk_status` is `HIGH_RISK`, stop local runnable guidance and return only a reduced local limit or distributed recommendation.248- For pure `cloud-run`, local host risk may inform optional dry-run advice but must not block the remote cloud recommendation.249250Canonical alert format:251252```md253LOAD GENERATOR CAPACITY ALERT254Risk Detected: The requested scenario ([X] VUs) exceeds the load generator operating limit ([Y] VUs).255Impact: Possible metric skew, TCP port exhaustion, or k6 process collapse.256Recommendation: Reduce the scenario to [Z] VUs or use distributed infrastructure with at least [N] additional nodes.257```258259Determinism rules:260261- `Y` must come from the current `capacity_estimate`.262- `Z` must come from the current `safe_limit_recommendation`.263- `N` must come from the current `scale_out_recommendation.additional_nodes`.264- The same request and machine evidence must produce the same capacity classification.265266## HTTP Method Question267268Before producing a final HTTP plan, add the method question to the same active question system:2692701. Confirm primary method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`) when endpoint behavior depends on method.2712. If method is missing and cannot be inferred, ask it as an additional required question before finalizing.2723. Reflect confirmed method in scenario steps, checks, and threshold rationale.273274## Auth Discovery Questions275276Before finalizing plan output or builder handoff parameters, add auth questions to the same active question system:2772781. Detect whether authentication is required (Bearer token, API key, basic auth, mTLS, session cookie, or none).2792. If auth is required or still unknown for executable output, ask for auth mechanism and required variable names as additional required questions.2803. Never hard-code credentials in examples or generated scripts.2814. Prefer environment variables (`__ENV`) for auth inputs and list required variables.282283## SLA-Scenario Coherence Validation284285When both `scenario` and `sla` are available, run this coherence pass before finalizing output. This pass does not block plan generation; it produces explicit warnings and a confirmation prompt when needed.2862871. `load` scenario:288 - If p95 target is higher than 500ms, emit INFO about potentially relaxed latency target.289 - If error bound is higher than 5%, emit WARNING about overly permissive failure rate for load tests.2902. `stress` scenario:291 - If latency target is ultra-strict (for example p99<100ms), emit WARNING about unrealistic stress constraints.292 - If error bound is stricter than 1%, emit WARNING because stress tests intentionally probe failure boundaries.2933. `spike` scenario:294 - If planned duration is greater than 10m, emit WARNING that spike tests should be short and abrupt.2954. `soak` scenario:296 - If SLA is stricter than load baseline defaults, emit WARNING that soak validates endurance, not peak latency.2975. `smoke` scenario:298 - If SLA includes strict percentile constraints (for example p99<50ms), emit WARNING that smoke does not validate sustained latency behavior.299300After warning emission, ask one confirmation question:301`Do you want to keep these thresholds for this scenario type, or adjust them now?`302303If user confirms to proceed, continue with the plan and keep a compact assumptions entry tagged `[provided override]`.304305## SLA Consistency Across Multi-Environment306307When planning for multiple environments (dev/staging/prod):308309- Threshold values MUST BE IDENTICAL across all environments.310- VU counts MAY VARY per environment.311- Duration MAY VARY per environment.312- Performance SLA targets (p95, p99, error bounds) MUST NOT VARY per environment.313314Rationale: SLA is a commitment and must remain coherent across environments. Relaxing SLA by environment creates non-comparable results and hides production risk.315316Canonical cross-skill warning (must match `k6-builder` exactly):317318`WARNING: SLA must be identical across environments to maintain testing coherence.`319320Canonical enforcement flow (planning stage):3213221. Detect single declared SLA plus per-environment threshold divergence request.3232. Emit the canonical warning string above.3243. Ask one confirmation question:325 - `Do you want to normalize all environment thresholds to the same SLA now?`3264. If user confirms normalization:327 - Continue planning with identical thresholds across dev/staging/prod.3285. If user rejects normalization:329 - Keep the plan as non-runnable planning guidance only.330 - Add assumptions tag `[provided override]` and explicit note:331 - `Builder-stage enforcement will reject runnable artifacts with per-environment SLA relaxation.`332 - Do not present relaxed thresholds as compliant defaults.333334## Clarification Output Contract335336When required inputs are missing and a clarification response is needed (not a provisional plan), use this exact format and nothing else:337338```339missing: <comma-separated list of missing fields>340why: <one sentence explaining why these fields are required to proceed>341next_question: <single, specific question that unblocks the next step>342```343344Rules:345- Use exactly these three fields — no additions, no removals.346- Do not mix plan fragments, partial executor recommendations, or scenario guesses into the clarification response. The clarification block must be self-contained.347- Keep `why` strictly unblocker-focused. Do not mention executor names, thresholds, VU counts, stages, protocol tactics, or builder handoff details.348- In clarification mode, avoid plan-like tokens in prose (`executor`, `thresholds`, `stages`, `vus`, `ramping`, `constant-vus`, `arrival-rate`).349- If multiple fields are missing, list them all in `missing` but ask only the single most-blocking question in `next_question`.350- After emitting the clarification block, end the response. Do not add caveats or partial analysis below it.351352## Required k6 Invariants353354Always enforce these validations before returning the plan:3553561. **Thresholds are required**357 - Parse thresholds from SLA if provided.358 - If SLA is not provided, derive profile-based defaults and show them explicitly.3592. **Load profile is required**360 - Plan must include explicit VUs and duration (or explicit stage set with equivalent duration and target VUs).361 - If `vus`/`duration` are missing, derive from profile defaults and state assumptions.362 - When request is multi-environment (dev/staging/prod), VU counts must be explicit and distinct per environment.3633. **Runnable URL hard-coding is forbidden**364 - Do not generate runnable scripts with fixed live target URLs.365 - Require `__ENV.BASE_URL` (or equivalent) for executable output.366 - If target is missing, ask for it instead of using a default live URL.3674. **Parameter coherence is required**368 - Derived or explicit profile values must map to explicit `vus` and `duration`, or explicit staged equivalents.369 - If write methods are planned (`POST`/`PUT`/`PATCH`), payload assumptions and expected status must be explicit.3705. **Secrets and runnable safety are required**371 - Never hard-code credentials or tokens in runnable snippets.372 - Require environment variables (`__ENV`) for auth inputs.3733746. **Protocol-specific technical quality is required**375 - gRPC plans must always include: `grpc_req_duration` metric, `client.connect()` in setup or default, and guaranteed `client.close()` on all execution paths (teardown or `try/finally`). Omitting any of these from a gRPC plan is a planning error.376 - HTTP plans must always include: `http_req_duration` threshold, explicit timeout guidance, and `checks` for response validation.377 - Browser plans must always include: page/context lifecycle management and at least one Web Vitals metric recommendation.378 - These are not stylistic preferences — they are required outputs for their respective plan types.3797. **Journey/state fidelity is required**380 - For multi-step user journeys, preserve the full requested sequence in order; do not merge, reorder, or drop steps.381 - Include a session/data-state handling strategy when the journey depends on auth/session, cart state, or correlated user data.382 - If the user provides an end-to-end KPI (for example checkout p95<5s), include it explicitly in Thresholds and map it to the relevant k6 metric.383 - **Correlation map required for flows with 3+ steps that extract data**: For every step that produces a value consumed by a later step, the plan must document it explicitly using this structure:384 ```385 correlation_map:386 - step: login → extracts: access_token → used_by: [createOrder, applyCoupon, pay, verify]387 - step: createOrder → extracts: orderId → used_by: [applyCoupon, pay, verify]388 - step: applyCoupon → extracts: discountApplied → used_by: [pay, verify]389 ```390 - For each extraction: name the variable, its source (JSON field or response header), and every downstream step that consumes it. Generic mention of "correlation" without this level of detail is insufficient — it is a planning error for flows with 3+ chained data dependencies.3918. **Cloud compatibility invariants are required (when cloud mode is requested)**392 - Exact k6 version must be detected and classified before cloud guidance.393 - Output must match runtime family cloud allowlist.394 - Distribution math must pass strict 100% validation.395 - Cloud auth and routing guidance must use environment variables (`K6_CLOUD_TOKEN`, `K6_CLOUD_STACK_ID`, `K6_CLOUD_PROJECT_ID`).396397## Output Contract398399Every response must include these sections in order:4004011. Planning Inputs Summary4022. Executor Recommendation4033. Load Profile (explicit or derived)4044. Thresholds (SLA-derived or defaults)4055. Protocol-Specific Notes4066. Guardrail Validation4077. Next recommended step408409Dynamic capacity reporting requirements:410411- `Planning Inputs Summary` must include `execution_context`.412- `Load Profile` must include `projected_load` and `machine_profile`.413- `Protocol-Specific Notes` must include `capacity_estimate`, `risk_status`, `safe_limit_recommendation`, and `scale_out_recommendation`.414- When `risk_status` is `AT_RISK` or `HIGH_RISK`, `Protocol-Specific Notes` must include the canonical capacity alert with current calculated values.415416Guardrail Validation checklist (minimum):417418- [ ] Final summary includes only verified facts or explicit `unknown`419- [ ] Missing critical data is surfaced with one unblocker question420- [ ] No assumption-based values are presented as confirmed421422## Scenario to Executor Mapping423424<executor-logic>425- **load**: ramping-vus with gradual ramp-up/down426- **stress**: ramping-vus with aggressive progression beyond capacity427- **spike**: ramping-vus with rapid surge to peak428- **soak**: constant-vus or ramping-vus sustained for extended duration429- **smoke**: constant-vus with minimal load430</executor-logic>431432## SLA Parsing Rules433434<sla-rules>435Parse SLA string to extract threshold conditions. Supported syntax:436437### Simple Conditions (single metric)438- `p95<Xms` → 95th percentile latency threshold439- `p99<Xms` → 99th percentile latency threshold440- `error<X%` or `rate<X%` → Error rate threshold441442### Comma-Separated Lists (implicit AND)443- `p95<500ms,p99<900ms,error<1%` → All conditions must be met444- Commas separate independent thresholds445- All listed thresholds are combined in final configuration446447### Explicit AND Conditions (multiple conditions on same metric)448- `p95<500ms AND p95>100ms` → p95 must be between 100ms and 500ms449- Multiple constraints on the same metric (range validation)450- Translates to multiple threshold entries for the same k6 metric451452**Note:** OR logic is not supported in this skill behavior. All conditions are treated as mandatory (AND).453454### Parsing Examples455- Input: `p95<400ms,error<1%` → p95 AND error rate thresholds456- Input: `p95<500ms AND p99<900ms` → Both percentiles required457- Input: `p99<200ms` → p99 threshold must be emitted exactly (no conversion to p95-only)458- Input: `p95<2s` → Single threshold with p99 inferred (see sla-defaults.md)459460Defaults per profile when SLA is not provided:461- `minimal`: p95<800ms, error<2%462- `standard`: p95<500ms, error<1%463- `aggressive`: p95<300ms, p99<700ms, error<0.5%, checks>99%464</sla-rules>465466## Protocol-Specific Generation467468<protocol-patterns>469### HTTP470- Use `http.get()`, `http.post()`, `http.batch()` for parallel requests471- Metrics: `http_req_duration`, `http_req_failed`472- Include explicit timeout guidance (baseline `timeout: '30s'`) for executable HTTP examples; missing timeout should be validated as `WARNING`.473- Tag requests: `tags: { name: 'api-call' }`474475### gRPC476- Use `grpc.Client()`, `client.load()`, `client.connect()`, `client.invoke()`477- Metrics: `grpc_req_duration`, `grpc_req_failed`478- Always close connections on all execution paths (teardown or `try/finally`)479- Handle metadata for authentication480- Connection lifecycle guidance is mandatory:481 - Create/load client once, outside the hot iteration path.482 - Do not reconnect on every iteration unless explicitly justified.483 - Prefer `teardown()` for `client.close()` to avoid leaked connections.484- TLS guidance must be explicit:485 - Secure endpoints should use TLS-enabled connection options.486 - Non-TLS/plaintext mode must be marked as test-only assumption.487- Metadata guidance must include concrete key examples and env-var-driven token usage.488- Timeout guidance must include both connection timeout and request timeout recommendations.489- Flag anti-pattern: reconnect-per-iteration as a performance and reliability risk.490491### Browser492- Use `browser.newContext()`, `context.newPage()`, `page.goto()`, `page.waitForSelector()`493- Always close page/context at iteration end494- Prefer `data-testid` selectors495- Collect Web Vitals when relevant496</protocol-patterns>497498## Progressive Disclosure499500Keep this file focused on core planning workflow. Place deep guidance in:501502- `skills/k6-plan/references/README.md`503504## Workflow505506When user invokes this skill:5075081. Parse provided parameters (`target`, `scenario`, `sla`, `profile`, `protocol`, `duration`, `vus`, `output`).5092. Run Tool Discovery Protocol when critical inputs are missing.5103. Start the Adaptive Question System with baseline questions when `target`, `scenario`, `sla`, or `protocol` are missing.511 - If clarification mode is selected, emit only the canonical `missing`/`why`/`next_question` block and end the response immediately.512 - In clarification mode, reject any appended plan fragments, executor suggestions, threshold snippets, staged load drafts, or builder handoff notes.5134. Apply load profile defaults based on `profile`.5145. Add an HTTP method question to the same question system when protocol is HTTP and the method is still ambiguous.5156. Add auth questions to the same question system when auth is required, unknown, or otherwise blocks executable output.5167. Add more questions in the same system if other critical ambiguities or missing requirements are detected.5178. Select executor based on scenario type.5189. Parse SLA thresholds or apply deterministic defaults.51910. Run the Dynamic Capacity Protocol using current machine evidence and projected workload only when the selected execution path uses the current host as the load generator.52011. If cloud execution or cloud-ready handoff is requested, add explicit cloud auth readiness guidance (`K6_CLOUD_TOKEN` or `k6 cloud login`) before execution advice.52112. For journey-style plans, preserve the full requested sequence and add session/data-state handling strategy.52213. Validate explicit or derived VUs and duration.52314. Generate textual plan with recommendations.52415. Validate output structure using the Output Contract section order.52516. Add exactly one deterministic `Next recommended step` based on first unresolved dependency.52617. If `output=script` or user explicitly requests runnable code, route to k6-builder with accumulated plan parameters (`target`, `scenario`, `sla`, `protocol`, `profile`, `method`, `auth`, `duration`, `vus`) plus the current capacity assessment fields.52718. Return the plan and assumptions summary.528529## Local Evaluation Workspace Policy530531For official skill evaluation runs in this repository:532533- Store artifacts under `skills/k6-plan/k6-plan-workspace/iteration-N/`.534- Keep each run isolated inside its own `iteration-N` directory.535- Treat benchmark outputs, grading files, timing files, and generated responses as non-versioned execution artifacts.