AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides guidance and best practices for implementing PostHog feature flags within Python applications. It covers the necessary setup, configuration of the PostHog Python SDK, and architectural patterns for managing feature flags effectively. The skill emphasizes server-side evaluation, secure handling of environment variables, and proper lifecycle management of the PostHog client to ensure reliable performance and data integrity.
What it does
- Provides instructions for installing and configuring the PostHog Python SDK.
- Outlines patterns for implementing boolean and multivariate feature flags in Python code.
- Defines best practices for flag naming, targeting, and lifecycle management.
- Explains how to handle client lifecycle events like shutdown to ensure event flushing.
- Offers guidance on secure configuration using environment variables.
- Provides strategies for local evaluation to improve performance and reduce API latency.
When to use it
- When you need to implement feature toggles or experiments in a Python-based backend.
- When you want to perform server-side feature flag evaluation to prevent UI flickering.
- When you need to ensure consistent user experiences across different sessions and devices.
- When you are setting up a new Python project that requires controlled feature releases.
Advantages
- Enables safe, incremental feature rollouts and A/B testing.
- Reduces latency by supporting local flag evaluation.
- Promotes clean code through centralized flag management patterns.
- Ensures data privacy by distinguishing between PII and safe event properties.
Usage examples
- “How do I initialize the PostHog client in my Python application?”
- The agent provides the code to instantiate the Posthog class with your API key, including the required enable_exception_autocapture=True setting and atexit registration for shutdown.
- “What is the best way to check a feature flag in my Python logic?”
- The agent explains how to use the posthog_client.feature_enabled() method and recommends wrapping flag checks in a dedicated function if the flag is used in multiple locations.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/posthog/feature-flags-python/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip feature-flags-python.zip -d .agents/skills
Documentation by PostHog
PostHog feature flags for Python
This skill helps you add PostHog feature flags to Python applications.
Reference files
references/python.md- Python feature flags installation - docsreferences/adding-feature-flag-code.md- Adding feature flag code - docsreferences/best-practices.md- Feature flag best practices - docs
Consult the documentation for API details and framework-specific patterns.
Key principles
Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
Minimal changes: Add feature flag code alongside existing logic. Don't replace or restructure existing code.
Boolean flags first: Default to boolean flag checks unless the user specifically asks for multivariate flags.
Server-side when possible: Prefer server-side flag evaluation to avoid UI flicker.
PostHog MCP tools
Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.
Framework guidelines
Remember that source code is available in the venv/site-packages directory
posthog is the Python SDK package name
Install dependencies with
pip install posthogorpip install -r requirements.txtand do NOT use unquoted version specifiers like>=directly in shell commandsIn CLIs and scripts: MUST call posthog.shutdown() before exit or all events are lost
Always use the Posthog() class constructor (instance-based API) instead of module-level posthog.api_key config
Always include enable_exception_autocapture=True in the Posthog() constructor to automatically track exceptions
NEVER send PII in capture() event properties — no emails, full names, phone numbers, physical addresses, IP addresses, or user-generated content
PII belongs in identify() person properties, NOT in capture() event properties. Safe event properties are metadata like message_length, form_type, boolean flags.
Register posthog_client.shutdown with atexit.register() to ensure all events are flushed on exit
The Python SDK has NO identify() method — use posthog_client.set(distinct_id=user_id, properties={...}) to set person properties, or use identify_context(user_id) within a context
Files
- ATTRIBUTION.mdAdded by AutoGineer960 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md2.5 KiB
- references/adding-feature-flag-code.md108.7 KiB
- references/best-practices.md7.9 KiB
- references/python.md5.0 KiB
ATTRIBUTION.md
Attribution
This folder is an unmodified copy of the Agent Skill "feature-flags-python", distributed by AutoGineer (https://autogineer.com/agent-skills).
Commit: a5d30e775d092e16e198f7b582f1f66dac2cee45
Created by: PostHog (https://github.com/PostHog/skills/tree/a5d30e775d092e16e198f7b582f1f66dac2cee45/skills/posthog/feature-flags/skills/python)
Publisher: PostHog (https://github.com/PostHog)
Licence: MIT License (https://github.com/PostHog/skills/blob/a5d30e775d092e16e198f7b582f1f66dac2cee45/LICENSE)
Licence evidence: repository licence LICENSE
Retrieved: 2026-11-07
The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.
Files added by AutoGineer
ATTRIBUTION.md: this file, written by AutoGineer
LICENSE: copied from LICENSE
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs an API key, Needs Python
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/posthog/feature-flags/skills/python · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- PostHog/skills
AutoGineer is not affiliated with or endorsed by PostHog or PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download feature-flags-python.zip