posthog-query

Run SQL queries against PostHog product analytics data using the PostHog CLI. Use when checking pageviews, event counts, trends, or any analytics data from PostHog.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "posthog-query" with this command: npx skills add quinlanjager/posthog-query

PostHog Query Skill

Run HogQL (ClickHouse-compatible SQL) queries against PostHog via the CLI.

One-Time Setup

posthog-cli login  # authenticate interactively; stores token in ~/.posthog/credentials.json

Requires API key scope: query:read.

Command

posthog-cli exp query run "<SQL>"

Results are printed as JSON lines to stdout. The CLI reads auth from ~/.posthog/credentials.json (set up via posthog-cli login).

Property Access Syntax

Use bracket notation for event properties — dot notation with quoted keys does not work:

-- ✅ Correct
properties['$current_url']
properties['$browser']

-- ❌ Wrong
properties.'$current_url'

Examples

Count all pageviews:

posthog-cli exp query run "SELECT count() as pageviews FROM events WHERE event = '\$pageview'"

Filter by URL:

posthog-cli exp query run "SELECT count() as pageviews FROM events WHERE event = '\$pageview' AND properties['\$current_url'] LIKE 'https://example.com/%'"

7-day daily trend:

posthog-cli exp query run "SELECT toDate(timestamp) as date, count() as pageviews FROM events WHERE event = '\$pageview' AND timestamp >= now() - INTERVAL 7 DAY GROUP BY date ORDER BY date"

Recent events:

posthog-cli exp query run "SELECT event, timestamp FROM events ORDER BY timestamp DESC LIMIT 10"

Other Subcommands

  • posthog-cli exp query editor — interactive query editor
  • posthog-cli exp query check "<SQL>" — syntax/type check without running
  • Append --debug to run to get the full JSON response (columns, types, cache info)

Notes

  • HogQL is ClickHouse-compatible SQL — standard ClickHouse functions apply
  • Shell-escape $ in event names: '\$pageview' or use double quotes carefully
  • The --debug flag returns full metadata including column types and cache status

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Google Docs Formatter

Instruction-only workflow for formatting, editing, and creating Google Docs using the existing gog skill/CLI. Use when a user asks to format a Google Doc, co...

Registry SourceRecently Updated
Coding

vibe-coding-skills-installer

Install vibe coding skill sets (openspec, gstack, superpowers) for any supported agent platform (Cursor, Claude Code, Codex, etc.). Interactively asks about...

Registry SourceRecently Updated
Coding

基于课程内容说明生成图文并茂的的PPT

高校教师课程PPT生成技能。当老师需要制作教学内容课件、备课PPT、教学演示文稿、实验指导手册时触发。支持数据科学、大数据技术、Python编程、深度学习、机器学习、数据可视化等多个学科领域。触发词:课程PPT、制作课件、备课PPT、教学演示、实验指导。

Registry SourceRecently Updated
Coding

HSCIQ MCP - Customs Query

HS Code Lookup for Chinese Products. Query customs codes, tariff rates, declaration elements, and regulatory requirements via HSCIQ MCP API. Create classific...

Registry SourceRecently Updated
5320toucao