Agent skill

PostHog CLI Queries

by debugtheworldbot in debugtheworldbot/keyStats

Runs HogQL queries against this project's PostHog data from the terminal using posthog-cli, with bundled scripts for dashboard metadata the CLI itself has no command for.

MITAuto-check passedData & Analytics

Install PostHog CLI Queries

skills CLI
$ npx skills add debugtheworldbot/keyStats --skill posthog-cli-queries -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install debugtheworldbot/keyStats posthog-cli-queries --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/debugtheworldbot/keyStats.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/posthog-cli-queries .claude/skills/posthog-cli-queries && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
posthog-cli-queries
GitHub stars
1.5k
Token cost
~1.2k tokens
SKILL.md length
375 words
Files
3 (incl. scripts)
Skills in repo
2
Repo updated
First seen
Licence
MIT

At a glance

Runs HogQL queries against this project's PostHog data from the terminal using posthog-cli, with bundled scripts for dashboard metadata the CLI itself has no command for.

  • Works in 4 steps: Verify auth → For event data, use posthog-cli exp… → For dashboard metadata or cached… → …
  • Querying recent PostHog events from the terminal instead of the web UI
  • SKILL.md covers When To Use, Preconditions, Default Workflow and Common Queries, plus 4 more sections
  • Runs Shell scripts from its folder; calls bash and jq; reaches us.posthog.com

What it does

Before querying, the skill verifies authentication with a trivial query and notes that dashboard API helpers read credentials from a local JSON file rather than any hardcoded project id, even though it names the project's current PostHog environment and region for reference. Event-level queries run directly through posthog-cli's experimental query command with a HogQL string, while dashboard metadata or cached insight results go through two bundled shell scripts because the CLI has no dedicated dashboard command.

A shell-quoting rule calls for wrapping HogQL in single quotes whenever it references a property like $app_version or $os, since double quotes let the shell expand the dollar sign before the CLI sees it. A set of ready-made HogQL queries covers recent events, top events and pageview pages over the last 7 days, click targets, app versions and an OS breakdown, and the skill expects every answer to report the exact command used, the key rows or aggregates, and any caveats such as partial-day data or test-account filtering.

When your agent uses it

  • Querying recent PostHog events from the terminal instead of the web UI
  • Getting a breakdown of top pages, click targets or app versions
  • Fetching PostHog dashboard metadata or cached insight results via script

Example prompts

  • “Show me the top 15 events from the last 7 days in PostHog.”
  • “What are the most-clicked elements on the site this week?”
  • “Pull the cached results for our main PostHog dashboard.”

Requirements

  • posthog-cli, installed and authenticated
  • A personal API key with query:read

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Verify auth
  2. For event data, use posthog-cli exp query run ''
  3. For dashboard metadata or cached dashboard insight results, use the scripts in this skill because the CLI has no dedicated dashboard command
  4. Return

What it can do on your machine

Read from SKILL.md and the folder at commit 0bb183d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • bash
    • jq

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • us.posthog.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

PostHog CLI Queries loads about 1.2k tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 375 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from debugtheworldbot/keyStats at commit 0bb183d, republished under its MIT licence (© debugtheworldbot). 375 words, ~1,193 tokens.

Download SKILL.mdSave it as .claude/skills/posthog-cli-queries/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
posthog-cli-queries
description
Use when querying this project's PostHog data from the terminal, including recent events, event breakdowns, active-user metrics, and dashboard metadata or cached insight results.

PostHog CLI Queries

Query this project's PostHog data from the terminal without guessing command syntax.

When To Use

  • The user asks to inspect PostHog events, trends, or dashboard data
  • The task needs real data from this project's PostHog environment
  • The user wants a repeatable terminal command instead of clicking in the PostHog UI

Preconditions

  • posthog-cli must be installed and authenticated
  • Query commands need a personal API key with query:read
  • Dashboard API helpers read ~/.posthog/credentials.json
  • This project currently uses PostHog environment 292804 on https://us.posthog.com, but scripts read the active local credentials instead of hardcoding values

Default Workflow

  1. Verify auth:
bash
posthog-cli exp query run 'SELECT 1 AS ok'
  1. For event data, use posthog-cli exp query run '<hogql>'
  2. For dashboard metadata or cached dashboard insight results, use the scripts in this skill because the CLI has no dedicated dashboard command
  3. Return:
    • the exact command used
    • the key rows or aggregates
    • any metric caveats such as partial-day data, test-account filtering, or missing properties

Shell quoting rule:

  • Use single quotes around HogQL when the query contains properties like $app_version or $os, otherwise the shell may expand them before the CLI sees the query

Common Queries

Recent events:

