Merged
Conversation
Add new 'xk6 x' command that allows developers to execute k6 subcommands provided by the current directory's extension without manually building the k6 executable. Changes: - Add xCmd() in internal/cmd/x.go to implement the new command - Create help text in internal/cmd/help/x.md - Register xCmd in root command - Refactor run command to use shared runK6Command helper - Extract runK6Command logic into run_helper.go for reuse - Update README with xk6 x command documentation The command builds a temporary k6 binary with the extension and executes it with the provided subcommand and arguments, streamlining the development workflow for k6 subcommand extensions.
… introduced in xk6.
andrewslotin
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements native support for k6 subcommand extensions in xk6, enabling developers to build and run subcommand extensions more efficiently.
Changes
This PR adds two key capabilities to xk6:
1. Subcommand Execution (
xk6 x)Introduces the
xk6 xcommand that builds a k6 binary with the extension from the current directory and immediately executes the custom subcommand.Usage:
This mirrors the k6 v1.5.0+ syntax (
k6 x subcommand) and eliminates the need to manually build and execute binaries during development.2. Subcommand Extension Scaffolding (
xk6 new --type subcommand)Extends the
xk6 newcommand to generate boilerplate code for subcommand extensions.Usage:
The generated template follows the official grafana/xk6-subcommand-example structure, providing a ready-to-use starting point for building custom k6 subcommands.
Motivation
With k6 v1.5.0 introducing subcommand extension support, developers can now create custom CLI commands under the
k6 xnamespace. However, the development workflow required manual binary builds for each test cycle:xk6 build --with . ./k6 x my-subcommandThis PR streamlines the workflow to match existing xk6 patterns (like
xk6 runfor JavaScript extensions), making subcommand extension development more efficient.Related
Closes #416