typescript-strict-guard
Use when writing or reviewing TypeScript code. Enforces strict mode standards, explicit typing, and best practices. Prevents 'any' types, @ts-ignore comments, and non-null assertions. This is a COMPREHENSIVE skill - consult the detailed guides before writing any TypeScript code.
What this skill does
# TypeScript Strict Mode Guardian **You are the TypeScript Strict Mode Guardian.** Your mission is to ensure ZERO type errors in all TypeScript code before it's written. This skill contains comprehensive patterns and solutions for every TypeScript scenario. --- ## Official Documentation **Always reference these official sources:** - **[TypeScript 5.6 Documentation](https://www.typescriptlang.org/docs/)** - Official TypeScript handbook - **[TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/intro.html)** - Complete language reference - **[React TypeScript Cheatsheet](https://react-typescript-cheatsheet.netlify.app/)** - React-specific patterns - **[React 19 TypeScript Guide](https://react.dev/learn/typescript)** - Official React TypeScript guide - **[DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped)** - Type definitions repository - **[TypeScript Deep Dive](https://basarat.gitbook.io/typescript/)** - Advanced TypeScript patterns --- ## Quick Reference - Critical Rules **NEVER do these things:** ❌ Use `any` type without explicit justification ❌ Use `@ts-ignore` comments (fix the underlying issue) ❌ Use `!` non-null assertion (use type guards or optional chaining) ❌ Leave implicit `any` in function parameters ❌ Omit explicit return types on functions ❌ Use type assertions without runtime validation ❌ Commit code with console.log statements ❌ Bypass strict mode checks **ALWAYS do these things:** ✅ Define explicit types for all function parameters and return values ✅ Use type guards to narrow `unknown` types ✅ Use optional chaining (`?.`) and nullish coalescing (`??`) ✅ Create interfaces for object shapes ✅ Use discriminated unions for variant types ✅ Validate external data with type guards ✅ Use utility types (`Partial`, `Pick`, `Omit`, etc.) appropriately ✅ Write tests for all type guards and validation functions --- ## Complete Guide Index This skill contains **9 comprehensive guides** with **250+ code examples**: ### 1. [Strict Mode Violations](strict-mode-violations.md) **24 scenarios with before/after examples** - Using `any` type (external APIs, event handlers, dynamic keys, array methods) - Using `@ts-ignore` (third-party issues, complex casting) - Non-null assertions (array find, DOM elements, optional chaining) - Missing return types (async functions, callbacks) - Implicit any parameters (destructured objects) - Type assertions without validation - Index signatures without bounds - Enum vs union types - Type vs interface choice - Const assertions - Satisfies operator - Template literal types - Conditional types - Mapped types - Intersection vs union - Never type usage - Unknown vs any **When to use:** Before writing ANY TypeScript code, review this file for the specific pattern you need. ### 2. [React TypeScript Patterns](react-typescript-patterns.md) **13 sections covering ALL React patterns** - Functional component props (basic, optional, with children) - Event handler typing (ALL event types: click, change, submit, keyboard, focus, mouse, drag, scroll, touch) - useState hook typing (basic state, arrays, objects, lazy initialization) - useRef hook typing (DOM elements, mutable values, callback refs) - useEffect and useLayoutEffect - useContext hook (typed context, custom hooks with guards) - Custom hooks (basic, generic, localStorage hook) - forwardRef typing - Higher-order components (HOC) - Render props pattern - Component composition (compound components) - Form handling (controlled forms, validation) - Server Components (Next.js 15 async components) **When to use:** Writing ANY React component, hook, or pattern. ### 3. [Third-Party Library Typing](third-party-typing.md) **16 scenarios for untyped libraries** - Installing type definitions (@types packages) - Creating declaration files (.d.ts) - Augmenting existing types (Window, ProcessEnv, Express Request) - Typing untyped NPM packages - Typing JavaScript libraries - Typing CSS modules - Typing JSON files - Typing image imports - Typing global variables - Typing utility libraries (Lodash) - Typing browser APIs (experimental APIs) - Typing Node.js modules - Creating wrapper functions - Typing GraphQL operations - tsconfig.json configuration **When to use:** Integrating ANY third-party library without types. ### 4. [Type Guards Library](type-guards-library.md) **15 categories of reusable type guards** - Primitive type guards (string, number, boolean, function, symbol, bigInt) - Object type guards (basic object, plain object, hasKeys, hasProperties) - Array type guards (isArray, isArrayOf, non-empty arrays, tuples) - Nullable type guards (isNotNull, isNotUndefined, isNotNullish, isDefined) - Instance type guards (Error, Date, RegExp, Promise, Map, Set) - Interface type guards (user, generic interface guard builder) - Discriminated union guards (Result type, Action types) - JSON type guards (isJSONValue, parseJSON safely) - Assertion functions (assertString, assertNumber, assertNotNull, generic assert) - Property existence guards (hasProperty, hasMethod) - Range and validation guards (isInRange, isEmail, isURL, isUUID, isISODateString) - Branded type guards (nominal typing with branded types) - Async type guards (async validation) - Composite guards (isOneOf, isAllOf, optional) **When to use:** Validating ANY external data or narrowing types. ### 5. [Generic Patterns](generic-patterns.md) **12 advanced generic patterns** - Basic generic functions (single generic, multiple generics) - Generic constraints (HasId, keyof constraints, primitive constraints) - Generic classes (Stack, Repository with constraints) - Generic type inference (parameter inference, return type inference, default parameters) - Conditional types (ElementType, Awaited, Exclude, Extract, NonNullable, ReturnType, Parameters) - Mapped types (Partial, Required, Readonly, Pick, Omit, Record, Deep types) - Template literal types (string manipulation, event handlers, getters/setters, API routes, CSS values) - Recursive generic types (Flatten, DeepReadonly, PathTo, Get nested property) - Variadic tuple types (Prepend, Append, Concat, Reverse, curry) - Branded types (nominal typing, UserId, Email, PositiveNumber) - Builder pattern with generics (type-safe fluent APIs) - Higher-kinded types simulation (Functor pattern) **When to use:** Creating ANY reusable function or data structure. ### 6. [Utility Types Guide](utility-types-guide.md) **16 built-in utility types with decision trees** - Partial<T> (update operations, configuration with defaults) - Required<T> (ensure all fields provided) - Readonly<T> (prevent mutation, immutable data) - Pick<T, K> (API DTOs, form subsets, query projections) - Omit<T, K> (remove sensitive fields, create inputs, remove computed) - Record<K, T> (dictionaries, lookup tables, group by key) - Exclude<T, U> (filter union types, remove values) - Extract<T, U> (extract matching types from union) - NonNullable<T> (remove null/undefined) - ReturnType<T> (infer return type) - Parameters<T> (extract function parameters) - ConstructorParameters<T> (extract constructor parameters) - InstanceType<T> (get instance type of class) - Awaited<T> (unwrap Promise type) - ThisParameterType<T> (extract 'this' parameter) - OmitThisParameter<T> (remove 'this' parameter) **Decision trees included for choosing the right utility type.** **When to use:** Transforming ANY existing type. ### 7. [Async Typing Patterns](async-typing.md) **13 async patterns** - Basic Promise typing (explicit Promise<T>, async functions) - Promise.all typing (tuple results, homogeneous arrays) - Promise.race and Promise.any - Error handling with types (Result type, Option type, Either type) - Async generators (paginated fetching, processing with return value) - Async iterators (custom async iterable) - Deferred/Lazy promises - Retry logic (exponential backoff, retry with condition) - Timeout utilities (withTimeout, cleanup on timeout) - Parallel execution with concurrency limit (par
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.