Building blocks
Targets
Targets define what goes into generated datafiles.
A target can represent an application, platform, service, frontend, or any other runtime that should receive its own datafile.

Defining Targets#
Create target files in the targets directory:
description: Web app datafileOnly description is required. A target with no selectors includes every active feature and global variable:
description: Complete datafileArchived definitions are omitted. Feature exposure settings also remain authoritative.
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.
Selection model#
Features and global variables are filtered independently. Adding a selector for one kind does not make the other kind explicit.
| Target selectors | Features | Global variables |
|---|---|---|
| None | All active features | All active global variables |
includeFeatures only | Matching features | All active global variables |
excludeFeatures only | All except matching ones | All active global variables |
includeVariables only | All active features | Matching global variables |
excludeVariables only | All active features | All except matching ones |
| Both selector families | Filtered independently | Filtered independently |
tag or tags | Matching tagged features | Matching tagged variables |
Once an include selector is present, selection becomes explicit for that entity kind only. For example, this narrows features while retaining every active global variable:
description: Checkout features with all global variablesincludeFeatures: - checkout*Filter both kinds when both should be narrow:
description: Checkout datafileincludeFeatures: - checkout*includeVariables: - checkout*To exclude one kind completely, use * with its exclusion selector:
description: Checkout featuresincludeFeatures: - checkout*excludeVariables: "*"description: Checkout global variablesexcludeFeatures: "*"includeVariables: - checkout*Required feature dependencies may still be added to a datafile. A global variable that requires a feature brings that feature with it, even when excludeFeatures: "*" is present.
Tags#
Target tag selects features and global variables matching one tag:
description: Web apptag: webUse tags when a target needs a selector with several tags:
description: Mobile appstags: or: - ios - androidSupported shapes:
tag: "web"tags: ["web"]tags: { or: ["web", "mobile"] }tags: { and: ["web", "checkout"] }
tag and tags are mutually exclusive. Tag arrays and and or or groups must contain at least one tag. If both properties are omitted, tags do not filter features or global variables.
Features#
Use includeFeatures and excludeFeatures to select features by key. Patterns use glob style * matching. A single * can match any number of characters. Empty patterns, surrounding spaces, and repeated ** patterns are rejected.
description: Checkout datafileincludeFeatures: - checkout* - shared.navigationexcludeFeatures: - checkout.internal*Exclusions take precedence over inclusions. If includeFeatures is omitted, all features are candidates. Use * directly to state that explicitly:
description: All featuresincludeFeatures: "*"Feature and tag selectors use AND semantics. A feature must match both selectors:
description: Web checkout featurestag: webincludeFeatures: - checkout*In this example, a feature whose key starts with checkout is not included unless it also has the web tag.
Global variables#
Use includeVariables and excludeVariables to select global variables by key. They use the same glob style patterns as feature selectors:
description: Checkout datafileincludeVariables: - checkout* - shared.currencyexcludeVariables: - checkout.internal*Exclusions take precedence. If includeVariables is omitted, all global variables are candidates. Use includeVariables: "*" to state that explicitly.
Tags and variable patterns use AND semantics. A global variable must satisfy both when both are present:
description: Web checkout datafiletag: webincludeVariables: - checkout*This target includes global variables whose keys start with checkout and which also have the web tag.
Dependencies#
Target selectors choose the initial features and global variables. Featurevisor then adds the runtime definitions needed to evaluate them correctly:
- Required feature chains
- Segments used by selected feature rules and overrides
- Segments used by selected global variable overrides
Dependency closure takes precedence over feature inclusion and exclusion patterns. This prevents a narrowly filtered datafile from silently changing evaluation results because a required feature is missing.
Context#
Target context represents values known while building. Featurevisor applies this context and removes rules or segments that are no longer needed.
description: Chrome userstag: webcontext: browser: chromePromotable#
In a project that uses sets, a target can protect its existing destination definition from later promotions by setting promotable: false at the top level:
description: Production web datafilepromotable: falsetag: webincludeFeatures: - checkout*If the destination target exists, it remains unchanged when either the source or destination target has this field. A missing destination target is still created and retains promotable: false.
When promote --target=web is used, the source target selects the initial features and is included in the promotion. A protected existing destination target is preserved, but feature selection still comes from the source target used by the command.
Build Output#
npx featurevisor build writes one datafile per target and environment:
datafiles/staging/featurevisor-web.jsondatafiles/production/featurevisor-web.jsonProjects without environments write directly under datafiles:
datafiles/featurevisor-web.jsonNested target files keep their directory structure:
targets/apps/admin.ymldatafiles/apps/featurevisor-admin.jsonTesting#
Feature assertions can optionally choose a target:
feature: checkoutassertions: - target: web environment: production at: 50 context: userId: "123" expectedToBeEnabled: trueThe test runner builds target datafiles in memory automatically.
CLI selection#
Targets can be selected optionally in commands that build, inspect, test, or evaluate datafiles:
$ 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 whole project behaviour. Normal builds build every target, while build --json and build --print accept at most one target.

