Skip to main content

piglet

A CLI for managing PostHog resources - feature flags, cohorts, dashboards, insights, and projects.

Note: This is not an official PostHog project. It is maintained by Cased.

Installation

uv tool install cased-piglet

Or with pip:

pip install cased-piglet

Configuration

Configuration can be provided via CLI options, environment variables, or config file (in that order of precedence).

Environment Variables

export POSTHOG_API_KEY="phx_your_key"
export POSTHOG_PROJECT_ID="12345"
export POSTHOG_HOST="us"  # optional, defaults to us

Config File

Create ~/.piglet/config.toml:

api_key = "phx_your_key"
project_id = 12345
host = "us"

Host Shortcuts

  • us → https://us.posthog.com (default)
  • eu → https://eu.posthog.com
  • Or use a full URL for self-hosted: https://posthog.mycompany.com

Global Options

--api-key TEXT        PostHog personal API key
--host TEXT           PostHog host (us, eu, or full URL)
--project-id INTEGER  PostHog project ID
--json                Output as JSON
--plain               Output as plain tab-separated text

Commands

Feature Flags

piglet flags list                # List all flags
piglet flags list --active       # List only active flags
piglet flags list --inactive     # List only inactive flags
piglet flags get <id-or-key>     # Get flag by ID or key
piglet flags create --key my-flag --name "My Flag" --rollout-percentage 50
piglet flags update 123 --rollout-percentage 100
piglet flags update 123 --active
piglet flags update 123 --inactive
piglet flags delete 123          # Prompts for confirmation
piglet flags delete 123 --yes    # Skip confirmation

Cohorts

piglet cohorts list              # List all cohorts
piglet cohorts list --static     # List only static cohorts
piglet cohorts list --dynamic    # List only dynamic cohorts
piglet cohorts get 123           # Get cohort details
piglet cohorts create --name "My Cohort"
piglet cohorts create --name "Static Cohort" --static
piglet cohorts update 123 --name "New Name"
piglet cohorts delete 123

Dashboards

piglet dashboards list           # List all dashboards
piglet dashboards list --pinned  # List only pinned dashboards
piglet dashboards get 123        # Get dashboard details
piglet dashboards create --name "My Dashboard"
piglet dashboards update 123 --name "New Name" --pinned
piglet dashboards delete 123

Insights

piglet insights list             # List all insights
piglet insights list --saved     # List only saved insights
piglet insights list --favorited # List only favorited insights
piglet insights get <id-or-short-id>
piglet insights create --name "My Insight"
piglet insights update 123 --name "New Name"
piglet insights delete 123

Projects

piglet projects list             # List all projects
piglet projects get 123          # Get project details

Output Formats

# Rich table (default)
piglet flags list

# JSON output
piglet --json flags list

# Plain tab-separated (good for scripting)
piglet --plain flags list
piglet --plain flags list | cut -f2  # Extract just the keys

Examples

# Use EU cloud
piglet --host eu flags list

# Self-hosted instance
piglet --host https://posthog.mycompany.com flags list

# Override project ID
piglet --project-id 99999 flags list

# Create and immediately enable a flag at 100%
piglet flags create --key new-feature --rollout-percentage 100 --active

# Disable a flag
piglet flags update 123 --inactive

# Export all flags as JSON
piglet --json flags list > flags.json

Claude Code Plugin

A Claude Code plugin is available for natural language interaction with piglet:

/plugin marketplace add cased/claude-code-plugins
/plugin install piglet

Once installed, you can ask Claude things like:

  • "What feature flags do we have?"
  • "Create a flag called dark-mode with 50% rollout"
  • "Disable the beta-feature flag"
  • "List all cohorts"

License

MIT


Piglet

Metadata

Release files for cased-piglet 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cased-piglet 0.1.0
File Size Uploaded Provenance
cased_piglet-0.1.0.tar.gz 944.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cased-piglet 0.1.0
File Interpreter ABI Platform
cased_piglet-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 961.8 kB

Release files / cased_piglet-0.1.0.tar.gz

Download URL cased_piglet-0.1.0.tar.gz
Size 944.1 kB
Tags Source
SHA-256 checksum
How to use checksums
01a4f57ff061d88939c10a391541a76d9eb7275dab941cf4a4a10d5a06a39c11
BLAKE2b-256 checksum
How to use checksums
c47a7efa9fa8aae2d0ab6e3d5642c2f10b2e6c5dfb115bb7be79b19d4853c04d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / cased_piglet-0.1.0-py3-none-any.whl

Download URL cased_piglet-0.1.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3fe409be3fb697b66c1c91ef2974875b949ab8f988d680dc4e1ef6f6102c66f
BLAKE2b-256 checksum
How to use checksums
420943725666e2f95a6df80b0e93564f54f409165a717f74f51fc2c9a098f3e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Security for cased-piglet 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page