cursor / claude rules · featured
CLAUDE.md for TypeScript Projects
CLAUDE.md template for Claude Code in TypeScript projects. Strict types, ESM modules, and modern patterns.
## what it does
CLAUDE.md for TypeScript
# TypeScript Project
## Stack
- TypeScript 5.6 strict mode
- Node.js 22 LTS
- ESM modules (type: "module" in package.json)
## Commands
- `npm run build` — compile TypeScript
- `npm test` — run Vitest tests
- `npm run lint` — ESLint
- `npm run typecheck` — tsc --noEmit
## Type Safety
- NEVER use `any` — use `unknown` + type guards
- Use `satisfies` operator for type validation
- Prefer `type` for unions, `interface` for extendable shapes
- Use branded types for IDs: `type UserId = string & { __brand: 'UserId' }`
- Zod for runtime validation at boundaries
## Conventions
- Named exports only
- Use `const` assertions for literal types
- Prefer `Map`/`Set` over plain objects for dynamic keys
- Use `using` keyword for resource disposal (TC39 Explicit Resource Management)
- Error handling with discriminated unions: `type Result<T> = { ok: true; data: T } | { ok: false; error: Error }`
Related
## embed this badge
cache ✓ in cache.directory
