Official agent skill

Optimizing Clickhouse And Hogql Queries

by PostHog in PostHog/posthog

Workflow for optimizing ClickHouse and HogQL queries. An agent skill from PostHog/posthog.

OfficialCustom licenceAuto-check passedDatabases

Install Optimizing Clickhouse And Hogql Queries

skills CLI
$ npx skills add PostHog/posthog --skill optimizing-clickhouse-and-hogql-queries -a claude-code

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

GitHub CLI
$ gh skill install PostHog/posthog optimizing-clickhouse-and-hogql-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/PostHog/posthog.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/optimizing-clickhouse-and-hogql-queries .claude/skills/optimizing-clickhouse-and-hogql-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
optimizing-clickhouse-and-hogql-queries
GitHub stars
40k
Token cost
~5.7k tokens
SKILL.md length
2,329 words
Files
3 (incl. references)
Skills in repo
252
Repo updated
First seen
Licence
Custom licence

At a glance

Workflow for optimizing ClickHouse and HogQL queries. An agent skill from PostHog/posthog.

  • Works in 6 steps: confirm you're at the right layer → get the ClickHouse SQL → scan for the common smells → …
  • Report is too slow
  • SKILL.md covers Optimizing every query a team…, Step 0: confirm you're at the…, Background: read these once and Step 1: get the ClickHouse SQL, plus 7 more sections
  • Needs ANTHROPIC_API_KEY

What it does

Optimizing Clickhouse And Hogql Queries is an agent skill from PostHog/posthog, published by the product's own GitHub organization. Workflow for optimizing ClickHouse and HogQL queries. Use when a HogQL query, query runner, insight, or report is too slow; when a hand-written ClickHouse query (via syncexecute or in a migration) is too slow; when ClickHouse times out or hits memory limits; when investigating a slow system.querylog row; or when reviewing a proposed HogQL printer change for performance. Covers extracting the ClickHouse SQL, common smells (FROM ... FINAL, JSONExtract over properties, missing skip indexes, self-joins, CTE blow-up)…

