Agentic PostgreSQL to ClickHouse migration tool for TypeScript projects.
This prototype was co-developed between AWS and ClickHouse.
clickhouse.build is a free, client-side CLI. You can install the CLI from this repo and try it out with your project.
If you don't already have a ClickHouse environment, you can sign up for a free ClickHouse Cloud trial with $300 in credits.
clickhouse.build assists with the process of migrating from PostgreSQL to ClickHouse:
- Scans your codebase to discover PostgreSQL analytical queries (aggregations, GROUP BY, window functions, etc.)
- Generates ClickPipe configuration for CDC or snapshot-based data replication
- Migrates application code by installing ClickHouse client and implementing patterns for query routing
The tool uses specialized AI agents that understand your code structure, database schema, and ORM patterns to generate production-ready migration code.
Before using clickhouse.build, ensure you have:
- Python 3.13+ (uses latest Python features)
- uv package manager (installation guide)
- AWS credentials with access to Amazon Bedrock
- Claude Sonnet 4.5 enabled in your AWS Bedrock account
- Clone the repository:
git clone https://github.com/ClickHouse/clickhouse.build.git
cd clickhouse.build- Set up AWS credentials:
cp .env.template .env
# Edit .env with your AWS credentialsRequired environment variables:
AWS_ACCESS_KEY_ID- Your AWS access keyAWS_SECRET_ACCESS_KEY- Your AWS secret keyAWS_DEFAULT_REGION- AWS region (e.g., us-east-1)
- Install dependencies:
uv syncBefore running the migration:
- Work on a branch - Never run migrations directly on main
- Create AGENTS.md - Add an AGENTS.md file to your repository to help
chbuildimprove its efficacy when understanding your codebase - Consider running
clickhouse.buildin a VM or container for additional safety precautions
Display help and available commands:
uv run main.py --helpRun the complete migration workflow (recommended for first-time users):
uv run main.py migrate /path/to/your/repo --replication-mode cdcThis will:
- Scan for analytical queries
- Generate ClickPipe configuration
- Migrate application code
- Prompt for approval before making any changes
Scanner Agent - Analyze a repository and find PostgreSQL analytical queries:
uv run main.py scanner [REPO_PATH]Output: .chbuild/scanner/scan_TIMESTAMP.json with discovered queries
Data Migrator Agent - Generate ClickPipe configuration for data migration:
uv run main.py data-migrator [REPO_PATH] [--replication-mode cdc|snapshot|cdc_only]Output: curl command with ClickPipe JSON configuration
Code Migrator Agent - Migrate application code:
uv run main.py code-migrator [REPO_PATH]Output: Modified application files with ClickHouse integration
Migrate - Run the complete migration workflow (scanner → data-migrator → code-migrator):
uv run main.py migrate [REPO_PATH] [--replication-mode cdc|snapshot|cdc_only]--skip-credentials-check- Skip AWS credentials validation--yes/-y- Skip all confirmation prompts and approve all changes automatically (useful for CI/CD)--replication-mode- Set replication mode for data migration:cdc- Change Data Capture with initial snapshot + real-time syncsnapshot- One-time snapshot replication onlycdc_only- CDC without initial snapshot
See CONTRIBUTING.md for development setup and guidelines.
We welcome feedback on the direction of this project as we continue to evolve it.
