Implement and review MetaMask Extension A/B tests using the canonical repository standard. Use for any task that adds or modifies A/B test flags, variant configs, useABTest usage, analytics payloads, or A/B-test-related tests and docs.
Canonical workflow for implementing and reviewing MetaMask Extension A/B tests.
Do not use this skill for general analytics work that does not involve A/B
test flags, useABTest, active_ab_tests, or related tests/docs.
Implementation ChecklistFiles To ModifyAnalytics Payload ChangesTests To RunCompliance Check ResultFor implementation or review tasks, follow this workflow:
rg -n "useABTest\\(|active_ab_tests|ab_tests|Abtest|feature-flag-registry|RemoteFeatureFlagController" app shared ui test docs
rg -n "Experiment Viewed|ExperimentViewed" app shared ui
ui/.{teamName}{ticketId}Abtest{TestName}.useABTest(flagKey, variants) and keep a control variant in
the variants object.variantName and isActive from the hook for business-event
instrumentation.control and isActive: false.useABTest for the automatic Experiment Viewed exposure
event.active_ab_tests manually only for business events that bypass the
shared MetaMetrics wrappers/controller path, and only when the
assignment is active.ab_tests: payloads. If a legacy touchpoint cannot be
migrated in the same change, keep the line annotated with
LEGACY_AB_TEST_ALLOWED and explain why.const experiment = useABTest('swapsSWAPS4135AbtestNumpadQuickAmounts', {
control: { buttons: [25, 50, 75, 'MAX'] },
treatment: { buttons: [50, 75, 90, 'MAX'] },
});
const activeABTests = experiment.isActive
? [
{
key: 'swapsSWAPS4135AbtestNumpadQuickAmounts',
value: experiment.variantName,
},
]
: undefined;
test/e2e/feature-flags/feature-flag-registry.ts with the production
default threshold-array JSON value.manifestFlags.remoteFeatureFlags or
FixtureBuilder.withRemoteFeatureFlags(...) when a test needs
deterministic assignment..agents/skills/ab-testing-implementation/scripts/check-ab-testing-compliance.ts# Current pre-commit / local implementation example
node --import tsx .agents/skills/ab-testing-implementation/scripts/check-ab-testing-compliance.ts --staged
# Current review-mode / explicit file set example
node --import tsx .agents/skills/ab-testing-implementation/scripts/check-ab-testing-compliance.ts --files app/path/to/file.ts,test/path/to/file.spec.ts --base origin/main
useABTest always has a control variant.Experiment Viewed is not emitted manually when useABTest is in
use.active_ab_tests rather than ab_tests.ui/-only config files.ui/hooks/useABTest.tsui/hooks/useABTest.test.tsshared/lib/ab-testing/resolve-ab-test-assignment.tsshared/lib/ab-testing/ab-test-analytics.tsui/selectors/remote-feature-flags.tsapp/scripts/controllers/metametrics-controller.tstest/e2e/feature-flags/feature-flag-registry.tsUse docs/ab-testing.md only when you need deeper background, additional
examples, FAQ answers, or local override guidance beyond this workflow.