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