Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

PostHog CLI

$ posthog-cli Official Low Risk
PostHog · Workspace & SaaS · MIT · macos / linux / windows

PostHog CLI (posthog-cli) is PostHog's fast Rust CLI built primarily for CI/CD source map injection/uploading (sourcemap inject, sourcemap upload) for PostHog Error Tracking alongside authenticated project tasks. It distributes cleanly via @posthog/cli, Homebrew, or Cargo.

FCRS-1.0 Score
81 /100
Good
Medium Confidence
Zero-Friction Install
brew install posthog/tap/posthog-cli
CLI vs MCP Decision Hybrid (CLI + MCP)

Use posthog-cli in build/CI steps to inject and upload source maps (sourcemap inject/upload); use PostHog MCP for querying HogQL analytics, insights, and feature flags.

Agent-Readiness Checklist

— JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 19 / 25

Fast Rust CLI designed for non-interactive CI/CD pipelines via POSTHOG_CLI_TOKEN, though focused on build/sourcemap workflows rather than JSON analytics querying.

  • Non-interactive env-var auth (POSTHOG_CLI_TOKEN, POSTHOG_CLI_ENV_ID)
  • Narrower command surface than PostHog's REST API
Trust & Safety 21 / 25

Scoped personal API tokens and local-first sourcemap inject keep destructive blast radius very low.

  • sourcemap inject only modifies local build output before optional upload
  • Scoped POSTHOG_CLI_TOKEN limits permissions
Setup & Portability 14 / 15

Prebuilt Rust binary available via @posthog/cli on npm, Homebrew tap, Cargo, and install script.

  • npm install -g @posthog/cli, brew install posthog/tap/posthog-cli, cargo install posthog-cli
Utility & Efficiency 11 / 15

Solves PostHog Error Tracking source map symbolication cleanly, though analytics queries belong in HogQL/API/MCP.

  • Purpose-built for sourcemap inject and upload
Maintenance & Lineage 9 / 10

Official PostHog tool developed inside PostHog/posthog under MIT.

  • Official PostHog GitHub monorepo
Docs & Verifiability 7 / 10

Documented under PostHog Error Tracking source-map upload guides.

  • Official docs at posthog.com/docs/cli

Security, Auth & Guardrails

Auth Modes
Env API Key OAuth Browser Config File
Credential Storage

Stores CLI session credentials via posthog-cli login in user config directories or reads POSTHOG_CLI_TOKEN / POSTHOG_CLI_ENV_ID from environment variables.

Side Effects
Read-Only Local Write Remote Write
Cost & Quotas

CLI is free (MIT); PostHog provides a generous free monthly tier across analytics and error tracking.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# PostHog CLI Agent Rules
- Run `posthog-cli sourcemap inject` on `./dist` before `upload`, and verify `--project` / `POSTHOG_CLI_ENV_ID` targets staging vs production.
- Keep `POSTHOG_CLI_TOKEN` scoped with Error Tracking write permissions only.
- Do not upload unredacted build artifacts containing embedded secrets.

Agent-Ready Command Recipes

Safe Read-Only Queries

Inspect PostHog CLI commands and version
posthog-cli --version

Prints the installed posthog-cli binary version without making network calls.

Verify source map CLI subcommands
posthog-cli sourcemap --help

Lists available source map injection and upload flags locally.

Controlled Writes & Previews

Inject chunk IDs into local build artifacts
posthog-cli sourcemap inject --directory ./dist

Annotates local JS bundles and source maps in ./dist with chunk IDs without uploading to PostHog.

Strengths for Agents

  • + Fast Rust binary with wide distribution (@posthog/cli, Homebrew, Cargo).
  • + Separates local sourcemap inject from remote sourcemap upload cleanly.
  • + Headless CI auth via POSTHOG_CLI_TOKEN and POSTHOG_CLI_ENV_ID.

Caveats & Pitfalls

  • ! Command surface is still relatively narrow (centered on source maps and auth) compared to PostHog's full API.
  • ! Analytics queries and feature-flag evaluations are better handled via PostHog MCP or API.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI