typescript-code-expert

mkobit's avatarfrom mkobit

Enforces functional programming, immutability, and strict type safety when writing, reviewing, or editing TypeScript and React code.

⭐2stars🔀1forks📁View on GitHub🕐Updated Jan 10, 2026

When & Why to Use This Skill

This Claude skill acts as a rigorous TypeScript and React code architect, designed to elevate software quality by enforcing functional programming principles, strict immutability, and robust type safety. It helps developers eliminate technical debt and runtime errors by ensuring codebases adhere to modern best practices, such as pure functions, Zod validation, and optimized React hook patterns.

Use Cases

  • Automated Code Audits: Reviewing pull requests to identify and replace 'any' types, hard type assertions, and imperative loops with type-safe, functional alternatives.
  • React Component Refactoring: Converting legacy class components or complex imperative logic into clean, decomposed functional components and custom hooks.
  • State Management Optimization: Implementing immutable data patterns and Discriminated Unions to model complex application states reliably.
  • Runtime Safety Implementation: Integrating Zod for schema validation to ensure that external API data matches internal TypeScript interfaces perfectly.
  • Modernizing Legacy Code: Pragmatically applying functional paradigms and 'readonly' constraints to existing TypeScript projects to improve maintainability.
nameTypeScript code expert
descriptionEnforces functional programming, immutability, and strict type safety when writing, reviewing, or editing TypeScript and React code.

TypeScript code expert guidelines

Follow these guidelines when writing or reviewing TypeScript. Apply these rules strictly for new code. Apply these rules pragmatically for existing codebases.

Functional programming

Prefer functional programming paradigms over imperative code. Prefer pure functions. Avoid side effects. Use libraries like remeda, fp-ts, or lodash-fp for data transformations. Prefer these libraries over manual imperative loops. Use iterator helpers like .values() where available in modern environments. Avoid class definitions when possible. Use classes only when required by frameworks (e.g., Obsidian plugins). Use classes only when required by third-party library constraints. Do not use let or var unless absolutely necessary. Use const for all variable declarations.

Immutability

Treat all data as immutable by default. Prefer readonly properties in interfaces. Prefer ReadonlyArray<T> over mutable arrays. Use the spread operator or functional utilities to update state. Inspect any use of mutable state carefully. Justify any deviation from immutability.

Type system

Must not use the any type. Must not use hard type assertions (e.g., as Type). Use unknown if the type is not yet known. Use Zod for runtime validation. Use generated types for GraphQL or API schemas. Use Discriminated Unions for modeling state with multiple variations. Leverage utility types like Pick, Omit, and Partial. Prefer interface for public API definitions. Prefer type for unions and intersections.

React guidelines

Use Functional Components. Use Hooks for state and side effects. Must not use Class Components. Decompose complex components into smaller, focused components. Extract complex logic into custom hooks. Use strict dependency arrays in useEffect and useCallback. Avoid inline function definitions in render if they cause performance issues. Prefer derived state calculation during render over useEffect synchronization.

Testing guidelines

Prefer property-based testing (e.g., fast-check) to verify invariants. Minimize mocking in tests. Prefer testing pure functions in isolation. Aim for high test coverage on core logic. Maintain best effort for testing functional code.