Skip to content

About

The CLI for ClickHouse: local and cloud.

Topics

Resources

Contributing

Stars

84 stars

Watchers

2 watching

Forks

Repository files navigation

ClickHouse

clickhousectl

Slack community Follow on X YouTube videos

clickhousectl (chctl) is the official CLI for ClickHouse and Postgres, from local development to ClickHouse Cloud.

What can the CLI do?

  • ClickHouse: install and switch local versions, run isolated servers, deploy local UDFs, and execute SQL.
  • ClickHouse Cloud: create, configure, scale, back up, and query managed services on AWS, GCP, and Azure.
  • ClickHouse Managed Postgres: run Docker-backed Postgres locally, then create, monitor, configure, and restore managed services in Cloud.
  • ClickPipes: ingest data into ClickHouse Cloud from object storage, streams, and databases through change data capture.
  • ClickStack: manage sources, roles, saved searches, dashboards, alerts, and webhooks for an existing Managed ClickStack service.

The CLI also manages organization access, BYOC infrastructure, activity logs, and official ClickHouse skills for coding agents.

Install

Supports macOS and Linux on Apple Silicon/ARM64 and x86_64.

curl -fsSL https://clickhouse.com/cli | sh

The script installs to ~/.local/bin/clickhousectl and creates the chctl alias. Ensure ~/.local/bin is on your PATH.

Other installation options:

Tool Command
npm npm install -g clickhousectl or npx clickhousectl
uv uv tool install clickhousectl
pipx pipx install clickhousectl
pip pip install clickhousectl
cargo-binstall cargo binstall clickhousectl
Cargo, from source (Rust 1.94.1+) cargo install clickhousectl

The chctl alias is created by the install script and npm; PyPI and Cargo installs provide clickhousectl only.

Check for or install a CLI update:

clickhousectl update --check
clickhousectl update

update replaces binaries installed by the script, a download, or Cargo; npm, uv, pipx, and pip installs are upgraded with their package manager, and update prints that command. The install script and update verify each downloaded archive against the release SHA256SUMS; see Release verification to verify a download or build attestation yourself.

Shell completions and command search

Find any command or flag by keyword with clickhousectl search <words>, and run <command> --help for full flags and Cloud permission requirements.

To complete commands, flags, local server names, and installed versions with Tab (registers both clickhousectl and chctl):

eval "$(clickhousectl completions bash)"   # ~/.bashrc
eval "$(clickhousectl completions zsh)"    # ~/.zshrc, after compinit
clickhousectl completions fish | source    # ~/.config/fish/config.fish

Completion runs the installed CLI offline on each Tab press, stays current after update, and records no telemetry.

Start locally

Use the latest channel for the rolling master build of ClickHouse. A bare server start installs latest if no version or default is available.

clickhousectl local init
clickhousectl local clickhouse start dev --version latest
clickhousectl local client dev --query "SELECT version()"
clickhousectl local clickhouse stop dev

local init marks the directory as a project; later commands work from it or any subdirectory, as Git does. Each named server keeps isolated data under .clickhouse/; stopping preserves it for the next start.

For local Postgres, start Docker first:

clickhousectl local postgres start dev
clickhousectl local postgres client dev --query "SELECT version()"
clickhousectl local postgres stop dev

Continue with local development for SQL files, version management, custom configs, and cleanup.

Connect to ClickHouse Cloud

Create a ClickHouse Cloud account if needed ($300 in free trial credits), then sign in:

clickhousectl cloud auth signup
clickhousectl cloud auth login

Cloud commands act on an organization you choose. Pin one for the project, or pass --org <ID_OR_NAME> on each command:

clickhousectl cloud org list
clickhousectl cloud use --org <ID_OR_NAME>

Browser OAuth is read-only. Creating or changing resources requires an API key with the appropriate roles:

  • Short-lived scoped key (interactive): run clickhousectl cloud access roles to inspect assignable roles, then request browser approval for a scoped key saved to .clickhouse/credentials.json:
    clickhousectl cloud access request --purpose "Create analytics service"
  • Existing API key (interactive): run clickhousectl cloud auth login --interactive to save a key without placing its secret in shell history.
  • CI or .env: set CLICKHOUSE_CLOUD_API_KEY and CLICKHOUSE_CLOUD_API_SECRET in your environment (or a git-ignored .env file in the project root).

OAuth tokens are global (~/.clickhouse/tokens.json); saved API keys and organization and service pins (clickhousectl cloud use --org <ID_OR_NAME>) belong to the project (.clickhouse/). See authentication and access for precedence, organization selection, and logout.

Create and query ClickHouse

Provision a ClickHouse Cloud service, run SQL directly over the Query API, or open an interactive clickhouse client session:

clickhousectl cloud clickhouse create --name analytics --provider aws --region us-east-1
clickhousectl cloud clickhouse get --clickhouse <ID_OR_NAME>
clickhousectl cloud clickhouse query --clickhouse <ID_OR_NAME> --query "SELECT version()"
clickhousectl cloud clickhouse client --clickhouse <ID_OR_NAME>

