Generated banner for K6 Docs
Generated logo for K6 Docs

K6 Docs

Grafana LabsOfficialPublished by Grafana Labs

  • Skill
  • Content generator
  • Cloud and DevOps
  • Apache-2.0
  • Low risk
  • Has scripts

From the author

Write or review k6 documentation across the three k6 repositories - k6-DefinitelyTyped (TypeScript types), k6-docs (user documentation), and k6 (release notes / changelog). Applies k6 doc style conventions, generates TypeScript type definitions, drafts release notes, and validates examples by running them against k6@master. Use when working on k6 documentation, the k6 changelog, the k6 release notes, k6 API reference, k6 TypeScript types, load testing docs, or when the user asks to write, edit, or review anything in the k6, k6-docs, or k6-DefinitelyTyped repos - even if they don't explicitly say "documentation".
— the description by Grafana Labs

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The k6-docs skill provides a structured approach to managing documentation across the k6 ecosystem. It ensures that user-facing documentation, TypeScript type definitions, and release notes remain accurate and synchronized with the k6 codebase. The skill enforces strict quality standards, including mandatory validation of all code examples against the current k6 master branch and visual verification of rendered documentation using browser-based tools.

What it does

  • Drafts and reviews user documentation for k6 features
  • Generates and maintains TypeScript type definitions
  • Drafts release notes and changelogs for new versions
  • Validates code examples by executing them against k6@master
  • Verifies documentation rendering and link integrity
  • Applies consistent style conventions across all documentation

When to use it

  • When updating or creating k6 API reference documentation
  • When drafting release notes for a new k6 version
  • When modifying TypeScript type definitions for k6
  • When reviewing documentation changes for accuracy and style
  • When verifying that code examples in documentation are functional

Advantages

  • Ensures all documentation code examples are tested and functional
  • Maintains consistency across multiple repositories
  • Prevents broken links and rendering issues through automated checks
  • Automates the validation of TypeScript types
  • Provides a clear, repeatable workflow for documentation maintenance

Usage examples

“Review the new documentation for the k6 browser module.”
The agent will check the documentation against the style guide, verify all links, and run the included code examples against k6@master.
“Generate the release notes for the latest k6 update.”
The agent will draft the release notes, ensuring all mentioned features are documented and examples are validated.
“Update the TypeScript types for the k6 HTTP module.”
The agent will update the type definitions and run tests to ensure they are compatible with the current k6 implementation.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/grafana/k6-docs/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip k6-docs.zip -d .agents/skills

Documentation by Grafana Labs

k6 Documentation

Document or review k6 features across three repositories: k6-DefinitelyTyped (TypeScript types), k6-docs (user documentation), and k6 (release notes).

Workflow

Pick the workflow that matches the user's intent:

Quick References

Critical Rules

  • Never push automatically - always ask first

  • Never chain commands with && or ; - run each command separately (prevents failures)

  • Only document user-facing features - not internal implementation

  • Use 1. for every numbered list item (not 1., 2., 3.)

  • Test every code example against k6@master before committing

  • No Co-Authored-By: Claude or AI attribution in commits

Validating examples (always run before committing)

Every code example in k6 documentation and release notes must execute cleanly against k6@master. The minimum loop:

# 1. cd into the k6 repo (not k6-docs or k6-DefinitelyTyped)
cd ~/path/to/k6

# 2. Make sure you're on master at the latest commit (the contract is k6@master)
#    First check for local work: if this prints anything, stop and ask the user before switching branches
git status --porcelain
git checkout master
git pull

# 3. Run each example as a separate command (no &&)
go run . run /path/to/script.js

If the run fails: read the error, fix the example in the source (doc or release note), re-run. Do not commit a change whose example doesn't run clean against current master. For the full multi-example workflow with parallel subagents, see references/testing-workflow.md.

Files

references/typescript-patterns.md

TypeScript Definition Patterns

Basic Method Signature

/**
 * Brief description of what the method does.
 *
 * Additional context about when/why to use it.
 *
 * @example
 * ```js
 * // Example showing basic usage
 * const result = page.methodName('arg1');
 * ```
 *
 * @param paramName Description of the parameter.
 * @param options Options to use.
 */