bash
posthog-cli exp query run 'SELECT event, timestamp FROM events ORDER BY timestamp DESC LIMIT 20'

Top events in the last 7 days:

bash
posthog-cli exp query run 'SELECT event, count() AS c FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY c DESC LIMIT 15'

Top pageview pages in the last 7 days:

bash
posthog-cli exp query run "SELECT properties.page_name AS page_name, count() AS c FROM events WHERE event = 'pageview' AND timestamp > now() - INTERVAL 7 DAY GROUP BY page_name ORDER BY c DESC LIMIT 15"

Top click targets in the last 7 days:

bash
posthog-cli exp query run "SELECT properties.element_name AS element_name, count() AS c FROM events WHERE event = 'click' AND timestamp > now() - INTERVAL 7 DAY GROUP BY element_name ORDER BY c DESC LIMIT 15"

Recent app versions from events:

bash
posthog-cli exp query run 'SELECT properties.$app_version AS app_version, count() AS c FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY app_version ORDER BY c DESC LIMIT 20'

Recent OS breakdown:

bash
posthog-cli exp query run 'SELECT properties.$os AS os, count(DISTINCT person_id) AS users FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY os ORDER BY users DESC LIMIT 20'

Hourly volume in the last 24 hours:

bash
posthog-cli exp query run 'SELECT toStartOfHour(timestamp) AS hour, count() AS c FROM events WHERE timestamp > now() - INTERVAL 24 HOUR GROUP BY hour ORDER BY hour DESC LIMIT 24'
Show full SKILL.md (149 more words)Show less

Dashboard Commands

List dashboards:

bash
bash .agents/skills/posthog-cli-queries/scripts/dashboard_list.sh

Fetch a dashboard as JSON:

bash
bash .agents/skills/posthog-cli-queries/scripts/dashboard_fetch.sh 1075953

Fetch a dashboard summary:

bash
bash .agents/skills/posthog-cli-queries/scripts/dashboard_fetch.sh 1075953 --summary

Current known dashboard:

bash
bash .agents/skills/posthog-cli-queries/scripts/dashboard_fetch.sh 1075953 --summary

Dashboard Analysis Notes

  • Dashboard results are usually cached insight payloads, so last_refresh matters
  • Do not compare a partial current day against a full previous day without saying so explicitly
  • Check filterTestAccounts before comparing tiles with each other
  • If $os or $app_version has a large null bucket, call out that the property coverage is incomplete
  • If event names overlap like app_open and Application Opened, mention that the taxonomy is split

Useful jq Snippets

Extract tile names from a fetched dashboard JSON:

bash
jq -r '.tiles[] | select(.insight != null) | [.id, .insight.id, .insight.name] | @tsv'

Show top breakdown rows from one insight result:

bash
jq -r '.tiles[] | select(.insight.id==6334935) | .insight.result[] | [.label, .count, (.data[-1] // 0)] | @tsv'

Failure Handling

  • If posthog-cli exp query run says missing required scope 'query:read', fix the personal API key scopes first
  • If a query times out, narrow the date range or aggregate more aggressively
  • If dashboard scripts fail, confirm ~/.posthog/credentials.json exists and contains host, token, and env_id

© debugtheworldbot, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (scripts) in .agents/skills/posthog-cli-queries of debugtheworldbot/keyStats.

  • SKILL.md
  • scripts/dashboard_fetch.sh
  • scripts/dashboard_list.sh

Open the folder on GitHubat commit 0bb183d

Compare with similar skills

PostHog CLI Queries next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

PostHog CLI Queries compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
PostHog CLI Queries this skilldebugtheworldbot/keyStats1.5k—~1.2kAutomated safety check: PassMIT
Retentioneering Contributingretentioneering/retentioneering-tools920—~1.8kAutomated safety check: PassApache-2.0
Retentioneering Product Analyticsretentioneering/retentioneering-tools920—~1.6kAutomated safety check: PassApache-2.0
Retention Analysisliangdabiao/claude-data-analysis-ultra-main2901 repos~1.3kAutomated safety check: NotesNone
Feature Analytics Instrumentation Plannermistralai/mistral-vibe5.1k—~2.2kAutomated safety check: PassApache-2.0
Funnel Analysisliangdabiao/claude-data-analysis-ultra-main2902 repos~781Automated safety check: NotesNone

