AI-driven funnel optimization for product teams. Triple-agent A/B test design (Claude + Codex + Gemini), DAU-aware experiment windows, accumulated learning. PostHog-powered. MIT license.
/plugin marketplace add youtube-jocoding/funnel-optimize
/plugin install funnel-optimize@funnel-optimizeThen run /funnel-discover once, and /funnel-optimize whenever you want to advance the experiment cycle.
Manual install (without plugin): see Quickstart below.
You have PostHog data, you have a funnel, you want to run A/B tests systematically. But:
- Setting up the data pipeline takes weeks
- Designing experiments without bias is hard (vanity metrics β false ships)
- Running experiments without accumulating learning means you keep making the same mistakes
- Single-agent AI suggestions miss obvious alternatives
funnel-optimize automates the whole loop: data collection β diagnosis β experiment design (3 AI agents compete) β implementation β PR. Then it learns from every kill/ship and feeds patterns back into the next experiment.
The cadence isn't fixed. Discovery measures your DAU and computes how long an experiment needs to run to reach significance. As soon as the data crosses the threshold (min_sample_size + p < significance_level), the winner is applied β no calendar gate.
Analyzes your project + dumps your PostHog events + interviews you about KPIs and DAU β generates funnel-config.json (including a DAU-derived experiment_window_days).
Run it whenever you want to advance the loop. The pipeline detects state and acts accordingly:
- Collect PostHog data over the configured window
- Evaluate active experiment β
continuewhile collecting,winner_*oncemin_sample_size + p<significance_levelis reached,killedif guardrails trip - Diagnose funnel bottlenecks + cohort insights
- Triple-Agent compete (Claude / Codex / Gemini suggest experiments)
- 2-Layer evaluation (auto-scoring + AI PM review)
- Implement code changes + create PostHog feature flag (with build validation + rollback)
- Archive + commit + PR
After any run, dashboard.html is regenerated with a single command:
npm run dashboardIt produces a self-contained, zero-dep HTML file at docs/funnel-archive/dashboard.html with:
- Window-over-window funnel-rate trend (last 8 windows by default)
- Current funnel β every step's users, cumulative rate, drop-off, and KPI gap
- Active experiment β Test vs Control side-by-side with lift and p-value at every step (including purchase)
- Compact experiment history table
archive.mjs calls it automatically as its final step. Open the file directly in any browser β no server, no CDN, no build.
A static demo is committed at examples/demo/dashboard.html.
- Node 18+ (uses native fetch, no deps)
- PostHog (Cloud or self-hosted)
- Claude Code CLI (required for AI agents)
- Codex CLI / Gemini CLI (optional β auto-fallback to single-agent)
- Git + GitHub CLI (for PR creation)
Easier: use the Claude Code plugin install above. The manual flow is for users who don't have Claude Code or want full control over file locations.
# 1. Clone funnel-optimize beside your project
git clone https://github.com/youtube-jocoding/funnel-optimize.git ../funnel-optimize
# 2. Copy artifacts into YOUR project
cd /path/to/YOUR-project
mkdir -p scripts/funnel-automation .claude/skills/funnel-optimize
cp -r ../funnel-optimize/scripts/* scripts/funnel-automation/
cp ../funnel-optimize/skills/funnel-optimize/SKILL.md .claude/skills/funnel-optimize/
cp ../funnel-optimize/funnel-config.example.json funnel-config.json
cp ../funnel-optimize/.env.example .env
# 3. Fill in your PostHog credentials
$EDITOR .env # POSTHOG_API_KEY, POSTHOG_PROJECT_ID
# 4. Run Discovery (Claude Code will guide you through KPI + DAU setup)
node scripts/funnel-automation/discover.mjs
# 5. First run (in Claude Code)
/funnel-optimizeβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 1: collect-data.mjs + evaluate-experiment.mjs β
β β snapshot.json + decision (continue/winner/kill) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 2: Diagnostic analysis (Claude Code reads β
β snapshot, identifies bottlenecks, writes report) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 3: Triple-Agent compete β
β βββ Claude (PM Skills: /discover /brainstorm) β
β βββ Codex CLI (optional) β
β βββ Gemini CLI (optional) β
β β 3 proposals scored β 1 winner picked β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 4: implement-experiment.mjs β
β β apply code changes + create PostHog flag β
β β build validation + auto-rollback β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Phase 7: archive.mjs + git commit + gh pr create β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
[significance reached β apply winner;
else continue collecting]
Everything lives in funnel-config.json:
| Field | Purpose |
|---|---|
optimization_targets[] |
Your KPIs (impression event, click events, target rate, priority) |
automation.experiment_window_days |
DAU-derived window. Significance can fire earlier. |
automation.min_sample_size / significance_level |
Significance gates |
automation.min_early_decision_days |
Optional calendar floor (default 0 β no floor) |
guardrails.allowed_files |
Which files AI agents can modify |
guardrails.allowed_domains_for_redirects |
Domain whitelist for fetch/redirect |
multi_agent.agents |
Which agents to run (claude required, codex/gemini optional) |
value_metrics |
LIR / Time-to-Value / Health Rollup definitions |
See docs/customization.md for the full schema.
- Architecture β 7-Phase pipeline + Triple-Agent design
- Discovery mode β first-time setup
- Operate mode β per-cycle workflow
- Customization β funnel-config.json schema
- Learnings β patterns observed in the field
- FAQ
PRs welcome. Especially:
- Data source adapters (Mixpanel, Amplitude, GA4) β currently PostHog only
- Framework-specific examples (Next.js, Vue, Svelte)
- Better Discovery prompts
- Better security scanner patterns
See CONTRIBUTING.md.
- v0.1 (current): PostHog + Claude/Codex/Gemini Triple-Agent
- v0.2: plugin interface for data sources
- v0.3: npm package + CLI
- v0.4: GitHub Action for scheduled automation
MIT β see LICENSE.