/clickhouse-pack:clickhouse-local-dev-loopfrom clickhouse-pack
Sets up a local ClickHouse dev environment with Docker Compose, init scripts, seed data, and integration testing using vitest. Useful for fast schema iteration and testing.
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.
None: SKILL.md is the whole skill.
Run ClickHouse in Docker for local development with fast schema iteration, seed data, and integration testing using vitest.
@clickhouse/client# docker-compose.yml
services:
clickhouse:
image: clickhouse/clickhouse-server:latest
ports:
- "8123:8123" # HTTP interface
- "9000:9000" # Native TCP (clickhouse-client CLI)
volumes:
- clickhouse-data:/var/lib/clickhouse
- ./init-db:/docker-entrypoint-initdb.d # Auto-run SQL on first start
environment:
CLICKHOUSE_USER: default
CLICKHOUSE_PASSWORD: dev_password
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1 # Enable SQL-based user management
ulimits:
nofile:
soft: 262144
hard: 262144
volumes:
clickhouse-data:
docker compose up -d
# Verify: curl http://localhost:8123/ping → "Ok.\n"
-- init-db/001-schema.sql
CREATE DATABASE IF NOT EXISTS app;
CREATE TABLE IF NOT EXISTS app.events (
event_id UUID DEFAULT generateUUIDv4(),
event_type LowCardinality(String),
user_id UInt64,
properties String, -- JSON string
created_at DateTime DEFAULT now()
)
ENGINE = MergeTree()
ORDER BY (event_type, created_at)
PARTITION BY toYYYYMM(created_at);
// scripts/seed.ts
import { createClient } from '@clickhouse/client';
const client = createClient({
url: 'http://localhost:8123',
username: 'default',
password: 'dev_password',
database: 'app',
});
const events = Array.from({ length: 1000 }, (_, i) => ({
event_type: ['page_view', 'click', 'signup', 'purchase'][i % 4],
user_id: Math.floor(Math.random() * 100) + 1,
properties: JSON.stringify({ index: i }),
created_at: new Date(Date.now() - Math.random() * 86400000 * 30)
.toISOString()
.replace('T', ' ')
.slice(0, 19),
}));
await client.insert({ table: 'events', values: events, format: 'JSONEachRow' });
console.log(`Seeded ${events.length} events`);
await client.close();
my-clickhouse-app/
├── docker-compose.yml
├── init-db/
│ └── 001-schema.sql
├── scripts/
│ └── seed.ts
├── src/
│ ├── db.ts # Client singleton
│ └── queries.ts # Named query functions
├── tests/
│ ├── setup.ts # Test lifecycle (truncate tables)
│ └── events.test.ts
├── .env.local # Local creds (git-ignored)
├── .env.example
└── package.json
// src/db.ts
import { createClient, ClickHouseClient } from '@clickhouse/client';
let client: ClickHouseClient | null = null;
export function getClient(): ClickHouseClient {
if (!client) {
client = createClient({
url: process.env.CLICKHOUSE_HOST ?? 'http://localhost:8123',
username: process.env.CLICKHOUSE_USER ?? 'default',
password: process.env.CLICKHOUSE_PASSWORD ?? 'dev_password',
database: process.env.CLICKHOUSE_DATABASE ?? 'app',
});
}
return client;
}
// tests/setup.ts
import { getClient } from '../src/db';
import { beforeEach, afterAll } from 'vitest';
beforeEach(async () => {
const client = getClient();
// TRUNCATE is lightweight — drops parts without logging
await client.command({ query: 'TRUNCATE TABLE IF EXISTS app.events' });
});
afterAll(async () => {
await getClient().close();
});
// tests/events.test.ts
import { describe, it, expect } from 'vitest';
import { getClient } from '../src/db';
describe('ClickHouse events', () => {
it('inserts and queries events', async () => {
const client = getClient();
await client.insert({
table: 'events',
values: [
{ event_type: 'test', user_id: 1, properties: '{}' },
{ event_type: 'test', user_id: 2, properties: '{}' },
],
format: 'JSONEachRow',
});
const rs = await client.query({
query: 'SELECT count() AS cnt FROM events',
format: 'JSONEachRow',
});
const [row] = await rs.json<{ cnt: string }>();
expect(Number(row.cnt)).toBe(2);
});
});
{
"scripts": {
"dev": "tsx watch src/index.ts",
"db:up": "docker compose up -d",
"db:down": "docker compose down",
"db:reset": "docker compose down -v && docker compose up -d",
"db:seed": "tsx scripts/seed.ts",
"db:shell": "docker exec -it $(docker compose ps -q clickhouse) clickhouse-client --password dev_password",
"test": "vitest",
"test:watch": "vitest --watch"
}
}
# Interactive SQL shell
docker exec -it <container> clickhouse-client --password dev_password
# Run a query from host via HTTP
curl 'http://localhost:8123/?query=SELECT+count()+FROM+app.events'
# Check running queries
curl 'http://localhost:8123/?query=SELECT+*+FROM+system.processes+FORMAT+PrettyCompact'
# Watch merges
curl 'http://localhost:8123/?query=SELECT+*+FROM+system.merges+FORMAT+PrettyCompact'
| Error | Cause | Solution |
|---|---|---|
Connection refused :8123 | Container not running | docker compose up -d |
READONLY | User lacks write perms | Set CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 |
Too many parts | Tiny frequent inserts | Batch inserts or increase parts_to_throw_insert |
Memory limit exceeded | Large query on small container | Add --memory 4g to Docker |
See clickhouse-sdk-patterns for production-ready client patterns.
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: "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 encountering ClickHouse exceptions, debugging failed queries,
or troubleshooting server-side errors.
Trigger: "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 engines, designing sort keys,
or modeling data for analytical workloads.
Trigger: "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.
Trigger: "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: "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, GDPR deletion requests,
or managing sensitive data in ClickHouse.
Trigger: "clickhouse data retention", "clickhouse TTL", "clickhouse GDPR",
"delete data clickhouse", "clickhouse data lifecycle", "clickhouse PII".
npx claudepluginhub flight505/skill-forge --plugin clickhouse-packOther plugins' skills for the same job