What You'll Build
A fully automated workflow that uses Continue CLI with the PostHog MCP to fetch analytics data, analyze user experience issues with AI, and automatically create GitHub
issues with the GitHub CLI.
What You’ll Learn
This cookbook teaches you to:- Use PostHog MCP to query analytics, errors, and feature flags
- Analyze user behavior patterns with AI
- Automatically create GitHub issues using GitHub CLI
- Set up continuous monitoring with GitHub Actions
Prerequisites
Before starting, ensure you have:- GitHub repository where you want to create issues
- PostHog account with session recordings enabled and data collecting
- Node.js 18+ installed locally
- Continue CLI with active credits (required for API usage)
- GitHub CLI installed (
gh
command)
1
Install Continue CLI
2
Set up Continue CLI Account & API Key
- Visit Continue Organizations
- Sign up or log in to your Continue account
- Navigate to your organization settings
- Click “API Keys” and then ”+ New API Key”
- Copy the API key immediately (you won’t see it again!)
- Login to the CLI:
cn login
3
Add Required Secrets to Continue CLI
Continue CLI will securely store your API keys as secrets that can be referenced in prompts.
Continue CLI handles the complex API interactions - you just need to provide
the right prompts!
Step 1: Set Up Your Credentials
First, you’ll need to gather your PostHog and GitHub API credentials and add them as secrets in Continue CLI.- PostHog API Credentials
- Set Up GitHub CLI Authentication
- Configure API Access in Continue CLI
You’ll need a Personal API Key (not a Project API key) to access session recordings:
- Go to Personal API Keys in PostHog
- Click + Create a personal API Key
- Name it “Continue CLI Session Analysis”
- Select these scopes:
session_recording:read
- Required for accessing session datafeature_flag:read
- Required for feature flag auditinginsight:read
query:read
session_recording_playlist:read
- Copy the key immediately (you won’t see it again!)
- Note your Project ID from your PostHog project settings
- Note your PostHog host URL (e.g.,
https://us.posthog.com
or your custom domain) - You’ll also need your POSTHOG_AUTH_HEADER value, which is simply
Bearer YOUR_API_KEY
Continue Secrets: The
POSTHOG_AUTH_HEADER
secret should be stored in
Continue’s secure secrets storage. This keeps your API key safe and the MCP
automatically connects to your default PostHog project.PostHog GitHub Continuous AI Workflow Options
🚀 Fastest Path to Success
Skip the manual setup and use our pre-built PostHog GitHub agent that includes
optimized prompts, rules, and the PostHog MCP for more consistent results.
How PostHog MCP Works:
- Your API key is tied to your PostHog account and organization
- It automatically uses your default project (no project ID needed)
- If you have multiple projects, use
mcp__posthog__switch-project
to change - The MCP connects via
https://mcp.posthog.com/sse
using your account context.
- ⚡ Quick Start (Recommended)
- 🛠️ Manual Setup
Perfect for: Immediate results with optimized prompts and built-in debugging
1
Add the Pre-Built Agent
Visit the PostHog GitHub Continuous AI Agent on Continue Hub and click “Install Agent” or run:This agent includes:
- Optimized prompts for PostHog analysis and GitHub issue creation
- Built-in rules for consistent formatting and error handling
- PostHog MCP for more reliable API interactions
2
Run the Analysis
Navigate to your project directory and run:That’s it! The agent handles everything automatically.
Why Use the Agent? Results are more consistent and debugging is easier thanks to the PostHog MCP integration and pre-tested prompts.
Why GitHub CLI over GitHub MCP: While GitHub MCP is available, it can be
token-expensive to run. The
gh
CLI is more efficient, requires no API tokens
(authenticated via gh auth login
), and provides a cleaner command-line
experience. GitHub MCP remains an option if you prefer full MCP integration.Agent Requirements
Agent Requirements
To use the pre-built agent, you need either:
- Continue CLI Pro Plan with the models add-on, OR
- Your own API keys added to Continue Hub secrets (same as Step 1 below) The agent will automatically detect and use your configuration.
Repository Labels Required: Make sure your GitHub repository has these labels:
bug
,enhancement
,technical-debt
high-priority
,medium-priority
,low-priority
user-experience
,automated
,feature-flag
,cleanup
What Continue CLI Does:
- Parses your analysis results automatically
- Makes authenticated GitHub API calls using your stored token
- Creates properly formatted issues with appropriate labels
- Checks for duplicate issues to avoid spam
- Provides confirmation with issue URLs
What You’ve Built
After completing this guide, you have a complete Continuous AI system that:- Monitors user experience - Automatically fetches and analyzes PostHog session data
- Identifies problems intelligently - Uses AI to spot patterns and technical issues
- Creates actionable tasks - Generates GitHub issues with specific recommendations
- Runs autonomously - Operates daily without manual intervention using GitHub Actions
- Scales with your team - Handles growing amounts of session data automatically
Continuous AI
Your system now operates at Level 2 Continuous
AI -
AI handles routine analysis tasks with human oversight through GitHub issue
review and prioritization.
Security Best Practices
Protect Your API Keys:
- Store all credentials as GitHub Secrets, never in code
- Use Continue CLI’s secure secret storage
- Limit token scopes to minimum required permissions
- Rotate API keys regularly (every 90 days recommended)
- Monitor token usage for unusual activity
Example Use Cases
Here are practical examples of what you can build with PostHog MCP and Continue CLI:Session Recording Analysis (Current Implementation)
The main workflow above focuses on analyzing session recordings to identify UX issues and create GitHub issues automatically.Feature Flag Audit and Cleanup
🏁 Feature Flag Management
Automatically audit your feature flags to identify unused, outdated, or problematic flags that need attention.
- Fetches all feature flags from your PostHog project
- Analyzes flag usage, rollout status, and configuration
- Identifies flags that may be candidates for removal or updates
- Creates GitHub issues for flag cleanup tasks
feature-flag-get-all
- Retrieve all feature flagsfeature-flag-get-definition
- Get detailed flag configurationquery-run
- Run analytics queries to check flag usageinsights-get-all
- Get insights related to flag performance
- ”🏁 Feature Flag Cleanup: dark-mode-toggle” (100% rollout, safe to remove)
- ”🏁 Feature Flag Review: experimental-checkout” (unused for 120 days)
- ”🏁 Feature Flag Simplify: complex-user-targeting” (overly complex rules)
Advanced Prompts
Consider enhancing your workflow with these advanced Continue CLI prompts:Performance Analysis
“Analyze PostHog performance
metrics alongside session
recordings to identify slow page loads affecting user experience”
Error Correlation
“Cross-reference JavaScript console errors with user actions to identify the
root cause of UX issues”
Feature Flag Performance Impact
“Use PostHog MCP to correlate feature flag rollouts with performance metrics and user behavior changes to identify flags causing issues”
Custom Slack Alerts
“Create Slack alerts when critical UX issues are detected in PostHog
sessions or when feature flags need attention”
Next Steps
- Consider GitHub MCP as an alternative (note: can be token-expensive)
- Configure Slack MCP for alerts
- Set up PostHog performance monitoring
- Join the Continue Discord for support