/clickhouse-pack:clickhouse-sdk-patternsfrom clickhouse-pack
Provides production-ready patterns for @clickhouse/client: streaming inserts, typed queries, error handling, and connection management. Useful for building robust ClickHouse integrations.
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.
Production patterns for @clickhouse/client — typed queries, streaming inserts,
error handling, and connection lifecycle management. Start from the typed query
helper below, then drill into references/implementation.md for the streaming,
batching, and lifecycle patterns.
@clickhouse/client installed and authenticated (see clickhouse-install-auth)CLICKHOUSE_HOST / CLICKHOUSE_USER / CLICKHOUSE_PASSWORD env setdrain, Readable)Apply the pattern that fits your workload. Steps 2–7 live in references/implementation.md with full, copy-pasteable code; the core typed-query skeleton stays here.
query<T> wrapper that returns parsed rows (skeleton below).Readable instead of buffering in memory; honor drain.{ inserted, errors }.AsyncGenerator so you never load the full set into RAM.ClickHouseError (code + message)
from network/client errors and normalize into a structured result.SIGTERM via
client.close(); expose a ping()-based health check.max_threads, max_memory_usage,
max_execution_time, and max_result_rows for heavy queries.import { createClient } from '@clickhouse/client';
const client = createClient({
url: process.env.CLICKHOUSE_HOST!,
username: process.env.CLICKHOUSE_USER ?? 'default',
password: process.env.CLICKHOUSE_PASSWORD ?? '',
});
// Generic typed query — returns parsed JSON rows
async function query<T>(sql: string, params?: Record<string, unknown>): Promise<T[]> {
const rs = await client.query({
query: sql,
query_params: params,
format: 'JSONEachRow',
});
return rs.json<T>();
}
Note on parameterized queries: ClickHouse uses {name:Type} syntax for
parameters, not $1 or ?. Always use typed parameters to prevent SQL injection.
Applying these patterns produces:
client instance plus a generic query<T> helper that
returns typed, parsed rows.{ inserted: number; errors: Error[] } you can act
on programmatically.CH-<code>: <message> for server-side failures) rather
than raw thrown exceptions.Map common ClickHouse server error codes to a corrective action:
| Error Code | Meaning | Action |
|---|---|---|
SYNTAX_ERROR (62) | Bad SQL | Fix query syntax |
UNKNOWN_TABLE (60) | Table doesn't exist | Check table name, database |
TOO_MANY_SIMULTANEOUS_QUERIES (202) | Connection overload | Reduce concurrency or pool |
MEMORY_LIMIT_EXCEEDED (241) | Query uses too much RAM | Add filters, use streaming |
TIMEOUT_EXCEEDED (159) | Query too slow | Optimize ORDER BY, add indexes |
Full safeQuery wrapper (server-vs-client error discrimination) is in
references/implementation.md under Pattern 5.
Worked, runnable usage of each helper is in references/examples.md. Quick look — a typed aggregation query with named parameters:
interface EventCount {
event_type: string;
cnt: string; // ClickHouse JSON returns numbers as strings
}
const rows = await query<EventCount>(
'SELECT event_type, count() AS cnt FROM events WHERE user_id = {user_id:UInt64} GROUP BY event_type',
{ user_id: 42 }
);
See references/examples.md for streaming reads and structured error-result usage.
Apply these patterns in clickhouse-core-workflow-a for real data modeling, then
tune query cost and concurrency with clickhouse-cost-tuning and
clickhouse-performance-tuning.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
24 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-aDesign ClickHouse schemas with MergeTree engines, ORDER BY keys, and
partitioning.
Use when creating new tables, choosing an engine, designing sort keys, or
modeling data for analytical workloads on ClickHouse or ClickHouse Cloud.
Trigger with "clickhouse schema design", "clickhouse table design",
"clickhouse ORDER BY", "clickhouse partitioning", "MergeTree table".
/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".
/clickhouse-cost-tuningOptimize ClickHouse Cloud costs — compute scaling, storage tiering, compression,
and query efficiency for lower bills.
Use when analyzing ClickHouse Cloud bills, reducing storage costs, or optimizing
compute utilization.
Trigger with "clickhouse cost", "clickhouse billing", "reduce clickhouse spend",
"clickhouse pricing", "clickhouse expensive", "clickhouse storage cost".
/clickhouse-data-handlingHandle data lifecycle in ClickHouse — TTL expiration, data deletion (GDPR),
column-level encryption, and audit logging with real ClickHouse SQL.
Use when implementing data retention, fulfilling GDPR/CCPA deletion requests,
or managing sensitive data in ClickHouse.
Trigger with "clickhouse data retention", "clickhouse TTL", "clickhouse GDPR",
"delete data clickhouse", "clickhouse data lifecycle", "clickhouse PII".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin clickhouse-packOther plugins' skills for the same job