Skip to main content
AI test selection reads a git diff and runs a focused set of Momentic tests that covers the changed behavior. Use it in pull request CI when running every test would take too long.
This feature is in alpha and may change. Contact us to join the waitlist.

Run selected tests

Run it from the root of your git repository:
In supported CI providers, Momentic detects the pull request base ref. Use --ai-select-base when you need to set it explicitly:
Test files changed directly in the diff are included. Changes to shared modules do not force every consuming test to run; selection chooses representative coverage for the affected behavior. If Momentic cannot build a safe selection, it runs the full in-scope test set instead.

How selection works

Momentic combines three sources of evidence:
  1. The git diff identifies the code and behavior that changed.
  2. A local code index traces imports and downstream consumers in your repository.
  3. The app graph connects product journeys and UI states to the tests that exercised them in real runs.
The app graph provides runtime relationships that static imports cannot express, such as a backend change surfacing in a browser flow. Selection quality improves as the graph observes more of your application and test suite. Build-graph systems such as Bazel are effective at selecting work within a declared dependency graph. Applying that approach to end-to-end tests requires teams to manually define and maintain the relationship between build targets, services, and tests. Code imports also stop at network and product boundaries: they do not show that a frontend journey depends on an API, queue, data store, or third-party integration. The app graph adds those observed runtime relationships without requiring every cross-system dependency to be orchestrated by hand. The test budget is a soft cap. Momentic can exceed it when more tests are needed to cover distinct changed behavior.

Guide selection with a prompt

Use --prompt to add repository-specific selection guidance that Momentic cannot infer from the diff, code index, or app graph:
The prompt augments Momentic’s built-in selection instructions. It does not replace them. Repeat the flag to provide multiple instructions; Momentic appends the values in command-line order. When you omit --prompt, the standard selection prompt is unchanged. The standalone command accepts the same flag:

Use the code index in GitHub Actions

Check out full git history and install the code-index parsers before running the command:
See the complete GitHub Actions example for setup, code-index caching, standalone selection output, test execution, and result uploads.

Preview a selection

Use shadow mode to compare a selection with the full test run before using it to gate pull requests. Momentic still runs every in-scope test and records which ones selection would have skipped.
To inspect a selection without running tests, use momentic ai select:
The JSON result contains selectedTests for an explicit handoff and sets fallbackToRunAll when Momentic cannot produce a safe selection.

Build a dynamic CI matrix

Run standalone selection once in a planning job, convert the selected test paths into your CI system’s matrix format, and pass each shard’s paths to momentic run. This lets a small selection use one runner while larger selections create more shards. Your planner should handle three outcomes:
  1. Run the paths in selectedTests.
  2. Run every in-scope test when fallbackToRunAll is true.
  3. Skip the execution job for a valid selection with no tests.
The dynamic GitHub Actions example shows the complete workflow. Its matrix builder is a small Node.js script you can adapt to another CI provider or shard size. Use momentic run --ai-select when you do not need to customize the handoff; it performs selection and execution in one command.

When selection chooses zero tests

A selection that picks no tests is a normal outcome for non-behavioral changes. The run group still uploads with the selection plan, and the GitHub pull request comment explains why nothing ran instead of staying silent. When onboarding onto AI selection, set your CI up so zero-test selections reach Momentic:
  • Always run momentic results upload. Do not gate the upload step on the runs directory existing or on tests having run; a zero-test run group uploads its metadata, which is what powers the pull request comment.
  • When you merge sharded results before uploading, pass --allow-empty to momentic results merge so shards without runs keep their selection plans in the merged archive.
  • momentic results check treats a zero-test results directory as clean, so a check step needs no special casing.
The AI Select example workflows follow this setup, including a zero-selection reporting job for the dynamic matrix pattern where an empty selection skips the execution jobs entirely.

Benchmark

The benchmark uses real code changes across frontend, backend, CLI, shared-library, configuration, and non-behavioral scenarios. The GPT-5.5 Codex baseline receives the same changes and candidate test files as Momentic, but does not use the app graph or its investigation workflow. Cross-functional recall is measured on a harder subset of those cases that span product boundaries. We can share the raw results and reproduction harness on request.

Notes

  • The command needs enough git history to resolve the base ref. Use fetch-depth: 0 with actions/checkout.
  • The code index currently analyzes TypeScript and JavaScript imports. Runtime app graph evidence can still connect behavior across other boundaries.
  • A budget limits selection size, not safety behavior. Selection can fall back to running all tests.