flaker core computation engine
Dependencies
Upgrading from 0.0.x / 0.1.x? See docs/how-to-use.md#config-migration for the full key rename map. Starting with 0.2.0, the CLI refuses to start on legacy configs and points to the migration guide.Upgrading from 0.4.x? See docs/migration-0.4-to-0.5.md or docs/migration-0.4-to-0.5.ja.md. 0.5.x keeps existing profiles working, but the recommended user-facing commands are now gate-oriented.
pnpm add -D @mizchi/flakerpnpm dlx @mizchi/flaker --help# In Claude Code
/plugin marketplace add mizchi/flaker
/plugin install flaker@flakerimport {
"mizchi/flaker" @flaker,
}
test "sample from historical runs" {
let meta = @flaker.build_sampling_meta(
[
@flaker.SamplingHistoryRowInput::{
suite: "tests/login.spec.ts",
test_name: "login works",
task_id: Some("web-login"),
filter: None,
variant: None,
test_id: None,
status: "passed",
retry_count: 0,
duration_ms: 1200,
created_at: "2026-04-03T00:00:00.000Z",
},
],
[
@flaker.SamplingListedTestInput::{
suite: "tests/login.spec.ts",
test_name: "login works",
task_id: Some("web-login"),
filter: None,
variant: None,
test_id: None,
},
],
)
let sampled = @flaker.sample_weighted(meta, count=1, seed=1UL)
assert_eq(sampled.length(), 1)
}moon run src/cmd/flaker --target js -- --help
moon run src/cmd/flaker --target native -- --version| Mental model | Current flaker shape (0.9.0) |
|---|---|
| Iteration Gate | profile.local |
| Merge Gate | profile.ci |
| Release Gate | usually a full run, often backed by profile.scheduled or a dedicated release workflow |
| Observation loop | flaker apply + flaker apply --emit daily (flaker ops daily deprecated in 0.9.0) |
| Triage loop | flaker status --gate merge --detail + flaker ops weekly (apply with [quarantine].auto=true also handles suggest/apply) |
| Incident loop | flaker ops incident (or flaker debug retry / confirm / diagnose) |
pnpm add -D @mizchi/flaker
pnpm flaker init --adapter <playwright|vitest|jest|junit> --runner <same or actrun>
# edit [affected].resolver in flaker.toml (workspace | glob | bitflow)
pnpm flaker doctor
pnpm flaker plan # preview what apply will do
pnpm flaker apply # converge (safe to re-run)
pnpm flaker status # dashboard + promotion driftCanonical command forms (0.9.0)The primary surface is 11 commands: init, plan, apply, status, run, doctor, debug, query, explain, import, report. The 0.7.0 legacy aliases were removed in 0.8.0. 0.9.0 re-deprecates flaker ops daily (removed in 1.0.0). ops weekly / ops incident remain Advanced first-class.
Canonical (0.9.0) Deprecated (since → removed) flaker apply (replaces collect ci / local / coverage / calibrate, quarantine suggest / apply, policy quarantine, analyze flaky-tag — all removed in 0.8.0) flaker apply --emit daily [--output <file>] flaker ops daily (deprecated 0.9.0, remove 1.0.0) flaker apply --emit weekly ops weekly remains first-class (operator narrative) flaker apply --output <file> new in 0.9.0 — saves ApplyArtifact JSON flaker plan --output <file> new in 0.9.0 — saves PlanArtifact JSON flaker status (replaces analyze kpi, kpi — removed in 0.8.0) flaker status --markdown (replaces analyze eval --markdown — removed in 0.8.0) flaker status --list flaky (replaces analyze flaky — removed in 0.8.0) flaker status --gate <name> --detail --json (replaces gate review / history / explain — removed in 0.8.0) Breaking JSON shape changes in 0.9.0: apply --json uses executed[*].status: "ok"|"failed"|"skipped" (was .ok: boolean + aborted). status --json uses drift.unmet[*].kind / .desired (was .field / .threshold). See CHANGELOG for full notes.
flaker init --owner your-org --name your-repoexport GITHUB_TOKEN=$(gh auth token)
flaker collect --days 30flaker import report <file> --adapter playwright --commit "$(git rev-parse HEAD)"flaker import report <file> --adapter playwright --source ci --commit <sha>flaker collect local --last 20[runner]
type = "playwright"
command = "pnpm exec playwright test -c playwright.config.ts"
[runner.actrun]
workflow = ".github/workflows/ci.yml"
local = true
trust = true
# job = "e2e"flaker status
flaker gate review merge
flaker gate history merge --json
flaker quarantine suggest --json
flaker ops weekly --jsonflaker analyze flaky
flaker analyze reason
flaker analyze eval --json
flaker analyze eval --markdown --window 7
flaker analyze eval --markdown --window 7 --output .artifacts/flaker-review.mdflaker run --dry-run --strategy hybrid --count 25
flaker run --dry-run --strategy affected --changed src/foo.ts
flaker run --dry-run --gate iteration --changed src/foo.tsflaker run --strategy hybrid --count 25
flaker run --strategy affected --changed src/foo.ts
flaker run --gate iteration --changed src/foo.ts
flaker run --runner actrun| Gate | Backing profile | Purpose |
|---|---|---|
| iteration | local | Fast local feedback for the author |
| merge | ci | PR / mainline gate |
| release | scheduled | Full or near-full verification |
# Auto-detects the backing profile
flaker run
# Explicit gate selection
flaker run --gate iteration
flaker run --gate merge
flaker run --gate release
# Advanced: explicit profile names still work
flaker run --profile local
flaker run --profile ci
flaker run --profile scheduled[runner]
type = "playwright"
command = "pnpm exec playwright test -c playwright.config.ts"
flaky_tag_pattern = "@flaky"
[profile.scheduled]
strategy = "full"
[profile.ci]
strategy = "hybrid"
sample_percentage = 30
adaptive = true # auto-adjust based on false negative rate
skip_flaky_tagged = true
[profile.local]
strategy = "affected"
max_duration_seconds = 60
fallback_strategy = "weighted"
skip_flaky_tagged = trueflaker ops weekly --json > .artifacts/flaker-weekly.jsonflaker analyze flaky-tag --json > .artifacts/flaky-tag-triage.jsonflaker analyze flaky-tag --json \
--add-threshold 30 \
--min-runs 10 \
--remove-after-passes 5flaker exec affected --changed src/foo.ts
flaker run --dry-run --gate iteration --changed src/foo.ts
flaker run --gate iteration --changed src/foo.ts- name: Run flaker
run: flaker run --gate merge
- name: Post PR comment
if: github.event_name == 'pull_request'
run: |
flaker report summary --adapter vitest --input report.json --pr-comment \
| gh pr comment ${{ github.event.pull_request.number }} --body-file -
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}flaker quarantine suggest --json --output .artifacts/quarantine-plan.json
flaker quarantine apply --from .artifacts/quarantine-plan.json --create-issuesflaker collect
flaker collect local
flaker import report <file> --adapter playwright
flaker collect coverage --format istanbul --input coverage/coverage-final.jsonflaker run --dry-run --strategy random --count 20
flaker run --dry-run --strategy weighted --count 20
flaker run --dry-run --strategy affected
flaker run --dry-run --strategy hybrid --count 50
flaker run --strategy hybrid --count 50
flaker run --strategy affected --changed src/foo.tsResolution order (highest to lowest):
1. Explicit CLI flag (--strategy, --percentage, --count)
2. [profile.<name>] in flaker.toml (via --profile or auto-detection)
3. [sampling] in flaker.toml (project default)
4. Built-in defaults
Notes:
--count overrides --percentage when both are given
--changed overrides git auto-detection
--dry-run suppresses execution, still records selection telemetry
--explain can be combined with --dry-run or a real runflaker analyze flaky
flaker analyze reason
flaker analyze eval
flaker dev train
flaker analyze query "SELECT * FROM test_results LIMIT 20"# Remote: triggers workflow_dispatch, waits for result
flaker debug confirm "tests/api.test.ts:handles timeout"
flaker debug confirm "tests/api.test.ts:handles timeout" --repeat 10
# Local: runs via test runner directly
flaker debug confirm "tests/api.test.ts:handles timeout" --runner local# Re-run failed tests from most recent CI failure
flaker debug retry
# From a specific workflow run
flaker debug retry --run 12345678flaker quarantine suggest --json --output .artifacts/quarantine-plan.json
flaker quarantine apply --from .artifacts/quarantine-plan.json --create-issues
flaker policy check
flaker exec affected --changed src/foo.tsflaker report summary --adapter vitest --input report.json --markdown
flaker report summary --adapter vitest --input report.json --pr-comment
flaker report diff --base base.json --head head.json[repo]
owner = "your-org"
name = "your-repo"
[storage]
path = ".flaker/data.duckdb"
[adapter]
type = "playwright"
[runner]
type = "playwright"
command = "pnpm exec playwright test"
flaky_tag_pattern = "@flaky"
[affected]
resolver = "workspace"
[flaky]
window_days = 14
detection_threshold_ratio = 0.02
[quarantine]
auto = true
flaky_rate_threshold_percentage = 30
min_runs = 10
[sampling]
strategy = "hybrid"
sample_percentage = 30
holdout_ratio = 0.1
co_failure_window_days = 90
[profile.scheduled]
strategy = "full"
[profile.ci]
strategy = "hybrid"
sample_percentage = 30
adaptive = true
skip_flaky_tagged = true
[profile.local]
strategy = "affected"
max_duration_seconds = 60
fallback_strategy = "weighted"
skip_flaky_tagged = truenode_modules/@mizchi/flaker/dist/cli/main.jsfn build_affected_report(targets : Array[AffectedTargetInput], direct_selections : Array[AffectedDirectSelectionInput], transitive_tasks : Array[AffectedTransitiveTaskInput], unmatched : Array[String]) -> AffectedReportCoreOutputfn build_sampling_meta(history_rows : Array[SamplingHistoryRowInput], listed_tests : Array[SamplingListedTestInput]) -> Array[TestMeta]fn compute_quarantine_exit_code(results : Array[QuarantineRuntimeResultInput], fallback_exit_code : Int) -> Intfn find_affected_nodes(graph : DependencyGraphInput, changed_files : Array[String]) -> Array[String]fn find_matching_quarantine(entries : Array[QuarantineEntryInput], task_id : String, spec : String, title : String) -> Intfn get_affected_test_patterns(graph : DependencyGraphInput, affected_ids : Array[String]) -> Array[String]fn run_config_check(listed_tests : Array[ConfigCheckListedTestInput], discovered_specs : Array[String], task_definitions : Array[ConfigCheckTaskDefinitionInput]) -> ConfigCheckCoreOutputfn summarize_quarantine(entries : Array[QuarantineEntryInput], tasks : Array[QuarantineTaskOwnershipInput], existing_specs : Array[String], now_date : String, expires_soon_days : Int) -> QuarantineSummaryCoreOutputflaker core computation engine
Dependencies