methodName(
    paramName: string | RegExp,
    options?: {
        /** Description of option property. */
        timeout?: number;
    },
): Promise<ReturnType>;

Method Overloads

For methods with different return types based on parameters:

// Overload for string input
parse(input: string): ParsedString;

// Overload for buffer input
parse(input: ArrayBuffer): ParsedBuffer;

// Generic overload
parse(input: string | ArrayBuffer): ParsedString | ParsedBuffer;

Browser Event Overloads

Event-based methods need per-event overloads for type safety:

// Overload for 'console' event
waitForEvent(
    event: "console",
    optionsOrPredicate?: ((msg: ConsoleMessage) => boolean) | {
        predicate?: (msg: ConsoleMessage) => boolean;
        timeout?: number;
    },
): Promise<ConsoleMessage>;

// Overload for 'request' event
waitForEvent(
    event: "request",
    optionsOrPredicate?: ((req: Request) => boolean) | {
        predicate?: (req: Request) => boolean;
        timeout?: number;
    },
): Promise<Request>;
When to Use Event Overloads

Rule: If a method accepts an event name string as the first parameter, create one overload per supported event.

Why: Each event type has its own return type (ConsoleMessage vs. Request vs. Response), so TypeScript needs explicit overloads to provide accurate type information.

How to add a new event:

  1. Copy an existing overload

  2. Change the event string literal: "console" → "dialog"

  3. Update the parameter type in predicate: ConsoleMessage → Dialog

  4. Update the return type: Promise<ConsoleMessage> → Promise<Dialog>

Example adding 'dialog' event:

// Overload for 'dialog' event
waitForEvent(
    event: "dialog",
    optionsOrPredicate?: ((dialog: Dialog) => boolean) | {
        predicate?: (dialog: Dialog) => boolean;
        timeout?: number;
    },
): Promise<Dialog>;

Note: The optionsOrPredicate union type (function OR object) is a Playwright pattern that k6-browser mirrors.

Type Tests

In types/k6/test/<module>.ts:

// @ts-expect-error - Tests that required parameters are enforced
page.methodName();

// $ExpectType Promise<ReturnType>
page.methodName("argument");

// $ExpectType Promise<ReturnType>
page.methodName("argument", { timeout: 10000 });

Test patterns:

  • // @ts-expect-error - Verifies TypeScript errors on invalid calls

  • // $ExpectType <Type> - Verifies the return type

Testing TypeScript Definitions

IMPORTANT: Use pnpm (not npm) to install dependencies. The k6-DefinitelyTyped workspace requires pnpm to create proper symlinks for module resolution.

cd k6-DefinitelyTyped
pnpm install -w --filter "{./types/k6}..."
pnpm test k6

Or use ${CLAUDE_PLUGIN_ROOT}/skills/k6-docs/scripts/test_typescript.sh

The first command creates a symlink for @types/k6 in node_modules, which is required for TypeScript module resolution to work during tests.

Troubleshooting

Error: Cannot find module 'k6/browser'

Cause: You likely used npm install instead of pnpm install.

Fix:

cd k6-DefinitelyTyped
pnpm install -w --filter "{./types/k6}..."
Error: dtslint is not found

Cause: Missing workspace dependencies.

Fix:

cd k6-DefinitelyTyped
pnpm install -w --filter "{./types/k6}..."

Ensure you're using the --filter flag with the workspace flag -w.

Pre-existing Test Failures

Context: The test suite may have pre-existing failures unrelated to your changes.

Action: Focus on ensuring your NEW types don't introduce ADDITIONAL errors. Compare test output before and after your changes.

See Troubleshooting guide for more help.

Formatting

Format files with dprint:

pnpm dprint fmt types/k6/

Or use ${CLAUDE_PLUGIN_ROOT}/skills/k6-docs/scripts/format_typescript.sh

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs a command-line tool

Security

What our scanner noticed· Low risk

  • Instructions that use the network
  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Grafana Labs
Publisher
Grafana Labs (Official)
Source
grafana/skills · skills/grafana-k6/k6-docs · commit 8fb72a5
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Grafana Labs or Grafana Labs.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download k6-docs.zip