clickhousectl is the CLI for ClickHouse: local and cloud.
With clickhousectl you can:
- Install and manage local ClickHouse versions
- Launch and manage local ClickHouse servers
- Run and manage local Postgres instances
- Execute queries against ClickHouse servers
- Set up ClickHouse Cloud and create cloud-managed ClickHouse clusters
- Create and manage ClickHouse Cloud Postgres services
- Manage ClickHouse Cloud resources
- Create and manage ClickPipes for data ingestion (S3, Kafka, Kinesis, Postgres, MySQL, MongoDB, BigQuery)
- Install the official ClickHouse agent skills into supported coding agents
- Push your local ClickHouse development to cloud
clickhousectl helps humans and AI-agents to develop with ClickHouse.
Installation
Quick install
~/.local/bin/clickhousectl. A chctl alias is also created automatically for convenience.
Requirements
- macOS (aarch64, x86_64) or Linux (aarch64, x86_64)
- Cloud commands require a ClickHouse Cloud API key
Local
Installing and managing ClickHouse versions
clickhousectl downloads ClickHouse binaries from builds.clickhouse.com, falling back to packages.clickhouse.com (Linux) or GitHub releases (macOS) when a build isn’t available there.
local use also creates a symlink at ~/.local/bin/clickhouse pointing to the selected version’s binary, so the plain clickhouse command (e.g. clickhouse local, clickhouse client) is on PATH. Pass --no-global to skip. If a regular file already exists at that path it is left alone with a warning. local remove of the active default version also clears the symlink.
ClickHouse binary storage
ClickHouse binaries are stored in a global repository, so they can be used by multiple projects without duplicating storage. Binaries are stored in~/.clickhouse/:
Initializing a project
init bootstraps your current working directory with a standard folder structure for your ClickHouse and Postgres project files. It is optional; you are welcome to use your own folder structure if preferred.
It creates the following structure:
Running queries
Creating and managing ClickHouse servers
Start and manage ClickHouse server instances. Each server gets its own isolated data directory at.clickhouse/servers/<name>/data/.
--name, the first server is called “default”. If “default” is already running, a random name is generated (e.g. “bold-crane”). Use --name for stable identities you can start/stop repeatedly.
Ports: Defaults are HTTP 8123 and TCP 9000. If these are already in use, free ports are automatically assigned and shown in the output. Use --http-port and --tcp-port to set explicit ports.
Global server management: Use --global with list, stop, and stop-all to operate across all projects system-wide. server list --global shows all running ClickHouse servers with a Project column indicating which directory each belongs to.
Custom config files for local servers
Local servers start with sensible defaults, but sometimes you need to flip a setting. Drop a config file into~/.clickhouse/configs/ and apply it by name when starting a server:
config.d), so it only needs to contain the settings you want to change, and there’s no need to reproduce a full config. Files can be .xml, .yaml, or .yml, and you can reference them by name with or without the extension.
Project-local data directory
All server data lives inside.clickhouse/ in your project directory:
clickhousectl local server remove <name> to permanently delete a server’s data.
Running local Postgres
In addition to ClickHouse,clickhousectl can run and manage local Postgres instances. Local Postgres is Docker-backed, so Docker must be installed and running. Each instance is identified by its name and major version, so multiple Postgres versions can run side by side with separate data directories.
Authentication
Authenticate to ClickHouse Cloud using API keys (recommended) or OAuth (browser-based). If you don’t have a ClickHouse Cloud account yet,clickhousectl cloud auth signup opens the sign-up page in your browser.
API key/secret (recommended)
API keys are the recommended way to authenticate, especially when driving the CLI from an AI agent. You can create scoped API keys that grant only the permissions you choose (read-only or read/write), and each key is tied to a single organization. This makes it a safe, least-privilege way to give the CLI access..clickhouse/credentials.json (project-local).
You can also use environment variables, either exported in your session:
.env file in your current working directory:
OAuth login
.clickhouse/tokens.json (project-local).
OAuth access is currently read-only and grants access to all organizations you belong to. For write access, or to scope the CLI to a single organization, create a scoped API key instead.
Auth status and logout
.clickhouse/credentials.json > exported environment variables > .env file > OAuth tokens.
Debugging which credential source was used
Pass--debug to any cloud command to print the resolved credential source (and the API URL) to stderr before the command runs.
Cloud
Manage ClickHouse Cloud services via the API.Organizations
Services
Service create options
Query API auth modes
cloud service query is the canonical way to run SQL against a cloud service over HTTP, with no clickhouse binary and no service password required. It works with both credential modes:
- API key auth (read + write SQL): the first time
cloud service queryruns against a service without a stored key, it provisions a Query API endpoint for that service and creates a dedicated API key bound to it. The key (keyId,keySecret, andendpointId) is stored in.clickhouse/credentials.jsonunderservice_query_keys.<service-id>. The key is scoped to a single service, so it can read and write (SELECT, INSERT, DDL) against that service but cannot reach any other service in the org. Pass--no-auto-enableto fail instead of provisioning. - OAuth (
cloud auth login): the query runs as your own identity, just like the web SQL-console. Your SQL permissions on the service are read-only when using OAuth. No Query API key is provisioned or stored.--no-auto-enablehas no effect in this mode.
cloud service start. Set CLICKHOUSE_CLOUD_QUERY_HOST to override the derived Query API host.
Query endpoint management
Private endpoint management
Backup configuration
Postgres services
clickhousectl can also create and manage ClickHouse Cloud Postgres services, mirroring the ClickHouse service commands above.
Postgres service create options
Backups
ClickPipes
Manage ClickPipes for ingesting data into ClickHouse Cloud from external sources.Creating ClickPipes
Each source type has its own subcommand underclickpipe create:
clickhousectl cloud clickpipe create <source> --help for the full list of options per source type.
Members
Invitations
Keys
Activity
JSON output
Use the--json flag to print JSON-formatted responses.
clickhousectl auto-detects coding-agent contexts (Claude Code, Cursor, Codex, Gemini CLI, Goose, Devin, and any tool that sets the standard AGENT env var) and emits JSON to stdout automatically without setting --json.
Exit codes
Exit codes follow thegh CLI conventions:
Skills
Install the official ClickHouse Agent Skills from ClickHouse/agent-skills.Non-interactive flags
Self-update
clickhousectl can update itself to the latest release: