npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@housekit/kit

v0.1.44

Published

CLI tool for HouseKit - manage ClickHouse schemas, migrations, and database operations with type-safe workflows.

Readme

HouseKit CLI 🏠⚡️

The modern schema management tool for ClickHouse.

⚠️ Public Beta: HouseKit CLI is currently in public beta. We are actively refining the migration engine and cluster management features.

💡 Interactive Docs: Use RepoGrep to search and query the entire codebase and documentation for free (Updated instantly).

💡 Ask ZRead: Need deep insights? Ask ZRead for AI-powered understanding of the codebase (Updated weekly).

💡 Ask Devin AI: Have questions about integrating HouseKit? Ask the Wiki for AI-powered assistance (Updated weekly).

HouseKit CLI brings a modern, streamlined developer experience to the ClickHouse ecosystem. Manage your sharded clusters, analytical tables, and complex materialized views using purely TypeScript—no more manual SQL migration files or structural drift.

npm version License: MIT Documentation zread Documentation Documentation

npm


🚀 Why HouseKit CLI?

  • Declarative Workflows: Define your source of truth in TypeScript.
  • Automatic Drift Detection: Compares your code against the live DB schema instantly.
  • Engine-Aware Diffing: Normalizes local engine objects vs. remote SQL to avoid false changes.
  • Blue-Green Deployments: Safe, zero-downtime structural changes for Materialized Views and Tables.
  • Cluster Awareness: First-class support for sharded clusters using {cluster} macros and sharding keys.
  • Zero Runtime Dependencies: Powered by jiti for native TS loading—no pre-compilation or heavy binaries required.

🛠 Installation

# Recommended: install as a dev dependency
npm install -D @housekit/kit @housekit/orm
# or
bun add -D @housekit/kit @housekit/orm

📖 The Two Workflows

HouseKit supports two distinct ways of working depending on your environment.

1. Rapid Development: housekit push

Perfect for early-stage projects or local development. It computes the delta between your TS files and the database and applies it immediately.

  • Safe: Asks for confirmation before any destructive change.
  • Fast: Skips the creation of migration files.
  • Smart: Handles column renames and type changes.
  • CI/CD Ready: Use -y flag or pipe commands for non-interactive mode.

2. Controlled Production: housekit generate & migrate

The standard for CI/CD and production environments.

  • Generate: Compares your code against a snapshot.json and creates a timestamped .sql file in your migrations folder.
  • Migrate: Executes pending SQL files against the target database, tracking history in system.migrations.

💻 Commands

| Command | Description | | :--- | :--- | | init | Bootstraps a new HouseKit project with config and folder structure. | | push | Syncs local schema directly to the database. Supports --log-explain. | | generate | Creates a new SQL migration file based on schema changes. | | migrate | Applies pending SQL migrations to the database. | | pull | Introspection: Connects to a DB and generates typed TS schema files. | | schema | Prints a beautiful, color-coded summary of your tables and types. | | status | Lists all detected differences between your code and the database. | | validate | Checks if code and DB are in sync (exit code 1 on drift). Great for CI. | | list | Summarizes row counts, engines, and sizes for all tables. | | reset | Wipes the database and restarts from your code schema (Dev only). |

Global Options

| Option | Description | | :--- | :--- | | -y, --yes | Auto-confirm all prompts (useful for CI/CD and scripts). | | -d, --database <name> | Target a specific database from your config. |

Non-Interactive Mode

When running in non-interactive environments (CI/CD pipelines, scripts with piped input), HouseKit automatically detects this and uses default values for prompts. For explicit control, use the -y flag:

# Auto-confirm all prompts
bunx housekit push -y

# Works in CI/CD pipelines
bunx housekit migrate -y --database production

⚙️ Configuration

Create a housekit.config.ts (or .js, .mjs) in your project root.

import type { HouseKitConfig } from '@housekit/kit';

export default {
  schema: './src/schema', // Where your table definitions live
  
  // Where migrations and snapshots will be stored
  out: './housekit',
  
  // Multi-database support
  databases: {
    default: {
      host: 'localhost',
      port: 8123,
      database: 'analytics_dev',
      username: 'default',
      password: process.env.CLICKHOUSE_PASSWORD || '',
    },
    production: {
      url: process.env.CLICKHOUSE_PROD_URL,
      database: 'analytics_prod',
    }
  }
} satisfies HouseKitConfig;

🏗 Advanced Usage

Working with Clusters

HouseKit simplifies managing Replicated and Distributed tables across a cluster.

import { defineTable, t, Engine } from '@housekit/orm';

// Define a table that lives on a cluster (object syntax still supported)
export const events = defineTable('events', {
  id: t.uuid('id').primaryKey(),
  userId: t.uuid('user_id'),
  createdAt: t.timestamp('created_at').default('now()'),
}, {
  engine: Engine.ReplicatedMergeTree(),
  
  // High Portability: Using '{cluster}' tells ClickHouse to use the 
  // cluster name defined in the server's configuration macros.
  // This allows the same code to run on 'dev_cluster', 'prod_cluster', etc.
  onCluster: '{cluster}', 
  
  shardKey: 'user_id',
  orderBy: 'id'
});

// Callback syntax is also available when you want presets or composition:
// defineTable('events', (t) => ({ ... }), { ... })

When you run housekit push, the CLI automatically detects the cluster configuration and executes the ALTER or CREATE statements across all nodes using the specified macro.

Safe Materialized View Updates

ClickHouse doesn't allow ALTER on Materialized View queries. HouseKit solves this via Blue-Green Deployments:

  1. Creates a __shadow table with the new query.
  2. Swaps the names atomically using RENAME.
  3. Ensures zero data loss during the transition.

Database Introspection (pull)

Have an existing database with 100 tables? Don't write the code by hand.

bunx housekit pull --database production

This will scan your ClickHouse instance and generate a clean, readable schema.ts file with all table definitions, engines, and settings preserved. Engine strings from ClickHouse are stored as customEngine to guarantee a lossless round-trip.


🛡 Security & Best Practices

  • Credentials: Never hardcode passwords. Use process.env.
  • Read-Only Mode: In housekit.config.ts, you can mark databases as readOnly: true to prevent accidental push or migrate calls.
  • Validation: Add housekit validate to your CI pipeline to ensure no developer forgot to generate a migration before merging.

License

MIT © Pablo Fernandez Ruiz