From there you can scale replicas and profiles, tune settings, manage IP allowlists and backups, or write connection details to .env with cloud clickhouse dotenv. See Cloud services and SQL and Query API behavior.

Create ClickHouse Managed Postgres

Provision a managed Postgres service, download its CA certificate for psql, or run read-only SQL directly from the CLI:

clickhousectl cloud postgres create --name app-db \
  --provider aws --region us-east-1 --size c6gd.xlarge --pg-version 18
clickhousectl cloud postgres get --postgres <ID_OR_NAME>
clickhousectl cloud postgres certs get --postgres <ID_OR_NAME> --output ca.pem
clickhousectl cloud postgres query --postgres <ID_OR_NAME> --query "SELECT version()"

Manage network access, AWS PrivateLink, Postgres/PgBouncer config, HA standbys, read replicas, logs, metrics, and point-in-time recovery. See the ClickHouse Managed Postgres guide.

Ingest with ClickPipes

Ingest from object storage, streams (Kafka, Kinesis, Pub/Sub), or databases (Postgres, MySQL, MongoDB, BigQuery) using API-key authentication and a running ClickHouse destination:

S3_URL="https://example-bucket.s3.amazonaws.com/events/**"
clickhousectl cloud clickpipe schema-discover object-storage --clickhouse <ID_OR_NAME> \
  --storage-type s3 --source-url "$S3_URL" --format JSONEachRow \
  --iam-role "$S3_IAM_ROLE_ARN" --json > discovery.json

clickhousectl cloud clickpipe create object-storage --clickhouse <ID_OR_NAME> \
  --name s3-events --storage-type s3 --source-url "$S3_URL" \
  --format JSONEachRow --iam-role "$S3_IAM_ROLE_ARN" \
  --database default --table s3_events --columns-from discovery.json
clickhousectl cloud clickpipe get --clickhouse <ID_OR_NAME> --clickpipe s3-events

See the ClickPipes guide for Managed Postgres CDC setup, monitoring, and safe updates, and ClickPipe configuration for mappings, credentials, scaling, and private connectivity.

Configure ClickStack

Manage sources, roles, saved searches, dashboards, alerts, and webhooks for an existing Managed ClickStack service:

clickhousectl cloud clickstack source list --clickhouse <ID_OR_NAME>
clickhousectl cloud clickstack dashboard validate --clickhouse <ID_OR_NAME> --file dashboard.json
clickhousectl cloud clickstack dashboard create --clickhouse <ID_OR_NAME> --file dashboard.json

See the ClickStack guide for JSON templates, webhooks, alerting, silencing, and safe updates.

Use with coding agents and scripts

Install official ClickHouse skills into the current project, or add --global for your home directory:

clickhousectl skills --agent claude --agent codex

The common .agents/skills/ directory is always included. Run skills without flags for interactive selection; unattended installs require --agent, --all, or --detected-only.

Structured commands support --json and select it automatically for detected coding agents (CLICKHOUSECTL_AUTO_JSON=0 opts out). SQL and native clients retain command-specific formats. Check exit codes and distinguish an accepted async request from completion; see automation and output contracts.

Documentation

Browse the full documentation index, or jump directly to a guide or reference:

Documentation Covers
Local development Local ClickHouse and Postgres, versions, configuration, and cleanup
ClickHouse Cloud services Create, query, scale, configure, back up, and remove services
ClickHouse Managed Postgres Connect, restrict access, query, configure, monitor, and recover
ClickPipes Load object storage, replicate Postgres CDC, monitor, and update pipelines
ClickStack Sources, dashboards, webhooks, alerts, silencing, and safe updates
User-defined functions Scaffold and test executable UDFs locally, then deploy to Cloud
Authentication and access OAuth, cloud access, API keys, precedence, org pins, roles, and logout
Organization, BYOC, and activity Org settings, quotas, billing, notifications, activity log, and BYOC
SQL and Query API Key binding, SQL input/output, timeouts, named endpoints, and saved queries
ClickPipe configuration Source auth, mappings, scaling, partial updates, and private connectivity
Automation and output contracts JSON shapes, exit codes, error codes, async next polling, and update checks
Release verification Install-path checks, SHA256SUMS, and GitHub build attestations
Telemetry Recorded fields, opt-out, and local payload inspection
Feedback What feedback sends, length limit, and errors
Contributing & Development Build, test gates, code layout, live integration suites, and release signing
Rust API library Typed Cloud API client, examples, and changelog

Telemetry and feedback

The CLI collects anonymous command usage and bounded failure categories, never argument values, SQL, credentials, or an installation/device ID. The first-run notice sends nothing; collection starts on a following run unless disabled (clickhousectl telemetry disable or DO_NOT_TRACK=1). See telemetry details.

Report gaps or unexpected CLI behavior with clickhousectl feedback "<message>"; see what feedback sends.

About

The CLI for ClickHouse: local and cloud.

Topics

Resources

Contributing

Stars

84 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages