All skills
Skillintermediate
/add-types - Add Type Definitions
Add TypeScript type definitions to existing TypeScript files with weak typing.
Claude Code Knowledge Pack7/10/2026
Overview
/add-types - Add Type Definitions
Add TypeScript type definitions to existing TypeScript files with weak typing.
Steps
- Scan the file for
anytypes, implicit any parameters, and untyped variables - Analyze function call sites to infer parameter and return types
- Check imported modules for available type definitions
- Replace
anytypes with specific types based on usage analysis - Add generic type parameters where functions operate on multiple types
- Create interface definitions for object literals used as parameters
- Add union types for variables that accept multiple value types
- Type event handlers and callback functions with proper signatures
- Add type assertions only where type narrowing is not possible
- Ensure all exported functions have explicit parameter and return types
- Run the TypeScript compiler and fix any new type errors
- Report: types added, any types remaining, type coverage percentage
Rules
- Never use type assertions (as) to silence errors; fix the root cause
- Prefer type inference for local variables; add explicit types for function boundaries
- Use utility types (Partial, Required, Pick, Omit) instead of duplicating interfaces
- Add readonly modifiers for properties that should not be mutated
- Use const assertions for literal values and enums
- Check DefinitelyTyped for missing third-party type definitions
- Target 100% type coverage for public API functions