.agents/skills/clickhouse-query/SKILL.md
Run ClickHouse queries for analytics, metrics analysis, and event data exploration. Use when you need to query ClickHouse directly, analyze metrics, check event tracking data, or test query performance. Read-only by default.
npx skillsauth add em-jones/staccato-toolkit clickhouse-queryInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill to run ad-hoc ClickHouse queries for analytics, metrics analysis, and debugging.
Use the included query script:
node .claude/skills/clickhouse-query/query.mjs "SELECT count() FROM views"
| Flag | Description |
| --------------------- | ------------------------------------------------- |
| --explain | Show query execution plan |
| --writable | Allow write operations (requires user permission) |
| --timeout <s>, -t | Query timeout in seconds (default: 30) |
| --file, -f | Read query from a file |
| --json | Output results as JSON |
| --quiet, -q | Minimal output, only results |
# Count rows in a table
node .claude/skills/clickhouse-query/query.mjs "SELECT count() FROM views"
# Query with filters
node .claude/skills/clickhouse-query/query.mjs "SELECT * FROM modelEvents WHERE modelId = 123 LIMIT 10"
# Check query execution plan
node .claude/skills/clickhouse-query/query.mjs --explain "SELECT * FROM views WHERE userId = 1"
# Override default 30s timeout for longer queries
node .claude/skills/clickhouse-query/query.mjs --timeout 60 "SELECT ... (complex aggregation)"
# Query from file
node .claude/skills/clickhouse-query/query.mjs -f my-query.sql
# JSON output for processing
node .claude/skills/clickhouse-query/query.mjs --json "SELECT type, count() FROM modelEvents GROUP BY type"
--writable flag is used--timeout)--writable, you MUST ask the user for permissionOnly use the --writable flag when:
IMPORTANT: Always ask the user for permission before running with --writable.
| Table | Description |
| -------------------- | --------------------------------------------- |
| views | Page/entity view events |
| modelEvents | Model create/publish/update events |
| modelVersionEvents | Model version events including downloads |
| userActivities | User registration, login, subscription events |
| images | Image upload/delete events |
| reactions | Like/dislike events |
| reports | Content report events |
| entityMetricEvents | Aggregated metric events |
IMPORTANT: Production uses a ClickHouse replica cluster. When querying system tables (logs, metrics, etc.), you must use clusterAllReplicas() to get data from all nodes.
-- WRONG: Only queries the node you're connected to
SELECT * FROM system.query_log WHERE event_time > now() - INTERVAL 1 HOUR
-- CORRECT: Queries all replicas in the cluster
SELECT * FROM clusterAllReplicas(default, system.query_log)
WHERE event_time > now() - INTERVAL 1 HOUR
-- Find recent queries across all nodes
SELECT
hostname(),
event_time,
query_duration_ms,
formatReadableSize(memory_usage) AS memory,
query
FROM clusterAllReplicas(default, system.query_log)
WHERE type = 'QueryFinish'
AND event_time > now() - INTERVAL 5 MINUTE
ORDER BY event_time DESC
LIMIT 20
-- Find expensive queries by memory usage (last 24 hours)
SELECT
count() as query_count,
user,
sum(memory_usage) AS total_memory,
normalized_query_hash
FROM clusterAllReplicas(default, system.query_log)
WHERE event_time > now() - INTERVAL 1 DAY
AND query_kind = 'Select'
AND type = 'QueryFinish'
GROUP BY normalized_query_hash, user
ORDER BY total_memory DESC
LIMIT 10
-- Search query logs by pattern
SELECT event_time, query_id, query, type
FROM clusterAllReplicas(default, merge('system', '^query_log*'))
WHERE query ILIKE '%some_table%'
AND event_time > now() - INTERVAL 5 MINUTE
-- Debug a specific query across all nodes
SELECT hostname(), message
FROM clusterAllReplicas(default, system.text_log)
WHERE query_id = 'your-query-id-here'
ORDER BY event_time_microseconds ASC
| Use Case | Function |
| --------------------------------------------- | ----------------------------------------------------------- |
| System tables (query_log, text_log, etc.) | clusterAllReplicas(default, system.table_name) |
| Application tables (views, modelEvents, etc.) | Direct query (already distributed) |
| Search multiple system tables | clusterAllReplicas(default, merge('system', '^pattern*')) |
-- Use count() not COUNT(*)
SELECT count() FROM views
-- Date filtering with toDate()
SELECT * FROM views WHERE toDate(time) = today()
-- Last 7 days
SELECT * FROM modelEvents WHERE time > now() - INTERVAL 7 DAY
-- Aggregations
SELECT type, count() as cnt FROM modelEvents GROUP BY type ORDER BY cnt DESC
tools
<!--VITE PLUS START--> # Using Vite+, the Unified Toolchain for the Web This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, but it invokes Vite through `vp dev` and `vp build`. ## Vite+ Workflow `vp` is a global binary that handles the full development lifecycle. Run `vp help` to pr
development
Guide for building performant data tables. Uses tanstack-table for table logic (sorting, filtering, pagination) and tanstack-virtual for rendering large datasets efficiently.
development
Expert guidance for building observable, expressive, and fault-tolerant TypeScript applications using the effect-ts/effect ecosystem. Covers Effect<A, E, R> type, error management, dependency injection via Layers, observability (logging, metrics, tracing), concurrency with Fibers, retry/scheduling, Schema validation, Streams, and Sinks.
tools
Complete E2E (end-to-end) and integration testing skill for TypeScript/NestJS projects using Jest, real infrastructure via Docker, and GWT pattern. ALWAYS use this skill when user needs to: **SETUP** - Initialize or configure E2E testing infrastructure: - Set up E2E testing for a new project - Configure docker-compose for testing (Kafka, PostgreSQL, MongoDB, Redis) - Create jest-e2e.config.ts or E2E Jest configuration - Set up test helpers for database, Kafka, or Redis - Configure .env.e2e environment variables - Create test/e2e directory structure **WRITE** - Create or add E2E/integration tests: - Write, create, add, or generate e2e tests or integration tests - Test API endpoints, workflows, or complete features end-to-end - Test with real databases, message brokers, or external services - Test Kafka consumers/producers, event-driven workflows - Working on any file ending in .e2e-spec.ts or in test/e2e/ directory - Use GWT (Given-When-Then) pattern for tests **REVIEW** - Audit or evaluate E2E tests: - Review existing E2E tests for quality - Check test isolation and cleanup patterns - Audit GWT pattern compliance - Evaluate assertion quality and specificity - Check for anti-patterns (multiple WHEN actions, conditional assertions) **RUN** - Execute or analyze E2E test results: - Run E2E tests - Start/stop Docker infrastructure for testing - Analyze E2E test results - Verify Docker services are healthy - Interpret test output and failures **DEBUG** - Fix failing or flaky E2E tests: - Fix failing E2E tests - Debug flaky tests or test isolation issues - Troubleshoot connection errors (database, Kafka, Redis) - Fix timeout issues or async operation failures - Diagnose race conditions or state leakage - Debug Kafka message consumption issues **OPTIMIZE** - Improve E2E test performance: - Speed up slow E2E tests - Optimize Docker infrastructure startup - Replace fixed waits with smart polling - Reduce beforeEach cleanup time - Improve test parallelization where safe Keywords: e2e, end-to-end, integration test, e2e-spec.ts, test/e2e, Jest, supertest, NestJS, Kafka, Redpanda, PostgreSQL, MongoDB, Redis, docker-compose, GWT pattern, Given-When-Then, real infrastructure, test isolation, flaky test, MSW, nock, waitForMessages, fix e2e, debug e2e, run e2e, review e2e, optimize e2e, setup e2e