This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
KubernetesJS is a monorepo providing a fully-typed, zero-dependency TypeScript client for the entire Kubernetes API, plus React hooks, CLIs, and operational tooling. Code is generated from the Kubernetes OpenAPI spec using schema-sdk.
- This repo: https://deepwiki.com/constructive-io/kubernetesjs
- Kubernetes client-go (reference Go client): https://deepwiki.com/kubernetes/client-go
# Install dependencies
pnpm install
# Build all packages (excludes ops-dashboard)
pnpm build
# Build everything including apps
pnpm build:all
# Lint all packages (uses eslint --fix)
pnpm lint
# Build a specific package
pnpm --filter kubernetesjs build
pnpm --filter @kubernetesjs/react build
# Run tests in a specific package
cd packages/kubernetesjs && pnpm test
cd packages/kubernetesjs && pnpm test:watch
# Run a single test file
cd packages/kubernetesjs && npx jest path/to/test.ts
# Regenerate TypeScript client from Kubernetes OpenAPI spec
cd packages/kubernetesjs && pnpm codegen
cd packages/react && pnpm codegen
# Kubernetes API proxy (required for integration tests and local dev)
kubectl proxy --port=8001 --accept-hosts='^.*$' --address='0.0.0.0'- pnpm workspaces with
packages/*andapps/* - Lerna for independent versioning and publishing
- makage as the build tool (generates CJS + ESM dual output to
dist/)
| Package | npm name | Description |
|---|---|---|
packages/kubernetesjs |
kubernetesjs |
Core zero-dependency K8s client |
packages/react |
@kubernetesjs/react |
React hooks with TanStack Query |
packages/cli |
@kubernetesjs/cli |
CLI tool (k8s / kubernetes commands) |
packages/client |
@kubernetesjs/client |
Enhanced client wrapper |
packages/ops |
@kubernetesjs/ops |
Ops library |
packages/ops-cli |
@kubernetesjs/ops-cli |
High-level ops CLI |
packages/manifests |
@kubernetesjs/manifests |
Curated operator manifests |
apps/ops-dashboard |
private | Next.js dashboard UI |
The core kubernetesjs and @kubernetesjs/react packages have their source generated from the Kubernetes OpenAPI spec (swagger.json). The codegen scripts in packages/*/scripts/codegen.ts use schema-sdk to produce src/index.ts. Do not manually edit generated src/index.ts files in these packages — modify the codegen scripts or swagger.json instead.
Key codegen configuration:
- Excludes beta APIs (
v1beta1,v2beta1) and flowcontrol resources - Uses
namingStrategy.renameMapto resolve type name conflicts (e.g.,EndpointPort,ServiceReference) - Patches
IntOrStringto a properoneOfunion type
KubernetesClient takes { restEndpoint: string } and provides typed methods for all K8s API operations (list, get, create, update, patch, delete, watch). The core package has zero runtime dependencies by design.
@kubernetesjs/react wraps the client in a React Context (KubernetesProvider) with TanStack Query for caching/fetching. Generated hooks follow the pattern use{OperationName}Query / use{OperationName}Mutation.
Packages reference each other via workspace:^ in package.json. The core kubernetesjs package is depended on by react, cli, client, ops, and manifests.
- ESLint with
@typescript-eslint,simple-import-sort,unused-imports, and Prettier integration - Prettier: double quotes, trailing commas (es5), 2-space indent, semicolons
- ESLint enforces: single quotes in JS/TS source (note: Prettier uses double quotes — ESLint rule takes precedence in
.tsfiles) no-explicit-anyis off;strictNullChecksis off in tsconfig- Unused vars with prefix
_or matchingReact|res|nextare allowed
GitHub Actions runs pnpm build and pnpm lint on push/PR to main and release/* branches (Node 20, pnpm 10.12.2).
pnpm install && pnpm -r build && pnpm -r test
pnpm lerna version # independent versioning with conventional commits
pnpm lerna publish from-package