cockroachdb/cockroach
Tooling
CockroachDB ships an unusual amount of in-repo tooling. The most important pieces:
./dev and Bazel
./dev (source: pkg/cmd/dev/) is the primary command-line interface for everything build-related. It is a thin wrapper around Bazel that adds aliases, fixes UX rough edges, and lifts artifacts out of Bazel's output tree.
| Command | Purpose |
|---|---|
./dev doctor |
Validate the local environment |
./dev build / ./dev build short |
Build the cockroach binary |
./dev test pkg/... |
Run unit tests |
./dev testlogic |
Run SQL logic tests |
./dev gen go / ./dev gen bazel / ./dev gen |
Code generation |
./dev lint --short |
Run the linters |
Bazel rules live next to Go code as BUILD.bazel. Gazelle (./dev gen bazel) keeps them in sync with imports. The dependency manifest is DEPS.bzl (~580 KB), regenerated whenever vendored deps change.
crlfmt
The CRDB-specific Go formatter, source under pkg/cmd/. It enforces 100-column code, 80-column comments, and CRDB import grouping. Run crlfmt -w -tab 2 path.go per-file before pushing.
Code generation
CockroachDB generates a lot of Go code at build time. Examples:
- Protobuf — every
.protoproduces*.pb.goviaprotoc-gen-gogoroach(pkg/cmd/protoc-gen-gogoroach). - DRPC — every service produces a DRPC variant via
pkg/cmd/protoc-gen-go-drpc. - Optgen —
.optfiles inpkg/sql/opt/norm/rules/andpkg/sql/opt/xform/rules/compile to Go throughpkg/sql/opt/optgen/. - Stringer /
enumstringer— typed enums get string serialization helpers. - execgen — vectorized engine code is templated through
pkg/sql/colexec/execgen/. - Mocks — interfaces for testing are mocked via
mockgen. - SQL grammar —
pkg/sql/parser/sql.ycompiled bygoyacc. - Schema migrations — bootstrap data in
pkg/cmd/sql-bootstrap-data/andpkg/sql/catalog/bootstrap/.
./dev gen regenerates everything; per-target invocations (./dev gen protobuf, ./dev gen go) are faster.
Dev binaries (pkg/cmd/)
The pkg/cmd/ directory contains ~70 distinct command-line tools. Notable ones:
| Tool | What it does |
|---|---|
roachprod |
Provision and manage cloud-hosted CockroachDB clusters for testing. |
roachtest |
Long-running distributed system tests against roachprod-managed clusters. |
workload |
Synthetic SQL workload generator (TPC-C, KV, ycsb, etc.). |
roachvet |
CockroachDB-specific Go vet checks. |
dev |
The build wrapper described above. |
release |
Release engineering automation. |
roachprod-microbench |
Cross-revision performance benchmarks. |
microbench-ci |
The CI side of microbenchmarks. |
whoownsit |
Identify owning team for a path via .github/CODEOWNERS. |
urlcheck |
Validate URLs in markdown docs. |
github-post, github-pull-request-make |
CI ↔ GitHub integration. |
bazci |
Adapter that runs Bazel inside CI. |
Many of these tools are themselves substantial CockroachDB-internal projects.
Linters
The lint suite combines golangci-lint, staticcheck, and CRDB-specific lint rules in pkg/testutils/lint/. It enforces things like:
WrapfoverWrap/fmt.Errorffor error wrapping.- No raw
time.Now()in non-clock code. - No
panicoutside startup paths. - Reasonable use of
context.Context. - Forbidden imports between layers (e.g.,
pkg/storagecannot depend onpkg/sql).
./dev lint --short runs a fast subset; ./dev lint runs the full set.
Skill scripts
The repo's CLAUDE.md lists three Cockroach-Labs-specific Claude Code skills:
/commit-helper— generates commit and PR messages with release-note annotations./file-crdb-issue— files GitHub issues using the CRDB templates./review-crdb— reviews PRs for correctness and reviewability.
External contributors can ignore these; they are wired up to internal Cockroach Labs workflows.
CI
CI is driven from .github/workflows/ (lighter checks like CLA, codeowners, lint) and TeamCity (the heavy lifting: full test suite, race, stress, roachtests, mixed-version, …). The .github/ directory also holds CODEOWNERS for review routing and issue templates for filing bugs.
The merge bot is craig[bot]. PRs land via /trunk merge rather than the GitHub merge button. The bot rebases, re-runs CI, and only merges if green.
Pre-commit hook
CockroachDB ships a pre-commit crlfmt hook in githooks/ (must be installed manually with git config core.hooksPath githooks). It runs crlfmt on staged files.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.