/clickhouse-pack:clickhouse-core-workflow-afrom clickhouse-pack
Designs ClickHouse schemas with MergeTree engines, ORDER BY keys, partitioning, and codec choices. Activates on queries about table design, schema design, ORDER BY, or partitioning.
Ships in clickhouse-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Design ClickHouse tables with correct engine selection, ORDER BY keys,
partitioning, and codec choices for analytical workloads. This skill covers the
four schema decisions that determine query speed and storage cost — engine,
sort key, partition expression, and column codecs — then points to
references/ for full DDL and the programmatic apply path.
@clickhouse/client connected (see clickhouse-install-auth)| Engine | Best For | Dedup? | Example |
|---|---|---|---|
MergeTree | General analytics, append-only logs | No | Clickstream, IoT |
ReplacingMergeTree | Mutable rows (upserts) | Yes (on merge) | User profiles, state |
SummingMergeTree | Pre-aggregated counters | Sums numerics | Page view counts |
AggregatingMergeTree | Materialized view targets | Merges states | Dashboards |
CollapsingMergeTree | Stateful row updates | Collapses +-1 | Shopping carts |
ClickHouse Cloud uses SharedMergeTree — it is a drop-in replacement for
MergeTree on Cloud. You do not need to change your DDL.
The ORDER BY clause is the single most important schema decision. It defines:
Rules of thumb:
event_type, status)user_id, tenant_id)created_at)-- Good: filter by tenant, then by time ranges
ORDER BY (tenant_id, event_type, created_at)
-- Bad: UUID first means every query scans the full index
ORDER BY (event_id, created_at) -- event_id is random UUID
Start from the append-only event skeleton below, then adapt the engine and sort
key to your access pattern. Full DDL for the three canonical shapes — event
analytics (MergeTree), user profiles (ReplacingMergeTree), and daily
aggregation (AggregatingMergeTree) — plus column codec choices is in
schema examples.
CREATE TABLE analytics.events (
event_id UUID DEFAULT generateUUIDv4(),
tenant_id UInt32,
event_type LowCardinality(String),
user_id UInt64,
properties String CODEC(ZSTD(3)), -- JSON blob, compress well
created_at DateTime64(3) DEFAULT now64(3)
)
ENGINE = MergeTree()
ORDER BY (tenant_id, event_type, toDate(created_at), user_id)
PARTITION BY toYYYYMM(created_at)
TTL created_at + INTERVAL 1 YEAR
SETTINGS index_granularity = 8192;
toYYYYMM(date) (monthly) is the right default for most time-series tables —
target 10-1000 parts per partition. Each partition creates separate parts on
disk, so over-partitioning (e.g., by user_id) creates millions of tiny parts
and kills performance. Full partition matrix and the Node.js apply path are in
partitioning and applying schema.
Applying this skill produces:
CREATE TABLE statement with an engine, ORDER BY sort key,
PARTITION BY expression, per-column codecs, and (optionally) a TTL clause.@clickhouse/client command() call that runs
the DDL from application code (see the reference), keeping schema in version
control alongside the service.| Error | Cause | Solution |
|---|---|---|
ORDER BY expression not in primary key | PRIMARY KEY != ORDER BY | Remove explicit PRIMARY KEY or align |
Too many parts (300+) | Over-partitioning | Use coarser partition expression |
Cannot convert String to UInt64 | Wrong data type | Match insert types to schema |
TTL expression type mismatch | TTL on non-date column | TTL must reference DateTime column |
MergeTree, sort key (tenant_id, event_type, toDate(created_at), user_id), monthly partitions, 1-year TTL.ReplacingMergeTree(updated_at),
ORDER BY user_id, read with FINAL for deduplicated rows.AggregatingMergeTree targeting a
materialized view, storing AggregateFunction(uniq, UInt64) state.Full DDL for all three shapes plus column codec choices:
schema examples. The Node.js apply path
(client.command() with @clickhouse/client) and the full partition matrix:
partitioning and applying schema.
For inserting and querying data — batch inserts, async inserts, and query
patterns against these tables — see clickhouse-core-workflow-b.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin clickhouse-pack24 skills in this plugin
/clickhouse-ci-integrationRun ClickHouse integration tests in CI with GitHub Actions and Docker
containers. Use when setting up automated testing against a real ClickHouse
instance, configuring CI pipelines, or implementing schema validation in CI.
Trigger with "clickhouse CI", "clickhouse GitHub Actions", "clickhouse
integration tests", "test clickhouse in CI", "clickhouse automated testing".
/clickhouse-common-errorsDiagnose and fix the top 15 ClickHouse errors — query failures, insert problems,
memory limits, and merge issues.
Use when a ClickHouse query or insert throws an exception, a server-side error
appears in logs, or a failed query needs root-cause analysis.
Trigger with "clickhouse error", "fix clickhouse", "clickhouse not working",
"debug clickhouse", "clickhouse exception", "clickhouse syntax error".
/clickhouse-core-workflow-bInsert, query, and aggregate data in ClickHouse with real SQL patterns.
Use when writing analytical queries, inserting data at scale, building
dashboards, or implementing materialized views for pre-aggregation.
Trigger with "clickhouse query", "clickhouse insert", "clickhouse aggregate",
"clickhouse materialized view", "clickhouse SQL".
Other plugins' skills for the same job