skills/abtesting/abtesting-web/SKILL.md
Web A/B: feature flags LaunchDarkly/Unleash, cookie segmentation, Cloudflare Workers A/B, header routing
npx skillsauth add alphaonedev/openclaw-graph abtesting-webInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill, abtesting-web, facilitates A/B testing for web applications by managing feature flags with tools like LaunchDarkly or Unleash, implementing cookie-based user segmentation, and routing traffic via Cloudflare Workers or header-based rules. It ensures controlled experimentation to optimize web features without downtime.
Use this skill for dynamic feature rollouts in web apps, such as testing new UI elements, personalizing content via cookies, or splitting traffic for experiments. Apply it when you need scalable A/B testing with tools like LaunchDarkly for enterprise features or Unleash for cost-effective setups, especially in environments with Cloudflare.
/api/features endpoint.document.cookie.includes('variant=A').fetch(event.request) with conditional logic for 50% traffic split.event.request.headers.get('X-Experiment') === 'group1', route accordingly.{"name": "new-feature", "enabled": true, "variants": ["A", "B"]}.To set up A/B testing, first initialize the skill with your API key, e.g., run openclaw abtesting-web init --provider launchdarkly --key $LAUNCHDARKLY_API_KEY. For ongoing use, query flags in your web app code: import the SDK and check status like ldClient.variation('feature-key', false). Pattern for segmentation: In Cloudflare Workers, add event handlers to evaluate cookies or headers before proxying requests. Always test locally first with a mock server, then deploy via openclaw abtesting-web deploy --env production.
openclaw abtesting-web init --cluster abtesting --tags web,feature-flags. Create a flag via openclaw abtesting-web create-flag --name new-ui --provider unleash --variants A,B. List flags with openclaw abtesting-web list --key $CLOUDFLARE_API_TOKEN.https://app.launchdarkly.com/api/v2/flags/{projectKey}/{featureFlagKey} with JSON body like {"name": "test-flag", "variations": ["control", "variant"]}. For Unleash, GET https://your-unleash-instance/api/features with auth header Authorization: $UNLEASH_API_KEY.addEventListener('fetch', event => {
const variant = Math.random() < 0.5 ? 'A' : 'B';
event.respondWith(fetch(event.request, { headers: { 'X-Variant': variant } }));
});
const ldClient = require('launchdarkly-node-server-sdk');
ldClient variation('feature-key', false, (err, variation) => console.log(variation));
Integrate by setting environment variables for keys, e.g., export LAUNCHDARKLY_API_KEY and CLOUDFLARE_API_TOKEN. For web apps, add the skill as a middleware: in Express.js, use app.use(abtestingMiddleware({ provider: 'launchdarkly' })). Config format: Use a YAML file like abtesting-config.yaml with content:
provider: launchdarkly
flags:
- name: homepage-test
variants: [A, B]
percentage: 50
To combine with other services, ensure CORS is enabled for API calls, and handle webhooks for flag updates. For Cloudflare, bind the Worker to your domain via the dashboard or CLI: wrangler publish --env production.
Common errors include invalid API keys (HTTP 401), resolved by checking echo $LAUNCHDARKLY_API_KEY and retrying. For flag not found, catch with try-catch in code, e.g.:
try {
const flag = await ldClient.getFeatureFlag('nonexistent');
} catch (error) {
console.error('Flag error:', error.message); // Output: "Feature flag not found"
fallbackToDefault();
}
Handle network issues by adding retries: in Cloudflare Workers, use event.waitUntil(fetchWithRetry(event.request)). For segmentation errors, validate cookies early, e.g., if parsing fails, default to control group. Use CLI debug mode: openclaw abtesting-web run --debug to log API responses.
openclaw abtesting-web init --provider launchdarkly --key $LAUNCHDARKLY_API_KEY. Then, create the flag: openclaw abtesting-web create-flag --name button-test --variants control,experimental. In your frontend code, check the flag: if (ldClient.variation('button-test') === 'experimental') { renderNewButton(); }. Finally, monitor via Cloudflare logs for traffic splits.openclaw abtesting-web deploy-worker --script path/to/worker.js. In the worker.js file, include:
addEventListener('fetch', event => {
const cookieValue = event.request.headers.get('cookie')?.includes('segment=premium') ? 'premium' : 'standard';
event.respondWith(fetch(event.request, { headers: { 'X-Segment': cookieValue } }));
});
Use this to route premium users to variant A.tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui