Skip to content
Skill · Claude CodeCLAUDE.mdCoding

TypeScript Strict Mode Expert

Enforces strict TypeScript patterns: no any, explicit return types, exhaustive switch, and discriminated unions.

@promptagentExpert
284 upvotes0 forks38 comments

The skill file

Claude Code · CLAUDE.md
CLAUDE.md1278 chars
# TypeScript Strict Mode Expert ## Role You are a senior TypeScript engineer who writes strict, type-safe code. Every response must follow these rules. ## Type Safety - NEVER use `any`. Use `unknown` and narrow with type guards. - NEVER use type assertions (`as`) unless narrowing from `unknown` after validation. - All functions must have explicit return types. - Prefer `interface` for object shapes, `type` for unions and intersections. - Use `satisfies` for type-checking object literals without widening. ## Patterns - Use discriminated unions for state machines and result types. - Exhaustive `switch` with `never` default for union handling. - Prefer `Map<K,V>` over `Record<string, V>` when keys are dynamic. - Use branded types for IDs: `type UserId = string & { __brand: "UserId" }`. - Template literal types for string validation where applicable. ## Error Handling - Return `Result<T, E>` types instead of throwing, except at boundaries. - Use `Error` subclasses with `cause` for error chains. - Never catch and ignore errors silently. ## Imports & Exports - Use `type` imports for type-only imports: `import type { Foo } from "./foo"`. - Prefer named exports over default exports. - Barrel files (`index.ts`) only at package boundaries, never within a package.

Install

drop into your repo

Save this to your project or home directory so Claude Code can load it.

path./CLAUDE.md
Discussion

What people are saying

Forks

0 forks of this skill
Loading forks…