Its SKILL.md is about 5.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/investigation-playbook.md` and `references/learnings.md`).

It sits in Databases, covering Data warehousing and REST APIs. It works with ClickHouse, SQL, PostgreSQL and Django. The repository describes itself as: :hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error…

When your agent uses it

  • Report is too slow
  • A hand-written ClickHouse query (via syncexecute
  • In a migration) is too slow
  • ClickHouse times out

Example prompts

  • “/optimizing-clickhouse-and-hogql-queries”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. confirm you're at the right layer
  2. get the ClickHouse SQL
  3. scan for the common smells
  4. run EXPLAIN
  5. measure for real
  6. apply the optimization

What it can do on your machine

Read from SKILL.md and the folder at commit 812e5c6. 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

    No scripts in the folder and no shell commands in SKILL.md.

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

  • Network

    Links to these hosts (documentation or services it may open):

    • clickhouse.com
    • github.com

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

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • ANTHROPIC_API_KEY

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

Context cost

Optimizing Clickhouse And Hogql Queries loads about 5.7k tokens when it runs, and up to ~16k if it reads all its reference files. Until then it costs about 197 tokens; SKILL.md has 2,329 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~197
When it runs · the whole SKILL.md, loaded when a task matches
~5.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~16k

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); files beside SKILL.md are not scanned.

SKILL.md

Its licence (Custom licence) doesn't allow us to republish the file, so here is its outline and opening line. It has 2,329 words (~5,700 tokens).

“Optimizes ClickHouse and HogQL queries (HogQL compiles to ClickHouse), not Postgres / Django ORM. For an app-DB query (Model.objects.filter(...)), stop and use profiling-slow-api-endpoints; Step 0 has the full triage.”

— opening of SKILL.md by PostHog, Custom licence
name
optimizing-clickhouse-and-hogql-queries

Read the full SKILL.md on GitHub

Files

SKILL.md and 2 other files (references) in .agents/skills/optimizing-clickhouse-and-hogql-queries of PostHog/posthog.

  • SKILL.md
  • references/investigation-playbook.md
  • references/learnings.md

Open the folder on GitHubat commit 812e5c6

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders. This page covers the copy in PostHog/posthog, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Optimizing Clickhouse And Hogql 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.

Optimizing Clickhouse And Hogql Queries compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Optimizing Clickhouse And Hogql Queries this skillPostHog/posthog40k—~5.7kAutomated safety check: PassCustom licence
Querying Tempotempoxyz/tidx107—~3.1kAutomated safety check: PassMIT
Clickhouse Logs Queriessupabase/supabase111k—~2.4kAutomated safety check: PassApache-2.0
Chdb SQLvemetric/vemetric3951 repos~1.2kAutomated safety check: PassApache-2.0
Semantic Analystsidequery/sidemantic129—~982Automated safety check: PassAGPL-3.0
Database MigrationRain-kl/OpenFlare288—~1.3kAutomated safety check: PassApache-2.0

Similar skills

  • Querying Tempo

    tempoxyz/tidx

    Query indexed Tempo chain data via tidx HTTP API and CLI. An agent skill from tempoxyz/tidx.

    107 GitHub stars~3.1k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Clickhouse Logs Queries

    supabase/supabase

    Official

    Write, review, and migrate Supabase logs queries against the ClickHouse-backed logs table (the logs.all.otel analytics endpoint).

    111k GitHub stars~2.4k tokensUpdated today
    DatabasesAuto-check passed
  • Chdb SQL

    vemetric/vemetric

    A skill your agent uses when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse…

    395 GitHub starsUsed in 1 repo~1.2k tokens
    DatabasesAuto-check passed
  • Semantic Analyst

    sidequery/sidemantic

    Answer analytical, KPI, metric, trend, cohort, and business-performance questions through a Sidemantic semantic layer.

    129 GitHub stars~982 tokensUpdated 2 days ago
    DatabasesAuto-check passed
  • Database Migration

    Rain-kl/OpenFlare

    Wavelet 项目专用:当新增或修改数据库表结构、索引、初始化数据、系统配置 seed、模板 seed、默认管理员、goose SQL 迁移、internal/infra/persistence/migrator、ClickHouse 分析库 DDL 或数据库升级流程时必须使用。本技能指导在 internal/infra/persistence/migrator/goose 下编写…

    288 GitHub stars~1.3k tokensUpdated 2 days ago
    DatabasesAuto-check passed
  • Using Timeseries Databases

    ancoleman/ai-design-components

    Time-series database implementation for metrics, IoT, financial data, and observability backends.

    526 GitHub stars~1.7k tokensUpdated 10 mo ago
    DatabasesAuto-check passed

More from PostHog/posthog

All 252 skills in this repo
  • Authoring Log Alerts

    PostHog/posthog

    Official

    Author useful, low-noise log alerts on services in a PostHog project.

    40k GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Official

    Operating procedure for the conflict-autoresolver agent: sweep open PostHog/posthog PRs that conflict with master, resolve the trivial conflicts (generated artifacts deterministically, source…

    40k GitHub stars~4.2k tokensUpdated today
    Auto-check passed
  • Official

    Help users debug PostHog Error Tracking stack-trace symbolication for any supported platform — JavaScript/TypeScript web, React Native (Hermes), Android (Proguard / R8), or iOS / macOS (dSYM).

    40k GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Exploring Apm Traces

    PostHog/posthog

    Official

    Investigates distributed application performance using PostHog APM (OpenTelemetry span) data via MCP.

    40k GitHub stars~3.5k tokensUpdated today
    Auto-check passed
  • Exploring LLM Traces

    PostHog/posthog

    Official

    Debug and inspect LLM/AI agent traces using PostHog's MCP tools.

    40k GitHub stars~4.4k tokensUpdated today
    Auto-check passed
  • Investigate Metric

    PostHog/posthog

    Official

    Diagnose why a product metric changed (dropped, spiked, or plateaued) by orchestrating breakdowns, actors, paths, lifecycle, retention, and annotations queries.

    40k GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Categories

Questions about Optimizing Clickhouse And Hogql Queries

What does Optimizing Clickhouse And Hogql Queries do?

Workflow for optimizing ClickHouse and HogQL queries. An agent skill from PostHog/posthog. Optimizing Clickhouse And Hogql Queries is an agent skill from PostHog/posthog, published by the product's own GitHub organization. Workflow for optimizing ClickHouse and HogQL queries.

When should I use Optimizing Clickhouse And Hogql Queries?

Optimizing Clickhouse And Hogql Queries fits situations like: report is too slow; A hand-written ClickHouse query (via syncexecute; in a migration) is too slow; clickHouse times out.

How do I install Optimizing Clickhouse And Hogql Queries in Claude Code?

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

How do I install Optimizing Clickhouse And Hogql Queries in Codex?

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

Can I use Optimizing Clickhouse And Hogql 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 PostHog/posthog --skill optimizing-clickhouse-and-hogql-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/optimizing-clickhouse-and-hogql-queries, .gemini/skills/optimizing-clickhouse-and-hogql-queries, .github/skills/optimizing-clickhouse-and-hogql-queries and .opencode/skills/optimizing-clickhouse-and-hogql-queries in your project.

What does Optimizing Clickhouse And Hogql Queries need to run?

Going by SKILL.md and its folder, Optimizing Clickhouse And Hogql Queries needs credentials named ANTHROPIC_API_KEY. Our summary lists: Python 3.

Does Optimizing Clickhouse And Hogql Queries access the network?

SKILL.md names 2 domains. As links in the text: clickhouse.com and github.com. This is read from the text; nothing was executed.

Is Optimizing Clickhouse And Hogql 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. Review the folder before installing.

What licence does Optimizing Clickhouse And Hogql Queries use?

Optimizing Clickhouse And Hogql Queries has a licence file (the repository's licence) that doesn't match a standard licence. Read it on GitHub before reusing the skill.

How many tokens does Optimizing Clickhouse And Hogql Queries use?

About 5.7k tokens (SKILL.md is roughly 23k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 11k tokens, read only when the agent opens those files.

What are the alternatives to Optimizing Clickhouse And Hogql Queries?

Skills that share tags, products or a category with Optimizing Clickhouse And Hogql Queries: Querying Tempo (tempoxyz/tidx, 107 stars), Clickhouse Logs Queries (supabase/supabase, 111k stars), Chdb SQL (vemetric/vemetric, 395 stars) and Semantic Analyst (sidequery/sidemantic, 129 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Optimizing Clickhouse And Hogql Queries?

PostHog (a GitHub organization, an official publisher) maintains it in PostHog/posthog, which has 40,200 GitHub stars. The repository holds 252 skills in this directory. The repository was last updated on October 9, 2026.

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