Skip to content

CLI commands

The CLI is provided by @flaky-tests/core. Run it with bunx:

Terminal window
bunx @flaky-tests/core [flags]

Or install globally:

Terminal window
bun add -g @flaky-tests/core
flaky-tests [flags]

Running the CLI with no flags:

  1. Connects to the configured store
  2. Calls getNewPatterns() with default window (7 days) and threshold (2 failures)
  3. Prints a summary to stdout
  4. Exits 0 if no patterns found, 1 if patterns were found

Number of days in each detection window. The CLI compares the current window against an equal prior window.

Terminal window
bunx @flaky-tests/core --window 14 # 14-day windows

Default: 7

Minimum number of failures in the current window to flag a test as flaky.

Terminal window
bunx @flaky-tests/core --threshold 3

Default: 2

Print an AI investigation prompt for each pattern to stdout. Structured for pasting into Claude, Cursor, or Copilot.

Terminal window
bunx @flaky-tests/core --prompt

Copy the investigation prompt to the clipboard. Uses pbcopy on macOS, xclip on Linux, clip on Windows.

Terminal window
bunx @flaky-tests/core --prompt --copy

If multiple patterns are found, all prompts are concatenated before copying.

Open a GitHub issue for each new pattern. Requires GITHUB_TOKEN and either GITHUB_REPOSITORY (set automatically in Actions) or --repo.

Terminal window
bunx @flaky-tests/core --create-issue --repo your-org/your-repo

Issues include the investigation prompt in a collapsible <details> block. If an open issue for the same test already exists, a new one is not created.

Override the repository for issue creation. Defaults to GITHUB_REPOSITORY env var, then falls back to parsing git remote get-url origin.

Terminal window
bunx @flaky-tests/core --create-issue --repo acme/api

Generate a self-contained HTML report (single file, inline CSS + JS) and open it in the default browser.

Terminal window
bunx @flaky-tests/core --html

Works even when there are no newly-flaky patterns — the report falls back to run history. See Using the HTML report for what’s included and how to share it.

Destination path for --html. Defaults to a timestamped temp file.

Terminal window
bunx @flaky-tests/core --html --out flaky-report.html

Use this to commit the report, attach it to a PR, or upload it as a CI artifact.

CodeMeaning
0No new patterns detected
1One or more new patterns detected
2Configuration error (missing env vars, store connection failed)
Terminal window
# Check with defaults
bunx @flaky-tests/core
# Check 30-day window, threshold 5
bunx @flaky-tests/core --window 30 --threshold 5
# Print prompts for each pattern
bunx @flaky-tests/core --prompt
# Copy single prompt to clipboard
bunx @flaky-tests/core --prompt --copy
# Create GitHub issues
GITHUB_TOKEN=$TOKEN bunx @flaky-tests/core --create-issue --repo your-org/your-repo
# Use Turso store
FLAKY_TESTS_STORE=turso \
TURSO_URL=libsql://... \
TURSO_AUTH_TOKEN=... \
bunx @flaky-tests/core