# Clickhouse Js Node Rowbinary > Generate TypeScript/JavaScript code that reads/decodes AND writes/encodes ClickHouse RowBinary streams for the ClickHouse HTTP server. Use this skill whenever a user wants to parse or produce `RowBinary`, `RowBinaryWithNames`, or `RowBinaryWithNamesAndTypes`. Node.js only, doesn't cover browsers. Fuente: https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-rowbinary Markdown: https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-rowbinary.md Repositorio: https://github.com/ClickHouse/agent-skills Autor: ClickHouse Licencia: Apache-2.0 Actualizado: hace 19 días Coste de contexto: 74 tok instalada, 1.3k tok al activarse, 174.4k tok con todos los archivos del bundle Bundle: 193 archivos, 681 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add ClickHouse/agent-skills --skill clickhouse-js-node-rowbinary --agent claude-code # Cursor npx -y skills add ClickHouse/agent-skills --skill clickhouse-js-node-rowbinary --agent cursor # Codex npx -y skills add ClickHouse/agent-skills --skill clickhouse-js-node-rowbinary --agent codex # Gemini CLI npx -y skills add ClickHouse/agent-skills --skill clickhouse-js-node-rowbinary --agent gemini # Windsurf npx -y skills add ClickHouse/agent-skills --skill clickhouse-js-node-rowbinary --agent windsurf # Cline npx -y skills add ClickHouse/agent-skills --skill clickhouse-js-node-rowbinary --agent cline ``` ## Archivos - .gitignore — 106 B - AGENTS.md — 3 KB - CHANGELOG.md — 3 KB - EXAMPLES.md — 6 KB - README.md — 15 KB - SKILL.md — 5 KB - case-studies/iot-rowbinary-vs-json.md — 4 KB - case-studies/ledger-rowbinary-vs-json.md — 5 KB - case-studies/logs-json-wins.md — 4 KB - case-studies/wasm-vs-js.md — 10 KB - eval_result.md — 6 KB - eval_result_composer.md — 8 KB - eval_result_haiku.md — 9 KB - eval_result_sonnet.md — 6 KB - package-lock.json — 43 KB - package.json — 2 KB - reader.md — 15 KB - src/examples/carts.ts — 3 KB - src/examples/events.ts — 2 KB - src/examples/iot.ts — 6 KB - src/examples/ledger.ts — 4 KB - src/examples/logs.ts — 3 KB - src/examples/observability.ts — 5 KB - src/examples/orders.ts — 3 KB - src/examples/profiles.ts — 2 KB - src/examples/telemetry.ts — 3 KB - src/readers/aggregateFunction.ts — 2 KB - src/readers/bool.ts — 282 B - src/readers/columnar.ts — 6 KB - src/readers/compile.ts — 11 KB - src/readers/composite.ts — 7 KB - src/readers/core.ts — 3 KB - src/readers/datetime.ts — 4 KB - src/readers/decimals.ts — 2 KB - src/readers/dynamic.ts — 12 KB - src/readers/enums.ts — 2 KB - src/readers/floats.ts — 1 KB - src/readers/geo.ts — 4 KB - src/readers/header.ts — 1 KB - src/readers/integers.ts — 3 KB - src/readers/interval.ts — 2 KB - src/readers/ip.ts — 3 KB - src/readers/json.ts — 1 KB - src/readers/lowCardinality.ts — 750 B - src/readers/nested.ts — 1 KB - src/readers/nothing.ts — 1 KB - src/readers/reader.ts — 3 KB - src/readers/rowBinaryWithNamesAndTypes.ts — 7 KB - src/readers/rows.ts — 2 KB - src/readers/simpleAggregateFunction.ts — 797 B - src/readers/stream.ts — 12 KB - src/readers/strings.ts — 2 KB - src/readers/time.ts — 2 KB - src/readers/uuid.ts — 6 KB - src/readers/varint.ts — 3 KB - src/writers/aggregateFunction.ts — 796 B - src/writers/bool.ts — 285 B - src/writers/composite.ts — 5 KB - src/writers/core.ts — 4 KB - src/writers/datetime.ts — 5 KB - src/writers/decimals.ts — 2 KB - src/writers/enums.ts — 580 B - src/writers/floats.ts — 2 KB - src/writers/geo.ts — 5 KB - src/writers/integers.ts — 4 KB - src/writers/interval.ts — 463 B - src/writers/ip.ts — 4 KB - src/writers/lowCardinality.ts — 454 B - src/writers/nested.ts — 776 B - src/writers/nothing.ts — 941 B - src/writers/rows.ts — 7 KB - src/writers/simpleAggregateFunction.ts — 434 B - src/writers/strings.ts — 3 KB - src/writers/time.ts — 2 KB - src/writers/uuid.ts — 2 KB - src/writers/varint.ts — 2 KB - src/writers/writer.ts — 3 KB - tests/AggregateFunction.write.test.ts — 411 B - tests/Array.test.ts — 2 KB - tests/BFloat16.test.ts — 1 KB - tests/Bool.test.ts — 1 KB - tests/BoolEnumFloat.write.test.ts — 4 KB - tests/Composite.write.test.ts — 3 KB - tests/Date.test.ts — 1 KB - tests/Date32.test.ts — 1 KB - tests/DateTime.test.ts — 1 KB - tests/DateTime.write.test.ts — 3 KB - tests/DateTime64.test.ts — 2 KB - tests/DateTime64P3.test.ts — 1 KB - tests/DateTime64P6.test.ts — 1 KB - tests/DateTime64P9.test.ts — 1 KB - tests/Decimal.write.test.ts — 3 KB - tests/Decimal128.test.ts — 2 KB - tests/Decimal256.test.ts — 2 KB - tests/Decimal32.test.ts — 2 KB - tests/Decimal64.test.ts — 2 KB - tests/Dynamic.test.ts — 13 KB - tests/Enum16.test.ts — 2 KB - tests/Enum8.test.ts — 2 KB - tests/FixedString.test.ts — 1 KB - tests/FixedStringBytes.test.ts — 1 KB - tests/Float32.test.ts — 1 KB - tests/Float64.test.ts — 1 KB - tests/Geo.write.test.ts — 3 KB - tests/Geometry.test.ts — 2 KB - tests/IP.write.test.ts — 3 KB - tests/IPv4.test.ts — 2 KB - tests/IPv6.test.ts — 2 KB - tests/Int128.test.ts — 2 KB - tests/Int16.test.ts — 2 KB - tests/Int256.test.ts — 2 KB - tests/Int32.test.ts — 1 KB - tests/Int64.test.ts — 1 KB - tests/Int8.test.ts — 1 KB - tests/Integers.write.test.ts — 5 KB - tests/Interval.test.ts — 1 KB - tests/JSON.test.ts — 4 KB - tests/LineString.test.ts — 1 KB - tests/Map.test.ts — 2 KB - tests/MultiLineString.test.ts — 1 KB - tests/MultiPolygon.test.ts — 1 KB - tests/Nothing.write.test.ts — 810 B - tests/Nullable.test.ts — 2 KB - tests/Point.test.ts — 1 KB - tests/Polygon.test.ts — 1 KB - tests/Ring.test.ts — 1 KB - tests/Rows.write.test.ts — 8 KB - tests/String.test.ts — 2 KB - tests/String.write.test.ts — 2 KB - tests/Time.test.ts — 2 KB - tests/Time64.test.ts — 2 KB - tests/TimeInterval.write.test.ts — 2 KB - tests/Tuple.test.ts — 2 KB - tests/TupleNamed.test.ts — 2 KB - tests/UInt128.test.ts — 1 KB - tests/UInt16.test.ts — 1 KB - tests/UInt256.test.ts — 2 KB - tests/UInt32.test.ts — 1 KB - tests/UInt64.test.ts — 1 KB - tests/UInt8.test.ts — 1 KB - tests/UUID.test.ts — 4 KB - tests/UUID.write.test.ts — 2 KB - tests/UUIDBigInt.test.ts — 2 KB - tests/UUIDHiLo.test.ts — 2 KB - tests/UVarint.test.ts — 4 KB - tests/UVarint.write.test.ts — 2 KB - tests/Variant.test.ts — 3 KB - tests/advance.test.ts — 3 KB - tests/aggregateFunction.test.ts — 4 KB - tests/carts.bench.ts — 2 KB - tests/carts.example.test.ts — 2 KB - tests/clickhouse.ts — 1 KB - tests/coalesceChunks.test.ts — 5 KB - tests/columnar.test.ts — 6 KB - tests/combinations.generated.test.ts — 9 KB - tests/compile.test.ts — 4 KB - tests/encode.ts — 842 B - tests/events.bench.ts — 2 KB - tests/events.example.test.ts — 2 KB - tests/framing-interleaved.test.ts — 11 KB - tests/framing-nested.test.ts — 12 KB - tests/framing.test.ts — 19 KB - tests/iot.bench.ts — 5 KB - tests/iot.columnar.bench.ts — 2 KB - tests/iot.wasm-headroom.bench.ts — 5 KB - tests/ledger.bench.ts — 8 KB - tests/logs.bench.ts — 4 KB - tests/lowCardinality.test.ts — 2 KB - tests/nested.test.ts — 2 KB - tests/nothing.test.ts — 3 KB - tests/observability.bench.ts — 2 KB - tests/observability.example.test.ts — 4 KB - tests/orders.bench.ts — 2 KB - tests/orders.example.test.ts — 2 KB - tests/parseIP.bench.ts — 1 KB - tests/profiles.bench.ts — 2 KB - tests/profiles.example.test.ts — 2 KB - tests/qbit.test.ts — 3 KB - tests/readHeader.test.ts — 864 B - tests/readUUID.bench.ts — 1 KB - tests/rowBinaryWithNamesAndTypes.order.test.ts — 3 KB - tests/rowBinaryWithNamesAndTypes.test.ts — 19 KB - tests/rows.test.ts — 8 KB - tests/simpleAggregateFunction.test.ts — 2 KB - tests/streamRowBatches.test.ts — 6 KB - tests/streamingRow.bench.ts — 8 KB - tests/telemetry.bench.ts — 2 KB - tests/telemetry.example.test.ts — 2 KB - tests/wasm-int128.experiment.mjs — 7 KB - tsconfig.build.json — 306 B - tsconfig.json — 476 B - vitest.config.ts — 216 B - writer.md — 7 KB ## SKILL.md Reproducido tal cual desde ClickHouse/agent-skills bajo Apache-2.0. Esta sección es el documento original y está en inglés. # ClickHouse JS RowBinary Codec Generator for Node.js This skill generates both directions of the wire format: **readers** (decode bytes → values) and **writers** (encode values → bytes, the mirror). A given task normally needs only one side. This file is the shared entry point — the format gate plus the principles common to both directions; the per-direction decisions, guidance, and the per-type reference tables live in two sibling files. **Pick your side — read only the one you need:** - **Decoding a `RowBinary*` response** from ClickHouse into JS values → **[reader.md](reader.md)**. Streaming vs whole-buffer, row-objects vs columnar, fixed vs runtime schema, and the per-type reader reference. - **Encoding JS values into a `RowBinary` payload** to send to ClickHouse → **[writer.md](writer.md)**. The `Sink`/`writeX` building blocks, `writeRows` streaming, and the per-type writer reference. The per-type code is real, split by direction under `src/readers/` and `src/writers/`. ## First: is RowBinary even the right format? RowBinary exists for throughput, but it is **not automatically the fastest path** — match the format to the shape of the data before committing to a bespoke parser. **Prefer a `JSON*` format (e.g. `JSONEachRow`) when** the result is mostly strings / JSON-like values that you consume wholesale — randomly accessing essentially every field, running string/regexp methods on them, treating values as text. V8's native `JSON.parse` is heavily optimized C++ and builds JS strings and objects faster than a JS-level RowBinary decoder can; pair it with HTTP response compression (`gzip` / `zstd`, which crushes JSON's repetitive keys) and the wire cost shrinks too. **RowBinary clearly wins when** the result is dominated by: - **Wide numerics** — `Int128`/`Int256`/`UInt128`/`UInt256`, `Decimal128`/`Decimal256`. - **Binary / fixed-width blobs** — `IPv4`, `IPv6`, `UUID`, `FixedString`. - **High-volume fixed-width numeric columns** generally, where each value is a single `DataView` read. **Prefer the `Native` format when** columnar load and client-side analytics are the main goal (fold/scan/filter columns, feed typed arrays to a Worker or WASM). `Native` is column-major, so it loads straight into one typed array per column with no transpose. For help choosing and consuming a `JSON*` format (or CSV / TSV) instead, use the **`clickhouse-js-node-coding`** skill. ## Core guidance (both directions) These principles apply whether you are generating a reader or a writer; the side-specific operational guidance is in [reader.md](reader.md) / [writer.md](writer.md). - **Little-endian only.** RowBinary is little-endian; target x86/ARM. Read and write every multi-byte number with `DataView` accessors passing a **literal** `true` for the `littleEndian` flag. - **Correct first, then optimize.** First emit a correct codec built from the plain per-type API. Only after it's correct (and tested) specialize it. Don't bake performance assumptions in before correctness. - **Monomorphize generic/composite types.** Emit specialized, inlined code per type combination instead of passing functions as arguments where the type is known ahead of time. - **Inline the leaf ops.** The per-type `readX`/`writeX` functions are the correct, composable reference; the generated codec should INLINE their bodies, not call them, so the row loop is straight-line with no per-field indirection (and so the fixed-width coalescing can fold the offset arithmetic together). - **Annotate the type per column.** Inlining erases the type structure, so put a short comment above each column's encode/decode block naming the ClickHouse type it handles. - **Shared scratch is not reentrant.** Some hot methods reuse a module-level scratch buffer as a write-then-read pair — correct only because the access is fully synchronous. An `async`/`yield` boundary between populating and reading it corrupts the value. - **TypeScript by default.** Generate TypeScript code and helpers unless the user explicitly asks for plain JavaScript. ## Worked examples Six end-to-end examples with real speedup are catalogued in [EXAMPLES.md](EXAMPLES.md). ## Out of scope - **JSON / CSV / TSV / Parquet parsing** → use `clickhouse-js-node-coding`. - **Connection errors, hangs, type mismatches** → use `clickhouse-js-node-troubleshooting`. - **Browser / Web Worker / Edge** → `@clickhouse/client-web`. ## Still Stuck? - [ClickHouse RowBinary format](https://clickhouse.com/docs/interfaces/formats#rowbinary) - [ClickHouse data types](https://clickhouse.com/docs/sql-reference/data-types) - [ClickHouse JS client docs](https://clickhouse.com/docs/integrations/javascript) ## Dónde encaja - Categoría: [Bases de datos](https://skillsagentes.com/categorias/bases-de-datos.md) — Diseño de esquemas, migraciones y optimización de consultas. - Creador: [ClickHouse](https://skillsagentes.com/creators/clickhouse.md) — 11 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Infra Postgres](https://skillsagentes.com/skills/clickhouse/agent-skills/infra-postgres.md): Sets up and manages Postgres using the clickhousectl CLI — runs a local Docker-backed Postgres for development, and creates and operates managed ClickHouse Cloud Postgres services (connections, TLS, runtime config, read replicas, failover, point-in-time restore). Use when the user wants a Postgres or PostgreSQL database for their application, a local Postgres dev environment, psql access, or a managed/production Postgres in ClickHouse Cloud, or mentions moving a local Postgres to production. - [Infra Clickhouse](https://skillsagentes.com/skills/clickhouse/agent-skills/infra-clickhouse.md): Sets up and manages ClickHouse using the clickhousectl CLI — installs and runs a local ClickHouse server for development, and creates managed ClickHouse Cloud services for production (authentication, service creation, schema migration, application connection). Use when the user wants to build an application with ClickHouse, set up a local ClickHouse dev environment, create tables and start querying, deploy ClickHouse to production or ClickHouse Cloud, or migrate from a local setup to the cloud. - [Clickstack Otel Collector](https://skillsagentes.com/skills/clickhouse/agent-skills/clickstack-otel-collector.md): Use when a user wants to wire an OpenTelemetry collector into a Managed ClickStack service on ClickHouse Cloud, either by deploying a new local collector (Docker run or Docker Compose) or by configuring their own existing collector, then send rich synthetic telemetry and verify it is visible in ClickStack. - [Clickhouse Js Node Troubleshooting](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-troubleshooting.md): Troubleshoot and resolve common issues with the ClickHouse Node.js client (@clickhouse/client). Use this skill whenever a user reports errors, unexpected behavior, or configuration questions involving the Node.js client specifically — including socket hang-up errors, Keep-Alive problems, stream handling issues, data type mismatches, read-only user restrictions, proxy/TLS setup problems, or long-running query timeouts. Trigger even when the user hasn't precisely named the issue; vague symptoms like "my inserts keep failing" or "connection drops randomly" in a Node.js context are strong signals to use this skill. Do NOT use for browser/Web client issues. - [Clickhouse Js Node Coding](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-coding.md): Write idiomatic application code with the ClickHouse Node.js client (`@clickhouse/client`). Use this skill whenever a user is *building* against the Node.js client — configuring the client, pinging, inserting rows in JSON or raw formats, selecting and parsing results, binding query parameters, managing sessions and temporary tables, working with data types or customizing JSON parsing. Do NOT use for browser/Web client code. ## Skills relacionadas - [Chdb Datastore](https://skillsagentes.com/skills/clickhouse/agent-skills/chdb-datastore.md): Use when the user has tabular data (pandas DataFrame, parquet, csv, Arrow, json) and wants to filter, group, aggregate, join, or speed up slow pandas. Provides chDB DataStore — same pandas API, ClickHouse engine underneath. Also handles reading from S3, MySQL, PostgreSQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake as DataFrames and joining across sources. TRIGGER when: user mentions DataFrame, parquet, csv, "fast pandas", "speed up pandas", or cross-source DataFrame joins; user imports `chdb.datastore` or `from datastore import DataStore`. SKIP this skill for raw SQL syntax (use chdb-sql instead), ClickHouse server administration, or non-Python DataStore API work. - [Chdb Sql](https://skillsagentes.com/skills/clickhouse/agent-skills/chdb-sql.md): Use when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake) without setting up a server. Provides chDB — embedded ClickHouse SQL in Python with 1000+ functions, Session for stateful multi-step pipelines, parametrized queries, and cross-source joins via `s3()`, `mysql()`, `postgresql()`, `iceberg()`, `deltaLake()`, `remoteSecure()` table functions. TRIGGER when: user wants SQL on parquet/csv/files or across remote analytical sources; uses ClickHouse SQL features (window functions, windowFunnel, geoToH3, JSON path ops, Session, parametrized queries); imports `chdb` or calls `chdb.query()`. SKIP this skill for pandas-style DataFrame method-chaining (use chdb-datastore instead) or ClickHouse server administration. - [Clickhouse Architecture Advisor](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-architecture-advisor.md): MUST USE when designing ClickHouse architectures, selecting between ingestion or modeling patterns, or translating best practices into workload-specific system designs. Complements clickhouse-best-practices with decision frameworks and explicit provenance labels. - [Clickhouse Best Practices](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-best-practices.md): MUST USE when reviewing ClickHouse schemas, queries, or configurations. Contains 31 rules that MUST be checked before providing recommendations. Always read relevant rule files and cite specific rules in responses. - [Clickhouse Js Node Coding](https://skillsagentes.com/skills/clickhouse/agent-skills/clickhouse-js-node-coding.md): Write idiomatic application code with the ClickHouse Node.js client (`@clickhouse/client`). Use this skill whenever a user is *building* against the Node.js client — configuring the client, pinging, inserting rows in JSON or raw formats, selecting and parsing results, binding query parameters, managing sessions and temporary tables, working with data types or customizing JSON parsing. Do NOT use for browser/Web client code. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)