This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a TypeScript Node.js starter with optional Vite web client:
- Node server: HTTP server (
src/index.ts) with simple routing and graceful shutdown - Vite client: Optional browser entry (
src/main.ts+index.html) with API proxy - Shared types: Common interfaces in
src/shared/types.ts(or Zod schemas if enabled) - Environment: Typed environment configuration in
src/env.tsusing dotenv - Template system: Code generation via
scripts/template.mjswith templates intemplates/ - Development loop: Concurrent server + client with HMR via
scripts/dev.mjs
Key endpoints:
GET /health→{ status: "ok", service: "typeforge", time: "ISO" }GET /hello?name=X→{ message: "hello X" }- Client accesses these via proxy:
/api/health,/api/hello
- Source in
src/; tests intests/; optional web entryindex.html+src/main.ts. - Keep configuration in repo:
package.json,tsconfig.json,biome.json,lefthook.yml,.editorconfig. Provide.env.example. - Templates in
templates/for code generation (CLI scripts, API endpoints, schemas, etc.)
- pnpm scripts (pnpm is provisioned via proto):
pnpm dev: Run server and client concurrently (tsx + Vite) with graceful shutdown.pnpm dev:server: Node dev via tsx watch.pnpm dev:client: Vite dev server (HMR, opens browser).pnpm build/pnpm build:web: Build Node TS / Vite bundle.pnpm test/pnpm coverage: Vitest run/coverage.pnpm lint/pnpm format: Biome lint/format.
- Templates located in
templates/directory with__NAME__placeholders - Generate code:
just template <name> <dest>ornode scripts/template.mjs apply <name> <dest> - Available templates:
cli(CLI scripts),endpoint(API routes),env(env config),zod(Zod schemas),playwright(E2E),lhci(Lighthouse) - Templates are applied with variable substitution for rapid scaffolding
- Default: TypeScript-only types in
src/shared/types.ts - Zod mode: Runtime validation with schemas in
src/shared/schemas.ts - Switch to Zod:
just switch-to-zod(interactive) orCONFIRM=1 just switch-to-zod - Switch from Zod:
just switch-from-zod - Preflight check:
just preflight-switch-to-zod(safe to switch analysis) - When in Zod mode: client uses
schema.parse()instead of type assertions
- Quick health check:
just verifystarts/stops dev and checks server/healthand client/api/health. - E2E:
just e2e(Playwright installed) orjust e2e-dev(spawns dev automatically). - Doctor:
just doctor(verify + fast unit tests) for quick confidence.
- Indentation: 2 spaces (JS/TS), 4 spaces (Python). Keep lines ≤ 100 chars.
- Naming:
camelCasefor TS,PascalCasefor classes; kebab-case for files/dirs unless language dictates. - Formatting/Linting (Node): Biome (
biome.json) provides formatter, linter, and organize-imports. Usepnpm formatandpnpm lint.
- Framework: Vitest. Place tests in
tests/mirroring source paths. - Names:
*.test.ts(or.jsif applicable). - Coverage: Target ≥ 90% for core modules. Run
pnpm coverage. - Local run:
pnpm test(CI runs on push/PR).
- Always confirm with the user before invoking disruptive tasks. Examples:
just switch-to-zod,just switch-from-zod,just clean,just release. - For migrations (Zod): prefer running
just preflight-switch-to-zodfirst and share the summary with the user. - Non-interactive mode is allowed only after explicit user approval. Set
CONFIRM=1to bypass prompts.- Example (approved):
CONFIRM=1 just switch-to-zod
- Example (approved):
- Use
just ensureto verify toolchain before invoking build/test tasks.
- Commits: Use Conventional Commits. Example:
feat(api): add token refresh - PRs: Link issues, describe rationale + approach, include screenshots or logs when UI/CLI behavior changes, and note tests added/updated.
- Keep PRs focused and under ~300 lines of diff when possible.
- Never commit secrets. Use
.envlocally and CI secrets for pipelines. just initcopies.env.exampleto.envif missing.- Validate inputs and handle errors explicitly; add security notes in
docs/SECURITY.mdwhen needed.
- Vite proxies
/api/*to the Node server onSERVER_PORTand strips the/apiprefix for convenience.
- Default ports:
SERVER_PORT=3000,CLIENT_PORT=5173(configurable via environment or.env).
- Managed by Lefthook (
lefthook.yml). Installed viapnpm run prepare. - Toolchain enforcement: Hooks run
scripts/ensure-toolchain.mjsto ensure Node and pnpm matchproto.json. - Pre-commit: Biome format check + lint on staged files. Pre-push: type-check + tests.
- Package manager via proto-managed pnpm; Node version pinned with
proto.json(24.6.0). Enforcement allows any Node within the same major (24.x). - Always run
proto install && proto usebefore development; Just recipes also verify the toolchain and will fail fast if the major version mismatches or pnpm version differs from proto.
Key scripts in scripts/ directory:
dev.mjs: Orchestrates concurrent server + client development with graceful shutdowntemplate.mjs: Template engine for code generation with variable substitutionensure-toolchain.mjs: Validates proto toolchain matches requirementsswitch-to-zod.mjs/switch-from-zod.mjs: Automated migration between TS-only and Zod validationbootstrap.mjs: Project metadata replacement (replaces placeholder values)generate-commit-msg.mjs: Auto-generates conventional commit messages via llmc
Additional tooling:
- DX maintenance:
just dx-maintainruns comprehensive health checks and hygiene tasks - Worktrees:
just wt-new <name>,just wt-dx <name>for parallel development branches - CI simulation:
just cimirrors GitHub Actions locally - Auto-fix:
just fixapplies all auto-fixable formatting and linting rules