Growth Engineering Skill
Infrastructure and patterns for product-led growth, experimentation, and conversion optimization.
Feature Flag Systems
Implementation Pattern
// lib/feature-flags.ts
import { PostHog } from 'posthog-node';
const posthog = new PostHog(process.env.POSTHOG_API_KEY!);
interface FeatureFlags {
'new-onboarding-flow': boolean;
'pricing-experiment': 'control' | 'variant-a' | 'variant-b';
'ai-suggestions': boolean;
}
export async function getFlag<K extends keyof FeatureFlags>(
key: K,
userId: string,
): Promise<FeatureFlags[K]> {
const value = await posthog.getFeatureFlag(key, userId);
return value as FeatureFlags[K];
}
// Usage in component
const showNewOnboarding = await getFlag('new-onboarding-flow', user.id);
Feature Flag Best Practices
- Short-lived flags: Remove after experiment concludes (< 2 weeks)
- Long-lived flags: Ops toggles for gradual rollouts, kill switches
- Never nest feature flags (creates exponential complexity)
- Clean up stale flags monthly
- Log flag evaluations for debugging
A/B Testing Infrastructure
Experiment Design
// lib/experiments.ts
interface Experiment {
id: string;
name: string;
variants: {
id: string;
weight: number; // 0-100, must sum to 100
}[];
targetAudience: {
percentage: number; // % of users included
filters?: Record<string, unknown>;
};
primaryMetric: string;
secondaryMetrics: string[];
minimumSampleSize: number;
startDate: Date;
endDate?: Date;
}
// Track experiment exposure
function trackExposure(experimentId: string, variantId: string, userId: string) {
analytics.capture({
event: '$experiment_started',
distinctId: userId,
properties: {
$experiment_id: experimentId,
$variant_id: variantId,
},
});
}
Statistical Significance
- Minimum sample size: Calculate before starting (use Evan Miller calculator)
- Don't peek: Set duration upfront, don't stop early on promising results
- Sequential testing: Use if you must check early (adjusts p-values)
- Minimum detectable effect: Define what improvement matters (e.g., 5% lift)
Product-Led Growth Patterns
Activation Metrics
| Stage |
Metric |
Example |
| Sign up |
Registration complete |
User creates account |
| Setup |
Profile complete |
Fills required fields |
| Aha moment |
Core value experienced |
Creates first project |
| Habit |
Repeated engagement |
3 sessions in first week |
| Revenue |
Conversion to paid |
Subscribes to plan |
Viral Loops
// Referral system pattern
interface Referral {
referrerId: string;
referredEmail: string;
status: 'pending' | 'signed_up' | 'activated' | 'converted';
rewardGranted: boolean;
}
// Track referral funnel
function trackReferralStep(referralId: string, step: Referral['status']) {
analytics.capture({
event: 'referral_step',
properties: { referralId, step },
});
}
Conversion Optimization
- Reduce friction: Minimize form fields, enable social login
- Social proof: Show user counts, testimonials, logos
- Urgency: Trial countdown, limited-time offers (use sparingly)
- Value demonstration: Interactive demos, free tier with clear upgrade path
- Personalization: Onboarding flow based on use case selection
Growth Metrics
| Metric |
Formula |
Target |
| Activation rate |
Activated / Signed up |
> 40% |
| Trial-to-paid |
Paid / Trial started |
> 15% |
| Net revenue retention |
(Start MRR + Expansion - Contraction - Churn) / Start MRR |
> 110% |
| Viral coefficient |
Invites sent * Conversion rate |
> 0.5 |
| Time to value |
Median time from signup to aha moment |
< 5 min |
| DAU/MAU ratio |
Daily active / Monthly active |
> 20% |
Experimentation Platforms
| Platform |
Type |
Best For |
| PostHog |
Self-hosted/cloud |
Full-stack, open source |
| LaunchDarkly |
Cloud |
Feature flags at scale |
| Statsig |
Cloud |
Auto-stats, warehouse-native |
| Growthbook |
Self-hosted/cloud |
Open source, Bayesian stats |
| Optimizely |
Cloud |
Enterprise, multi-channel |
Related Resources
~/.claude/skills/product-analytics/SKILL.md - Analytics and tracking
~/.claude/agents/product-analytics-specialist.md - Analytics agent
~/.claude/skills/authentication-patterns/SKILL.md - Auth for PLG
Measure everything. Experiment constantly. Remove what doesn't work.
1---2name: growth-engineering3description: A/B testing infrastructure, feature flags (LaunchDarkly, Unleash), experimentation platforms, PLG patterns, and funnel optimization. Use when building experimentation systems, implementing feature toggles, or optimizing conversion funnels.4---5
6# Growth Engineering Skill
7
8Infrastructure and patterns for product-led growth, experimentation, and conversion optimization.
9
10---
11
12## Feature Flag Systems
13
14### Implementation Pattern
15
16```typescript
17// lib/feature-flags.ts
18import { PostHog } from 'posthog-node';
19
20const posthog = new PostHog(process.env.POSTHOG_API_KEY!);
21
22interface FeatureFlags {
23 'new-onboarding-flow': boolean;
24 'pricing-experiment': 'control' | 'variant-a' | 'variant-b';
25 'ai-suggestions': boolean;
26}
27
28export async function getFlag<K extends keyof FeatureFlags>(
29 key: K,
30 userId: string,
31): Promise<FeatureFlags[K]> {
32 const value = await posthog.getFeatureFlag(key, userId);
33 return value as FeatureFlags[K];
34}
35
36// Usage in component
37const showNewOnboarding = await getFlag('new-onboarding-flow', user.id);
38```
39
40### Feature Flag Best Practices
41
42- Short-lived flags: Remove after experiment concludes (< 2 weeks)
43- Long-lived flags: Ops toggles for gradual rollouts, kill switches
44- Never nest feature flags (creates exponential complexity)
45- Clean up stale flags monthly
46- Log flag evaluations for debugging
47
48---
49
50## A/B Testing Infrastructure
51
52### Experiment Design
53
54```typescript
55// lib/experiments.ts
56interface Experiment {
57 id: string;
58 name: string;
59 variants: {
60 id: string;
61 weight: number; // 0-100, must sum to 100
62 }[];
63 targetAudience: {
64 percentage: number; // % of users included
65 filters?: Record<string, unknown>;
66 };
67 primaryMetric: string;
68 secondaryMetrics: string[];
69 minimumSampleSize: number;
70 startDate: Date;
71 endDate?: Date;
72}
73
74// Track experiment exposure
75function trackExposure(experimentId: string, variantId: string, userId: string) {
76 analytics.capture({
77 event: '$experiment_started',
78 distinctId: userId,
79 properties: {
80 $experiment_id: experimentId,
81 $variant_id: variantId,
82 },
83 });
84}
85```
86
87### Statistical Significance
88
89- Minimum sample size: Calculate before starting (use Evan Miller calculator)
90- Don't peek: Set duration upfront, don't stop early on promising results
91- Sequential testing: Use if you must check early (adjusts p-values)
92- Minimum detectable effect: Define what improvement matters (e.g., 5% lift)
93
94---
95
96## Product-Led Growth Patterns
97
98### Activation Metrics
99
100| Stage | Metric | Example |
101|-------|--------|---------|
102| Sign up | Registration complete | User creates account |
103| Setup | Profile complete | Fills required fields |
104| Aha moment | Core value experienced | Creates first project |
105| Habit | Repeated engagement | 3 sessions in first week |
106| Revenue | Conversion to paid | Subscribes to plan |
107
108### Viral Loops
109
110```typescript
111// Referral system pattern
112interface Referral {
113 referrerId: string;
114 referredEmail: string;
115 status: 'pending' | 'signed_up' | 'activated' | 'converted';
116 rewardGranted: boolean;
117}
118
119// Track referral funnel
120function trackReferralStep(referralId: string, step: Referral['status']) {
121 analytics.capture({
122 event: 'referral_step',
123 properties: { referralId, step },
124 });
125}
126```
127
128### Conversion Optimization
129
130- Reduce friction: Minimize form fields, enable social login
131- Social proof: Show user counts, testimonials, logos
132- Urgency: Trial countdown, limited-time offers (use sparingly)
133- Value demonstration: Interactive demos, free tier with clear upgrade path
134- Personalization: Onboarding flow based on use case selection
135
136---
137
138## Growth Metrics
139
140| Metric | Formula | Target |
141|--------|---------|--------|
142| Activation rate | Activated / Signed up | > 40% |
143| Trial-to-paid | Paid / Trial started | > 15% |
144| Net revenue retention | (Start MRR + Expansion - Contraction - Churn) / Start MRR | > 110% |
145| Viral coefficient | Invites sent * Conversion rate | > 0.5 |
146| Time to value | Median time from signup to aha moment | < 5 min |
147| DAU/MAU ratio | Daily active / Monthly active | > 20% |
148
149---
150
151## Experimentation Platforms
152
153| Platform | Type | Best For |
154|----------|------|----------|
155| PostHog | Self-hosted/cloud | Full-stack, open source |
156| LaunchDarkly | Cloud | Feature flags at scale |
157| Statsig | Cloud | Auto-stats, warehouse-native |
158| Growthbook | Self-hosted/cloud | Open source, Bayesian stats |
159| Optimizely | Cloud | Enterprise, multi-channel |
160
161---
162
163## Related Resources
164
165- `~/.claude/skills/product-analytics/SKILL.md` - Analytics and tracking
166- `~/.claude/agents/product-analytics-specialist.md` - Analytics agent
167- `~/.claude/skills/authentication-patterns/SKILL.md` - Auth for PLG
168
169---
170
171_Measure everything. Experiment constantly. Remove what doesn't work._