feature-flag-manager
When the user needs to implement feature flags, gradual rollouts, or experiment bucketing. Use when the user mentions "feature flag," "feature toggle," "gradual rollout," "canary release," "percentage rollout," "kill switch," "user bucketing," "experiment assignment," or "dark launch." Covers flag evaluation, deterministic user assignment, targeting rules, and flag lifecycle management. For experiment design, see ab-test-setup. For event tracking, see analytics-tracking.
What this skill does
# Feature Flag Manager
## Overview
Implements feature flag systems for controlled rollouts and A/B testing. Covers flag definition, deterministic user bucketing (same user always sees the same variant), attribute-based targeting, percentage rollouts, and flag lifecycle management. Builds self-hosted solutions — no third-party dependencies.
## Instructions
### 1. Flag Definition Schema
```typescript
interface FeatureFlag {
key: string; // "checkout-redesign"
type: 'boolean' | 'multivariate';
enabled: boolean; // Global kill switch
variants: string[]; // ["control", "new-checkout"]
allocation: number[]; // [50, 50] — percentage per variant
targeting?: TargetingRule[];
createdAt: Date;
updatedAt: Date;
}
interface TargetingRule {
attribute: string; // "plan", "country", "signupDate"
operator: 'eq' | 'neq' | 'in' | 'gt' | 'lt' | 'contains';
values: any[];
allocation?: number[]; // Override allocation for this segment
}
```
Store flags in database with in-memory cache (refresh every 30 seconds or on webhook).
### 2. Deterministic Bucketing
Use MurmurHash3 for stable, uniform distribution:
```typescript
import murmurhash from 'murmurhash';
function assignVariant(flagKey: string, userId: string, variants: string[], allocation: number[]): string {
const hash = murmurhash.v3(flagKey + ':' + userId);
const bucket = hash % 10000; // 0-9999 for 0.01% granularity
let cumulative = 0;
for (let i = 0; i < variants.length; i++) {
cumulative += allocation[i] * 100; // Convert percentage to basis points
if (bucket < cumulative) return variants[i];
}
return variants[0]; // Fallback to first variant
}
```
Properties:
- **Deterministic**: Same user + same flag = same variant, always
- **Independent**: Different flags produce independent assignments
- **Uniform**: MurmurHash3 distributes evenly across buckets
- **Stable on resize**: Changing 50/50 to 70/30 keeps most users in their original bucket
### 3. Flag Evaluation Pipeline
```
evaluateFlag(flagKey, userId, userAttributes):
1. Load flag config from cache
2. If flag.enabled === false → return default variant (control)
3. Check targeting rules in order:
- If user matches a rule → use that rule's allocation
- If no rules match → use default allocation
4. Compute bucket via deterministic hash
5. Map bucket to variant via allocation percentages
6. Log assignment event (for analytics)
7. Return variant name
```
### 4. Server-Side Integration
```typescript
// Express middleware — evaluate all active flags per request
app.use((req, res, next) => {
const userId = req.user?.id || req.cookies.anonymousId;
const attributes = {
plan: req.user?.plan,
country: req.headers['cf-ipcountry'],
signupDate: req.user?.createdAt,
};
req.flags = evaluateAllFlags(userId, attributes);
next();
});
// In route handler
app.get('/checkout', (req, res) => {
if (req.flags['checkout-redesign'] === 'new-checkout') {
return renderNewCheckout(req, res);
}
return renderCurrentCheckout(req, res);
});
```
### 5. Flag Lifecycle
```
1. CREATED — Flag defined, enabled=false, no traffic
2. TESTING — Enabled for internal users via targeting (email contains @company.com)
3. RAMPING — Gradual rollout: 5% → 25% → 50% → 100%
4. DECIDED — Experiment concluded, winner at 100%
5. ARCHIVED — Flag code removed, config kept for audit trail
```
Track lifecycle in database. Alert when flags are in DECIDED state for > 14 days (cleanup reminder).
### 6. Admin API
```
GET /api/flags — List all flags
POST /api/flags — Create flag
PATCH /api/flags/:key — Update allocation/targeting
PATCH /api/flags/:key/toggle — Enable/disable (kill switch)
GET /api/flags/:key/assignments — View user distribution
DELETE /api/flags/:key — Archive flag
```
## Examples
### Example 1: Boolean Feature Flag
**Prompt**: "Add a feature flag for our new search bar. Roll out to 10% of users first."
**Output**: Flag definition with boolean type, 90/10 allocation, evaluation middleware, and admin toggle endpoint.
### Example 2: Multi-Variant Experiment
**Prompt**: "Test three pricing page layouts: current, simplified, and detailed. Only for US users on free plan."
**Output**: Multivariate flag with targeting rules (country=US, plan=free), three-way allocation (34/33/33), bucketing implementation, and assignment logging for analytics.
## Guidelines
- **Always use server-side evaluation** — client-side flags leak experiment details and flicker
- **Hash with experiment key** — ensures independent randomization across experiments
- **Cache flag configs** — don't query database on every request; 30s TTL is fine
- **Log every assignment** — needed for experiment analysis; include flag, variant, userId, timestamp
- **Build a kill switch** — `enabled: false` must immediately disable the flag globally
- **Clean up old flags** — stale flags become tech debt; alert after 14 days post-decision
- **Test the bucketing** — verify distribution is uniform with 10K+ simulated users before shipping
- **Support anonymous users** — use a cookie-based anonymous ID for pre-login bucketing
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.