Similar skills

  • Retentioneering Contributing

    retentioneering/retentioneering-tools

    Help the user turn their Retentioneering ideas, friction reports, bug findings, or feature needs into high-quality upstream contributions: from capturing and validating the idea, through minimal…

    920 GitHub stars~1.8k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Retentioneering Product Analytics

    retentioneering/retentioneering-tools

    Analyze event logs, clickstreams, user paths, product funnels, retention, behavioral segments, transition graphs, step matrices, sequence patterns, and customer journeys using Retentioneering.

    920 GitHub stars~1.6k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Retention Analysis

    liangdabiao/claude-data-analysis-ultra-main

    Analyze user retention and churn using survival analysis, cohort analysis, and machine learning.

    290 GitHub starsUsed in 1 repo~1.3k tokens
    Data & AnalyticsAuto-check: notes
  • Official

    Plans which analytics events and properties a new feature needs, checks them against the existing event registry, and verifies them per environment.

    5.1k GitHub stars~2.2k tokensUpdated yesterday
    Data & AnalyticsAuto-check passed
  • Funnel Analysis

    liangdabiao/claude-data-analysis-ultra-main

    Analyze user conversion funnels, calculate step-by-step conversion rates, create interactive visualizations, and identify optimization opportunities.

    290 GitHub starsUsed in 2 repos~781 tokens
    Data & AnalyticsAuto-check: notes
  • Event Tracking

    linuxfoundation/insights

    Add event tracking calls to Vue/Nuxt components in the Insights app using the useTrackEvent composable.

    280 GitHub stars~1.9k tokensUpdated 6 days ago
    Data & AnalyticsAuto-check passed

More from debugtheworldbot/keyStats

  • Git Tag Changelog

    debugtheworldbot/keyStats

    Writes a short changelog or release notes by comparing two git tags, defaulting to the latest two version-like tags, from the real commits and changed files.

    1.5k GitHub stars~421 tokensUpdated 4 days ago
    Auto-check passed

Questions about PostHog CLI Queries

What does PostHog CLI Queries do?

Runs HogQL queries against this project's PostHog data from the terminal using posthog-cli, with bundled scripts for dashboard metadata the CLI itself has no command for. Before querying, the skill verifies authentication with a trivial query and notes that dashboard API helpers read credentials from a local JSON file rather than any hardcoded project id, even though it names the project's current PostHog environment and region for reference. Event-level queries run directly through posthog-cli's experimental query command with a HogQL string, while dashboard metadata or cached insight results go through two bundled shell scripts because the CLI has no dedicated dashboard command.

When should I use PostHog CLI Queries?

PostHog CLI Queries fits situations like: querying recent PostHog events from the terminal instead of the web UI; getting a breakdown of top pages, click targets or app versions; fetching PostHog dashboard metadata or cached insight results via script.

How do I install PostHog CLI Queries in Claude Code?

Run `npx skills add debugtheworldbot/keyStats --skill posthog-cli-queries -a claude-code`. Or copy the skill folder (.agents/skills/posthog-cli-queries in debugtheworldbot/keyStats) into .claude/skills/posthog-cli-queries in your project. Claude Code loads it when a task matches its description.

How do I install PostHog CLI Queries in Codex?

Run `npx skills add debugtheworldbot/keyStats --skill posthog-cli-queries -a codex`. Or copy the skill folder (.agents/skills/posthog-cli-queries in debugtheworldbot/keyStats) into .agents/skills/posthog-cli-queries in your project. Codex loads it when a task matches its description.

Can I use PostHog CLI Queries in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add debugtheworldbot/keyStats --skill posthog-cli-queries -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/posthog-cli-queries, .gemini/skills/posthog-cli-queries, .github/skills/posthog-cli-queries and .opencode/skills/posthog-cli-queries in your project.

What does PostHog CLI Queries need to run?

Going by SKILL.md and its folder, PostHog CLI Queries needs a shell for the scripts in its folder and the command-line tools its instructions call (bash and jq). Our summary lists: posthog-cli, installed and authenticated; A personal API key with query:read.

Does PostHog CLI Queries access the network?

SKILL.md names 1 domain. In commands or code: us.posthog.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is PostHog CLI Queries safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does PostHog CLI Queries use?

PostHog CLI Queries is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does PostHog CLI Queries use?

About 1.2k tokens (SKILL.md is roughly 4.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to PostHog CLI Queries?

Skills that share tags, products or a category with PostHog CLI Queries: Retentioneering Contributing (retentioneering/retentioneering-tools, 920 stars), Retentioneering Product Analytics (retentioneering/retentioneering-tools, 920 stars), Retention Analysis (liangdabiao/claude-data-analysis-ultra-main, 290 stars) and Feature Analytics Instrumentation Planner (mistralai/mistral-vibe, 5.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains PostHog CLI Queries?

debugtheworldbot (a GitHub user) maintains it in debugtheworldbot/keyStats, which has 1,465 GitHub stars. The repository holds 2 skills in this directory. The repository was last updated on October 3, 2026.

Source: debugtheworldbot/keyStats on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.