Featurevisor

Building blocks

Targets

Targets define what goes into generated datafiles.

A target can represent an app, platform, microservice, microfrontend, or any other runtime artifact shape.

Defining Targets

Create target files in the targets directory:

targets/web.yml
description: Web app datafile

Only description is required.

If no extra information is provided, the target will include all features.

Generated datafile will be available at datafiles/featurevisor-web.json for this target. If you have environments configured, the datafile will be available at datafiles/production/featurevisor-web.json for the production environment.

Tags

Target tag selects features matching one tag:

targets/web.yml
description: Web app
tag: web

Use tags when a target needs a multi-tag selector:

targets/mobile.yml
description: Mobile apps
tags:
or:
- ios
- android

Supported shapes:

  • tag: "web"
  • tags: ["web"]
  • tags: { or: ["web", "mobile"] }
  • tags: { and: ["web", "checkout"] }

tag and tags are mutually exclusive. If both are omitted, the target includes all non-archived features.

Features

Use includeFeatures and excludeFeatures to select features by key. Patterns use glob-like * wildcard matching. A single * can match any number of characters. Empty patterns, surrounding spaces, and repeated ** wildcards are rejected.

targets/checkout.yml
description: Checkout datafile
includeFeatures:
- checkout*
- shared.navigation
excludeFeatures:
- checkout.internal*

Exclusions take precedence over inclusions. If includeFeatures is omitted, all features are candidates. To state that explicitly, * can be used directly:

targets/all.yml
description: All features
includeFeatures: "*"

Feature and tag selectors are combined with AND semantics. A feature must match both selectors to be included:

targets/web-checkout.yml
description: Web checkout features
tag: web
includeFeatures:
- checkout*

In this example, a checkout feature without the web tag is not included, even though its key matches checkout*.

Tag arrays and and or or tag groups must contain at least one tag.

Context

Target context represents values known at build time. Featurevisor applies this context while building the target datafile and removes redundant rules or segments where possible.

targets/chrome.yml
description: Chrome users
tag: web
context:
browser: chrome

Build Output

npx featurevisor build writes one datafile per target and environment:

Output
datafiles/staging/featurevisor-web.json
datafiles/production/featurevisor-web.json

Projects without environments write directly under datafiles:

Output
datafiles/featurevisor-web.json

Nested target files keep their directory structure:

Nested target
targets/apps/admin.yml
datafiles/apps/featurevisor-admin.json

Testing

Feature assertions can optionally choose a target:

tests/features/checkout.spec.yml
feature: checkout
assertions:
- target: web
environment: production
at: 50
context:
userId: "123"
expectedToBeEnabled: true

The test runner builds target datafiles in memory automatically.

CLI selection

Targets can be selected optionally in commands that build, inspect, test, or evaluate datafiles:

Commands
$ npx featurevisor build --target=web --target=mobile
$ npx featurevisor test --target=web --target=mobile
$ npx featurevisor evaluate --target=web --feature=checkout --context='{"userId":"123"}'
$ npx featurevisor benchmark --target=web --feature=checkout --context='{"userId":"123"}' --n=1000
$ npx featurevisor assess-distribution --target=web --feature=checkout --context='{}' --populateUuid=userId --n=1000
$ npx featurevisor list --features --target=web --target=mobile
$ npx featurevisor info --target=web --target=mobile

--target is repeatable. Runtime commands process each selected target datafile independently. Without --target, these commands keep their regular project-wide behavior. Normal builds build every target, while build --json and build --print accept at most one target.

Further reading

Previous
Features