clickhouse-autoresearch-campaign
Skill này làm gì
Skill này hướng dẫn agent qua một nỗ lực có cấu trúc để tăng tốc một truy vấn cơ sở dữ liệu trong ClickHouse. Skill dành cho kỹ sư muốn thử nhiều thay đổi truy vấn một cách an toàn, với kết quả được ghi lại trên đường đi.
Khi nào nên dùng
- ✓Khi bạn muốn làm một truy vấn ClickHouse nhanh hơn qua các lần thử lặp lại có đo lường.
- ✓Khi bạn muốn mỗi thử nghiệm truy vấn được giữ trên nhánh git riêng.
- ✓Khi bạn muốn có bản ghi về thời gian chạy ban đầu và kiểm tra tính đúng đắn cho các thay đổi truy vấn.
Liên kết 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.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Truy vấn dashboard ClickHouse của chúng tôi quá chậm. Bạn có thể chạy một chiến dịch tối ưu trên nhánh riêng và giữ bản ghi về từng lần thử không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thiết lập một nhánh và không gian làm việc riêng, đo mốc thời gian ban đầu, rồi thử từng ý tưởng khác nhau một lần. Nó kiểm tra kết quả vẫn đúng và xem lại các chuỗi thử nghiệm không còn cải thiện.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Nó có cần nhánh git riêng không?
Có. Mỗi chiến dịch làm việc trên một nhánh git riêng, đó là ranh giới của công việc.
Nó có kiểm tra kết quả truy vấn vẫn đúng không?
Có. Các kiểm tra tính đúng đắn chạy song song với kiểm thử thời gian, nên một truy vấn nhanh hơn vẫn phải trả về câu trả lời đúng.
Nó dựa vào những công cụ nào?
Nó dựa vào các công cụ pi-autoresearch đã được cài đặt và một tệp cấu hình cho adapter mục tiêu.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6984
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.