Pular para o conteúdo
Skillpedia
APIs e servidores (backend)41 mil · #6984

clickhouse-autoresearch-campaign

O que ela faz

Esta skill guia um agente em um esforço estruturado para acelerar uma consulta de banco de dados no ClickHouse. É para engenheiros que querem testar muitas mudanças de consulta com segurança, com os resultados registrados ao longo do caminho.

Quando usar

  • ✓Quando você quer deixar uma consulta do ClickHouse mais rápida por meio de tentativas repetidas e medidas.
  • ✓Quando você quer que cada experimento de consulta fique em sua própria branch do git.
  • ✓Quando você quer um registro dos tempos de referência e das verificações de corretude das mudanças de consulta.

Link da skill

https://github.com/PostHog/posthog/blob/master/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/PostHog/posthog/blob/master/tools/query-performance-ai/query_performance_ai/sandboxed_autoresearch_agent/pi_plugin/skills/clickhouse-autoresearch-campaign/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Nossa consulta do dashboard no ClickHouse está lenta demais. Você pode executar uma campanha para otimizá-la em uma branch própria e manter um registro de cada tentativa?”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente configura uma branch e um workspace dedicados, mede uma linha de base inicial e testa ideias diferentes uma de cada vez. Verifica se os resultados continuam corretos e revisa as tentativas que deixam de melhorar.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do GitHub.

ClickHouse Autoresearch Campaign

This skill packages the orchestration for optimizing one ClickHouse query on one git branch.

Required reads

Before taking action, read orchestration.md (sibling of this file) completely. Treat it as the operating contract.

Preconditions

This skill assumes:

  • pi-autoresearch is installed and its tools are available
  • the current directory is a git repository
  • you have a target query or enough context to identify one
  • the operator will provide or help configure .clickhouse-autoresearch/adapter.json

Branch rule

One campaign = one git branch.

If the current branch is not a dedicated campaign branch yet, create one before initializing the workspace.

Workspace rule

Use a single workspace at:

.clickhouse-autoresearch/

The branch is the campaign boundary. The workspace is just the artifact layout.

If autoresearch.config.json exists in the current working directory, read its workingDir field and use that path as the workspace instead of the default above. Automated orchestrators (for example PostHog's run_campaign.py) initialize the workspace at /tmp/autoresearch-campaign/ and write the config alongside it.

Pre-initialized workspace detection

Before doing anything in the Setup sequence, check whether the workspace has already been prepared by an external orchestrator. If the resolved workspace contains all of:

  • adapter.json
  • baseline/metrics.json
  • query/original.sql

…then the workspace is pre-initialized. In that case:

  • Skip the entire Setup sequence (steps 1–6). Do not ask the operator for a target query, connection details, or anything else — the orchestrator has already supplied them.
  • Jump directly to step 7 of the Setup sequence (read the baseline and seed the first lanes and hypotheses), then continue with steps 8–9 and the normal campaign loop.
  • Operate headlessly: at no point prompt the operator for input. If a decision requires judgment, apply the skill's default guidance and record the choice in state.json / autoresearch.md.

Only fall back to the interactive Setup sequence below when the workspace is empty or partially initialized.

Adapter capabilities (what you can and cannot run)

Campaign queries flow through the adapter configured in adapter.json. Every campaign script (ch_capture_baseline.py, ch_run_candidate.py, any ad-hoc probe) ultimately submits SQL through this adapter, and the adapter enforces what ClickHouse sees.

When adapter.json has type: "coordinator", your SQL is routed to whichever ClickHouse the host-side coordinator is pointed at — typically a read-only test cluster or a local dev ClickHouse. Either way the cluster runs SQL under a profile that pins readonly = 2, so writes (INSERT, ALTER, CREATE, OPTIMIZE, SYSTEM, TRUNCATE, DROP, ATTACH, DETACH) will fail with a ClickHouse error. Read GET /v1/info (or check autoresearch.md — the coordinator's prompt addendum is prepended there) before issuing any predicate that depends on a specific team_id: the prompt addendum tells you which team_id the target cluster has data for, and you must rewrite team_id predicates to match it. For experiments treat every read-only statement form as available:

  • SELECT … — arbitrary subqueries, CTEs, joins
  • WITH … SELECT …
  • EXPLAIN … — every variant ClickHouse supports. Use them before proposing rewrites:
    • EXPLAIN SELECT … (default: PLAN)
    • EXPLAIN AST SELECT …
    • EXPLAIN SYNTAX SELECT …
    • EXPLAIN QUERY TREE SELECT … (post-analyzer logical tree; invaluable on modern ClickHouse)
    • EXPLAIN PIPELINE SELECT … — processor-level pipeline, headers, expressions
    • EXPLAIN ESTIMATE SELECT … — per-part row/mark estimates before execution
    • EXPLAIN PLAN indexes = 1, actions = 1, json = 1 SELECT … — primary-key and skip-index use, JSON for machine parsing
    • EXPLAIN TABLE OVERRIDE …
  • SHOW … — SHOW CREATE TABLE events, SHOW COLUMNS FROM events, SHOW INDEX FROM events, SHOW SETTINGS ILIKE '%mark_cache%', etc.
  • DESCRIBE / DESC …

Timeout: every submission is wrapped with SETTINGS max_execution_time = 60. Keep ad-hoc probes short. If the target query itself routinely exceeds 60s, use range narrowing (see Setup step 6) and only then start the campaign.

Cluster scoping: depends on the coordinator's target. The prompt addendum prepended to autoresearch.md tells you which team_id the target cluster has data for and ask

Perguntas frequentes

Precisa de uma branch do git própria?

Sim. Cada campanha trabalha em uma branch do git dedicada, que é o limite do trabalho.

Ele verifica se os resultados da consulta continuam corretos?

Sim. As verificações de corretude rodam junto com os testes de tempo, então uma consulta mais rápida ainda precisa devolver respostas certas.

De quais ferramentas ele depende?

Depende de as ferramentas pi-autoresearch estarem instaladas e de um arquivo de configuração para o adaptador alvo.

Detalhes

Descrição original do autor

Run a ClickHouse query optimization campaign on one git branch using pi-autoresearch, dynamic lanes and hypotheses, baseline result capture, correctness checks, and stagnation-aware lane/campaign review.

repo: PostHog/posthog

Popularidade

Estrelas no GitHub
41 mil
Posição no ranking
#6984
Licença
—
Atualizada em
02/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas