Skip to content
local-clickhouse logo

Local ClickHouse

local-clickhouse

Install, configure, and validate local ClickHouse for gapless-crypto-clickhouse development and backtesting. Use when setting up local development environment, enabling offline mode, improving query performance for backtesting, or running E2E validation. Includes mise/Homebrew/apt installation, m...

SKILL.md

Full skill instructions

Local ClickHouse

Install, configure, and validate local ClickHouse as an alternative to ClickHouse Cloud for development and backtesting (ADR-0044, ADR-0045).

Purpose

Enable local ClickHouse deployment for:

  1. Backtesting: 50-100x faster queries (no network round-trip)
  2. Development: Offline work without Cloud credentials
  3. Evaluation: Try package before Cloud commitment
  4. Cost savings: Avoid Cloud costs during experimentation

When to Use

Use this skill when:

  • Local development: Setting up development environment without Cloud
  • Backtesting optimization: Need faster query performance
  • Offline mode: Working without network access
  • Package evaluation: Trying gapless-crypto-clickhouse before Cloud setup

Triggers: User mentions "local ClickHouse", "install clickhouse", "backtesting setup", "offline mode", "GCCH_MODE=local"

Prerequisites

System Requirements:

  • macOS (Homebrew) or Linux (apt/​installer)
  • 2-4GB RAM minimum
  • 10GB+ disk space for data

Network: Internet required for installation only (offline after setup)

Workflow

Step 1: Install ClickHouse

macOS (Homebrew):

# Install ClickHouse
brew install clickhouse

# Verify installation
clickhouse --version

Linux (Ubuntu/​Debian):

# Quick installer (recommended)
curl https://clickhouse.com/ | sh
./​clickhouse --version

# Or via apt
sudo apt-get install -y apt-transport-https ca-certificates
curl -fsSL https://packages.clickhouse.com/​deb/​lts/​clickhouse.gpg | sudo gpg --dearmor -o /​usr/​share/​keyrings/​clickhouse-keyring.gpg
echo "deb [signed-by=/​usr/​share/​keyrings/​clickhouse-keyring.gpg] https://packages.clickhouse.com/​deb stable main" | sudo tee /​etc/​apt/​sources.list.d/​clickhouse.list
sudo apt-get update
sudo apt-get install -y clickhouse-server clickhouse-client

Step 2: Start ClickHouse Server

macOS (Homebrew):

# Start server in background
clickhouse server --daemon

# Verify server is running
clickhouse client --query "SELECT 1"

Linux (systemd):

# Start and enable service
sudo service clickhouse-server start
sudo systemctl enable clickhouse-server

# Verify server is running
clickhouse-client --query "SELECT 1"

Step 3: Configure Environment

Set Local Mode:

# Explicit local mode (recommended)
export GCCH_MODE=local

# Or rely on auto-detection (localhost triggers local mode)
export CLICKHOUSE_HOST=localhost

Environment Variables:

# Full local configuration
export GCCH_MODE=local
export CLICKHOUSE_HOST=localhost
export CLICKHOUSE_HTTP_PORT=8123
export CLICKHOUSE_DATABASE=default
export CLICKHOUSE_USER=default
export CLICKHOUSE_PASSWORD=

Step 4: Verify Connection

Using Python:

from gapless_crypto_clickhouse import probe

# Check local ClickHouse status
status = probe.check_local_clickhouse()
print(f"Installed: {status['installed']}")
print(f"Running: {status['running']}")
print(f"Version: {status['version']}")

# Get current mode
mode = probe.get_current_mode()
print(f"Mode: {mode}")  # Should be "local"

Using CLI:

# Quick connection test
GCCH_MODE=local python -c "
from gapless_crypto_clickhouse.clickhouse.config import ClickHouseConfig
config = ClickHouseConfig.from_env()
print(f'Host: {config.host}')
print(f'Port: {config.http_port}')
print(f'Secure: {config.secure}')
"

Step 5: Test with Real Data

Query with Auto-Ingestion:

import os
os.environ["GCCH_MODE"] = "local"

from gapless_crypto_clickhouse import query_ohlcv

# First query downloads and ingests data automatically
df = query_ohlcv(
    "BTCUSDT",
    "1h",
    "2024-01-01",
    "2024-01-07"
)
print(f"Rows: {len(df)}")
print(df.head())

Mode Detection Logic

The package auto-detects deployment mode based on environment:

GCCH_MODE=local       → Local mode (explicit)
GCCH_MODE=cloud       → Cloud mode (requires CLICKHOUSE_HOST)
GCCH_MODE=auto        → Auto-detect:
  CLICKHOUSE_HOST=""           → Local mode
  CLICKHOUSE_HOST="localhost"  → Local mode
  CLICKHOUSE_HOST="127.0.0.1"  → Local mode
  CLICKHOUSE_HOST="*.cloud"    → Cloud mode

Introspection:

from gapless_crypto_clickhouse import probe

# Get available modes
modes = probe.get_deployment_modes()
print(modes["available_modes"])  # ["local", "cloud"]

# Get current mode
current = probe.get_current_mode()  # "local" or "cloud"

# Get installation guide
guide = probe.get_local_installation_guide()
print(guide["macos"]["commands"])

Success Criteria

  • ClickHouse server running on localhost:8123
  • probe.check_local_clickhouse() returns {"installed": True, "running": True}
  • probe.get_current_mode() returns "local"
  • query_ohlcv() executes without Cloud credentials

Troubleshooting

Issue: "Connection refused" on port 8123

  • Check: Is ClickHouse server running?

    # macOS
    ps aux | grep clickhouse
    
    # Linux
    sudo service clickhouse-server status
    
  • Action: Start server with clickhouse server --daemon

Issue: "Command not found: clickhouse"

  • Check: Was ClickHouse installed correctly?
  • macOS: Run brew install clickhouse
  • Linux: Run curl https://clickhouse.com/ | sh

Issue: Mode detected as "cloud" instead of "local"

  • Check: Is CLICKHOUSE_HOST set to a remote hostname?
  • Action: Set export GCCH_MODE=local explicitly

Issue: Server crashes with memory error

  • Check: System has 2-4GB RAM available
  • Action: Increase available memory or reduce concurrent queries

Issue: Permission denied errors

  • Check: ClickHouse data directory permissions
  • Action: Ensure user has write access to /​var/​lib/​clickhouse (Linux)

Port Reference

ModeHTTP PortNative PortSecure
Local81239000False
Cloud84439440True

Performance Comparison

MetricLocalCloud
Query latency50ms100-500ms
First query (cold)50ms5-10s (idle resume)
Network dependencyNoneRequired
CredentialsNoneRequired
Best forBacktestingProduction

Server Management

Start Server:

# macOS
clickhouse server --daemon

# Linux
sudo service clickhouse-server start

Stop Server:

# macOS
pkill -f clickhouse-server

# Linux
sudo service clickhouse-server stop

Check Logs:

# macOS (Homebrew)
tail -f /​opt/​homebrew/​var/​log/​clickhouse-server/​clickhouse-server.log

# Linux
sudo tail -f /​var/​log/​clickhouse-server/​clickhouse-server.log

E2E Validation Workflow (ADR-0045)

This skill includes executable scripts for end-to-end validation of local ClickHouse.

Scripts Directory

ScriptPurpose
scripts/​start-clickhouse.shStart mise-installed ClickHouse server
scripts/​deploy-schema.shDeploy production schema (calls existing script)
scripts/​ingest-sample-data.pyIngest real Binance data via query_ohlcv()
scripts/​take-screenshot.pyCapture Play UI screenshot via Playwright
scripts/​validate-data.pyValidate data integrity, output JSON evidence

Running E2E Validation

Full workflow (manual):

# 1. Start ClickHouse
./​skills/​local-clickhouse/​scripts/​start-clickhouse.sh

# 2. Deploy schema
./​skills/​local-clickhouse/​scripts/​deploy-schema.sh

# 3. Ingest sample data
uv run python skills/​local-clickhouse/​scripts/​ingest-sample-data.py

# 4. Capture screenshot
uv run python skills/​local-clickhouse/​scripts/​take-screenshot.py

# 5. Validate data
uv run python skills/​local-clickhouse/​scripts/​validate-data.py

Via pytest (automated):

# Run E2E tests (requires mise ClickHouse installed)
uv run pytest tests/​test_local_clickhouse_e2e.py -v

# Tests will FAIL (not skip) if ClickHouse not available

Evidence Output

Scripts output evidence to tests/​screenshots/ (gitignored):

  • play-ui-{timestamp}.png - Playwright screenshots
  • validation-{timestamp}.json - Structured validation results

References

Next Steps

After successful local setup:

  1. Schema Creation: Tables created automatically on first query
  2. Data Ingestion: Use query_ohlcv() with auto_ingest=True
  3. E2E Validation: Run uv run pytest tests/​test_local_clickhouse_e2e.py -v
  4. Backtesting: Run analysis with 50-100x faster queries
  5. Production Migration: Switch to Cloud mode with export GCCH_MODE=cloud

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View