clickhouse-autoresearch-campaign
하는 일
이 스킬은 ClickHouse에서 데이터베이스 쿼리 하나의 속도를 높이기 위한 체계적인 작업을 에이전트가 진행하도록 안내합니다. 쿼리 변경을 반복적으로 안전하게 시험하면서 결과를 기록하려는 엔지니어를 위한 스킬입니다.
사용하는 경우
- ✓측정 가능한 반복 시도를 통해 ClickHouse 쿼리 하나를 빠르게 만들고 싶을 때.
- ✓각 쿼리 실험을 자체 git 브랜치에 보관하고 싶을 때.
- ✓쿼리 변경에 대한 기준 시간과 정확성 검사 기록을 원할 때.
스킬 링크
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복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“ClickHouse 대시보드의 쿼리가 너무 느립니다. 자체 브랜치에서 최적화 캠페인을 실행하고, 각 시도를 기록해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 전용 브랜치와 작업 공간을 설정하고, 시작 기준선을 측정합니다. 아이디어를 한 번에 하나씩 시도하며, 결과가 계속 맞는지 확인하고, 개선이 멈춘 시도의 기록을 검토합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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-autoresearchis 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.jsonbaseline/metrics.jsonquery/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, joinsWITH … 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, expressionsEXPLAIN ESTIMATE SELECT …— per-part row/mark estimates before executionEXPLAIN PLAN indexes = 1, actions = 1, json = 1 SELECT …— primary-key and skip-index use, JSON for machine parsingEXPLAIN 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
자주 묻는 질문
자체 git 브랜치가 필요한가요?
네. 각 캠페인은 하나의 전용 git 브랜치에서 작업하며, 그것이 작업의 경계가 됩니다.
쿼리 결과가 맞는지 확인하나요?
네. 정확성 검사는 시간 테스트와 함께 실행되므로, 더 빨라진 쿼리도 올바른 답을 반환해야 합니다.
어떤 도구에 의존하나요?
pi-autoresearch 도구가 설치되어 있어야 하고, 대상 어댑터를 위한 설정 파일이 필요합니다.
상세 정보
작성자의 원본 설명
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
인기도
- GitHub 스타
- 41k
- 순위
- #6984
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
depot-ci
41k에이전트가 GitHub Actions 대안인 Depot CI 워크플로를 설정하고 실행하도록 돕습니다. 기존 워크플로 이전과 실행 로그 읽기를 포함합니다.
depot-container-builds
41k에이전트가 Depot 원격 빌더에서 Docker 이미지를 빌드하도록 돕습니다. 다중 플랫폼 이미지, 레지스트리 푸시, 빌드 실패 수정을 포함합니다.
depot-github-runners
41k에이전트가 GitHub Actions 작업을 Depot 관리형 러너로 옮기고, 러너 크기와 라벨을 고르도록 돕습니다.
editing-agents-md
41k에이전트가 규칙을 AGENTS.md나 CLAUDE.md 중 어디에 둘지 정하고, 파일을 키우지 않으면서 잘 지켜지도록 쓰게 돕습니다.
비슷한 스킬
api-connector-builder
280k에이전트가 기존 패턴을 따라 새로운 API 연결을 만들도록 합니다. 새로운 방식을 도입하지 않고 연동을 하나 더 추가할 때 씁니다.
api-design
280k에이전트가 모범 사례에 따라 REST API를 설계하도록 돕습니다. API가 통신하는 방식, 오류를 보여 주는 방식, 데이터를 정리하는 방식을 정하는 데 유용합니다.
backend-patterns
280k에이전트가 서버 쪽 아키텍처 패턴과 데이터베이스 최적화를 다루도록 돕습니다. 서버에서 실행되는 코드를 만들거나 검토할 때 유용합니다.