ab-testing
- Repo stars 0
- Author updated Live
- Author repo skills-registry
- Domain
- Engineering
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @tomevault-io · no license declared
- Token usage
- Lean
- Setup complexity
- Plug-and-play
- External API key
- Not required
- Operating systems
- Unspecified (assume cross-platform)
- Runtime requirements
- Python
- Permissions
-
- Read-only
- Write / modify
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: ab-testing
description: >- Use when this capability is needed. // middleware.ts - Server-side assignment (no flicker) im…
category: engineering
runtime: Python
---
# ab-testing output preview
## PART A: Task fit
- Use case: >- Use when this capability is needed. // middleware.ts - Server-side assignment (no flicker) import { NextResponse, type NextRequest } from 'next/server' export function middleware(request: NextRequest) { runs entirely locally; runs on Python. Works with Claude Code, Cursor, Cline and 23 more..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “Quick Start / Architecture / Workflow” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “>- Use when this capability is needed. // middleware.ts - Server-side assignment (no flicker) import { NextResponse, type NextRequest } from 'next/server' export function middleware(request: NextRequest) { runs entirely locally; runs on Python. Works with Claude Code, Cursor, Cline and 23 more.”.
- **02** When the source has headings, the agent prioritizes “Quick Start / Architecture / Workflow” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source does not require a stable slash command. After installation, invoke the skill by name and describe the task.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files.
Start with a small task and check whether the result follows “Quick Start / Architecture / Workflow”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: ab-testing
description: >- Use when this capability is needed. // middleware.ts - Server-side assignment (no flicker) im…
category: engineering
source: tomevault-io/skills-registry
---
# ab-testing
## When to use
- >- Use when this capability is needed. // middleware.ts - Server-side assignment (no flicker) import { NextResponse, t…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “Quick Start / Architecture / Workflow” and keep inference separate from source facts.
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "ab-testing" {
input -> user goal + target files + boundaries + acceptance criteria
context -> Quick Start / Architecture / Workflow
rules -> SKILL.md triggers / order / output contract
runtime -> Python | read files, write/modify files | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} A/B Testing Platform for SaaS
Stack: Next.js 16 + Edge Middleware + GA4/GTM + Supabase + Rust-WASM (for stats) Why DIY?: Google Optimize sunset Sept 2023. GA4 has no native A/B testing.
Quick Start
// middleware.ts - Server-side assignment (no flicker)
import { NextResponse, type NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const response = NextResponse.next()
if (!request.cookies.get('exp_hero')) {
const variant = Math.random() < 0.5 ? 'A' : 'B'
response.cookies.set('exp_hero', variant, { maxAge: 60*60*24*30, path: '/' })
}
return response
}
// Track with GA4
window.dataLayer?.push({
event: 'experiment_view',
experiment_name: 'hero_test',
experiment_variant: variant
})
Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ A/B TESTING FLOW │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ 1. ASSIGN (Edge Middleware) │
│ ══════════════════════════ │
│ Request → Check cookie → Random assign → Set cookie → Response │
│ ✓ No flicker (server-side) ✓ Consistent (cookie-based) │
│ │
│ 2. RENDER │
│ ═════════ │
│ Server/Client Component → Read cookie → Show variant │
│ │
│ 3. TRACK (GTM + GA4) │
│ ════════════════════ │
│ dataLayer.push → GTM triggers → GA4 events with variant param │
│ │
│ 4. ANALYZE │
│ ═════════ │
│ GA4 Explorations OR Supabase + Rust-WASM Bayesian analysis │
│ │
│ 5. PERSONALIZE (Advanced) │
│ ═════════════════════════ │
│ Contextual bandit → Best variant per user segment │
│ │
└─────────────────────────────────────────────────────────────────────┘
Workflow
-
- Define experiment config (name, variants, weight, segment rules)
-
- Implement middleware assignment (see VARIANT-ASSIGNMENT.md)
-
- Wire up GTM tracking (experiment_view, conversions with variant param)
-
- Register
experiment_variantas Custom Dimension in GA4
- Register
-
- Collect data (minimum 2 weeks for weekly patterns)
-
- Analyze significance (see STATISTICAL-ANALYSIS.md)
-
- Roll out winner or iterate
Statistical Methods (Choose One)
| Method | Best For | Decision Output |
|---|---|---|
| Frequentist | Fixed sample, strict control | p-value < 0.05 → significant |
| Bayesian | Continuous monitoring, intuitive | P(B > A) = 96% → B likely better |
| Multi-Armed Bandit | Optimize during test | Auto-shift traffic to winner |
| Contextual Bandit | Personalization | Best variant per user segment |
Quick Bayesian (Beta-Binomial):
# A: 50/1000 conversions, B: 72/1000
import scipy.stats as stats
a_samples = stats.beta(51, 951).rvs(100000) # Beta(1+50, 1+950)
b_samples = stats.beta(73, 929).rvs(100000) # Beta(1+72, 1+928)
p_b_wins = (b_samples > a_samples).mean() # → ~0.96 (96%)
Full analysis guide: STATISTICAL-ANALYSIS.md
Key Patterns
Multiple Concurrent Experiments
// middleware.ts
const EXPERIMENTS = {
hero_cta: { weight: 0.5 },
pricing_layout: { weight: 0.5 },
signup_flow: { weight: 0.2 }, // 20% on new variant
}
for (const [name, config] of Object.entries(EXPERIMENTS)) {
if (!request.cookies.get(`exp_${name}`)) {
const variant = Math.random() < config.weight ? 'B' : 'A'
response.cookies.set(`exp_${name}`, variant, { maxAge: 2592000, path: '/' })
}
}
Phased Rollout
// Config stored in Supabase or Vercel Edge Config
const rolloutPhases = {
early_access: 0.1, // 10% new
public_beta: 0.5, // 50% new
general: 1.0 // 100% new (winner)
}
Tracking Conversions
// Include variant in ALL relevant events
window.dataLayer?.push({
event: 'sign_up',
method: 'google',
experiment_name: 'hero_cta',
experiment_variant: getCookie('exp_hero_cta'),
eventId: crypto.randomUUID() // De-duplication
})
When to Use Rust-WASM
| Use Case | Why Rust |
|---|---|
| Monte Carlo simulation (100k+ draws) | 10-100x faster than JS |
| Bayesian posterior computation | Numerical precision |
| Contextual bandit inference | Real-time ML at edge |
| Cross-platform consistency | Same logic in browser + server |
WASM is NOT needed for: Simple random assignment, cookie handling, event tracking
See: RUST-WASM.md
Anti-Patterns
| Don't | Why |
|---|---|
| Client-side variant assignment | Causes flicker, inconsistent |
| End test early ("B winning after 2 days!") | Random noise, not signal |
| Multiple changes in one variant | Can't isolate what worked |
| Overlapping tests on same element | Interaction effects confound |
| Skip sample size calculation | Under-powered = false negatives |
| Ignore segments | Winner overall may lose for key segment |
Validation Checklist
- No flicker on page load (verify in slow 3G)
- Cookie persists across sessions (check 30-day expiry)
- GTM Preview shows correct variant in dataLayer
- GA4 DebugView receives events with variant param
- Custom dimension
experiment_variantregistered in GA4 - ~50/50 split verified (check GA4 Realtime)
- Conversion events include variant attribution
Reference Index
By Task
| I need to... | Read |
|---|---|
| Implement variant assignment | VARIANT-ASSIGNMENT.md |
| Choose a statistical method | STATISTICAL-ANALYSIS.md |
| Set up GTM/GA4 tracking | GA4-GTM-TRACKING.md |
| Build admin dashboard | ADMIN-DASHBOARD.md |
| Add personalization/bandits | PERSONALIZATION.md |
| Optimize with Rust-WASM | RUST-WASM.md |
| Quick lookup (tools, formulas) | QUICK-REFERENCE.md |
By Topic
| Topic | Reference |
|---|---|
| Server-side assignment, multiple experiments, weighted splits | VARIANT-ASSIGNMENT.md |
| Frequentist vs Bayesian vs Bandits, sample size, pitfalls | STATISTICAL-ANALYSIS.md |
| GTM variables, GA4 events, BigQuery queries, debugging | GA4-GTM-TRACKING.md |
| Database schema, API routes, UI components, real-time updates | ADMIN-DASHBOARD.md |
| Segments, rules-based, Thompson sampling, contextual bandits | PERSONALIZATION.md |
| Rust setup, beta sampling, bandit implementation, Next.js integration | RUST-WASM.md |
| Tool recommendations, decision guide, formulas, cheat sheet | QUICK-REFERENCE.md |
Source: danzam98/claude-skills-toolkit — distributed by TomeVault.
Decide Fit First
Design Intent
How To Use It
Boundaries And Review