A k6 extension that provides offline k6 documentation in the terminal. Built as an xk6 subcommand, it registers under k6 x docs.
Designed for AI agents and developers who need quick access to k6 docs without leaving the terminal or opening a browser.
xk6 build --with github.com/grafana/xk6-subcommand-docsk6 x docs # Table of contents
k6 x docs http # JS API: k6/http module
k6 x docs http get # JS API: HTTP get function
k6 x docs browser page click # JS API: browser page click
k6 x docs using-k6 scenarios # Using k6: scenarios
k6 x docs jslib # JS API: jslib (no k6- prefix needed)
k6 x docs crypto # JS API: crypto
k6 x docs javascript-api/k6-http/get # Full slug (always works)
k6 x docs --list # List top-level categories
k6 x docs http --list # List subtopics under http
k6 x docs search threshold # Search docs
k6 x docs search "close context" # Fuzzy: matches closecontext
k6 x docs search "http-debugging" # Fuzzy: matches http debugging
k6 x docs best-practices # Best practices guide
k6 x docs --all # Dump all docs
Most JS API modules use the k6- prefix (k6-http, k6-browser, etc.), but some don't. Modules like jslib, crypto, init-context, and error-codes can be accessed directly by name without any prefix:
k6 x docs jslib
k6 x docs crypto
k6 x docs init-context
Search ignores spaces and dashes, so you don't need to remember exact formatting:
k6 x docs search "close context"matchesclosecontextk6 x docs search "http-debugging"matcheshttp debuggingk6 x docs search "closecontext"matchesclose-context
Search results are grouped by topic/module with hierarchical output rather than a flat list.
You can configure a markdown renderer (e.g. glow) so docs output is automatically rendered in the terminal.
Create ~/.config/k6/docs.yaml:
renderer: glow -p 200When configured and stdout is a TTY (interactive use), output is piped through the renderer. When piped (k6 x docs http | grep something), the renderer is bypassed and raw markdown is emitted. If the renderer command fails, raw output is printed as a fallback.
Docs are not embedded in the binary. They are fetched at runtime and cached locally.
On first run, the extension:
- Detects the k6 version from build info (e.g.
v1.5.0maps tov1.5.x) - Downloads the matching
.tar.zstbundle from this repository's GitHub releases - Extracts it to
~/.local/share/k6/docs/{version}/
Subsequent runs read straight from cache. No network needed.
Why not embed? xk6 has no build-time version detection mechanism, and embedding would bloat every k6 binary regardless of whether the user wants docs.
Doc bundles are published as GitHub releases through two triggers:
- Primary:
repository_dispatchfrom k6's release workflow - Fallback: Scheduled poll (disabled by default)
The pipeline clones k6-docs, transforms Hugo markdown into a compact format, compresses with zstd, and publishes as a GitHub release tagged docs-v{major}.{minor}.x.
This extension includes a Claude Code skill for AI-assisted k6 documentation lookup.
npx @anthropic-ai/claude-code skill install --url https://github.com/grafana/xk6-subcommand-docsOnce installed, Claude Code can look up k6 documentation during conversations using k6 x docs.
make test # Run tests
make lint # Run linter
make build # Build k6 with this extension
make prepare K6_VERSION=v1.5.x K6_DOCS_PATH=~/k6-docs # Prepare docs bundle locally