This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
All commands must be run from a module directory (e.g., cd kvcodec).
# Run all tests (unit + integration) for a module
go test -v -count=1 ./...
go test -v -count=1 ./test/...
# Run specific test
go test -v -run TestSpecificFunction
# Combined coverage
go test ./... -coverprofile=coverage.out && go tool cover -html=coverage.out# Full lint suite (matches CI)
go fmt ./...
go vet ./...
go vet ./test/...
staticcheck ./...
staticcheck ./test/...
find . -type f -name "*.go" | xargs misspell -error -locale USRequires staticcheck and misspell:
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/client9/misspell/cmd/misspell@latestgo mod tidyMulti-module Go repository. Each module is an independent Go module with:
go.mod/go.sumfor dependenciesgo.workworkspace linking the module and./testsubdirectorytest/subdirectory with separatego.modfor integration tests (isolates heavy deps like NATS server)- CI workflow in
.github/workflows/
- kvcodec — Transparent encoding/decoding wrapper for NATS JetStream KeyValue stores (Base64, AES, Path codecs with wildcard support)
- jetstreamext — JetStream extensions: GetBatch, GetLastMsgs, BatchPublisher, FastPublisher
- natsext — Core NATS extensions: RequestMany (scatter-gather with iterators)
- natssysclient — System API client for monitoring NATS servers (VARZ, CONNZ, etc.)
- natscontext — Context propagation and dialer utilities for NATS connections
- counters — Distributed counter using JetStream message counting
- pcgroups — Partitioned consumer groups (elastic/static/base)
- Each module follows independent versioning
- Test modules use
replacedirectives pointing to local module (..) - CI runs lint and test jobs independently per module
- Integration tests use an embedded in-memory NATS server
- Always use modern
for i := range nsyntax instead offor i := 0; i < n; i++where applicable - Use exported
varblocks for sentinel errors in a dedicatederrors.gofile (see kvcodec, jetstreamext, counters for examples) - Always use
errors.Is()when comparing errors in tests - Imports: stdlib first, blank line, then third-party — alphabetical within each group
- Functional options pattern:
With...()(e.g.,WithFastPublisherErrorHandler())