| name | clickhouse-multi-env-setup |
| description | Configure ClickHouse across dev, staging, and production with
environment-specific settings, secrets management, and infrastructure-as-code
patterns. Use when setting up per-environment ClickHouse instances, managing
connection configs, wiring secrets per environment, or deploying to multiple
environments. Trigger with "clickhouse environments", "clickhouse dev staging
prod", "clickhouse multi-env", "clickhouse environment config", "clickhouse
staging setup".
|
| allowed-tools | Read, Write, Edit, Bash(aws:*), Bash(gcloud:*), Bash(vault:*) |
| version | 1.7.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","database","analytics","clickhouse","olap"] |
| compatibility | Designed for Claude Code |
ClickHouse Multi-Environment Setup
Overview
Configure separate ClickHouse instances for development, staging, and production
with proper secrets management, environment detection, and infrastructure-as-code.
A single typed config module resolves the right instance from NODE_ENV, so
application code never branches on environment and destructive operations are
blocked outside dev/staging.
The full code for every step lives in
references/implementation.md; worked end-to-end
flows are in references/examples.md.
Prerequisites
- ClickHouse Cloud account or self-hosted instances per environment
- Secret management solution (Vault, AWS Secrets Manager, GCP Secret Manager)
- CI/CD pipeline with environment variables
Instructions
Step 1: Choose an environment strategy
Provision one instance per tier, isolated by data sensitivity:
| Environment | Instance | Purpose | Data |
|---|
| Development | Docker local | Fast iteration | Synthetic seed data |
| Staging | ClickHouse Cloud (Dev tier) | Pre-prod validation | Sampled prod copy |
| Production | ClickHouse Cloud (Prod tier) | Live traffic | Real data |
Step 2: Build a typed config module
Create src/config/clickhouse.ts with one ClickHouseEnvConfig per environment,
keyed by NODE_ENV. Fail fast in non-dev environments — require a password and
enforce HTTPS at startup:
export function getConfig(): ClickHouseEnvConfig {
const env = process.env.NODE_ENV ?? 'development';
const config = configs[env];
if (!config) throw new Error(`Unknown environment: `);
(env !== ) {
(!config.) ();
(!config..()) {
();
}
}
config;
}