typescript-enforcer

Enforce strict TypeScript type safety by banning `any` and requiring explicit types.

Updated Jul 29, 2025
One-click install
npx skills add https://github.com/T1nker-1220/.claude --skill typescript-enforcer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-enforcer
Source: https://github.com/T1nker-1220/.claude/tree/main/skills/typescript-enforcer
Command: npx skills add https://github.com/T1nker-1220/.claude --skill typescript-enforcer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill combats the pervasive issue of loose TypeScript usage, particularly the any type, which undermines type safety, leads to runtime errors, and makes codebases difficult to maintain.

Core Features & Use Cases

  • Zero Tolerance for any: Strictly enforces the avoidance of any, guiding users to use unknown with type guards for truly dynamic scenarios.
  • Explicit Typing: Requires explicit function parameters and return types, proper interfaces for all data structures, and specific types over broad ones.
  • Strict Configuration: Provides a tsconfig.json configuration to enable strict mode, catching potential type errors at compile time.
  • Use Case: When reviewing a pull request, activate this skill to automatically identify and flag any any types, missing return types, or improperly defined interfaces, ensuring high-quality, type-safe TypeScript code.

Quick Start

Example: Explicitly typed function with interface

interface User { id: string; name: string; email: string; }

function createUser(data: User): User { return { id: data.id, name: data.name, email: data.email, createdAt: new Date() }; }

Example: Using 'unknown' with a type guard

function isUser(data: unknown): data is User { return ( typeof data === 'object' && data !== null && 'id' in data && 'name' in data ); }

Frequently Asked Questions about typescript-enforcer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate 'any' types from my TypeScript codebase?

Replace 'any' with explicit types, interfaces, or 'unknown' with type guards. This Skill enforces strict typing by flagging 'any' usage and guiding you toward precise type definitions, catching type errors at compile time instead of runtime.

What's the best way to enforce strict TypeScript across a project?

Enable strict mode in tsconfig.json and require explicit parameter and return types on all functions. This Skill provides strict configuration templates and validates that all data structures use proper interfaces rather than loose typing.

How do I use 'unknown' instead of 'any' for dynamic data?

'unknown' requires explicit type checking before use. This Skill shows you how to write type guards that safely narrow 'unknown' to specific types, maintaining type safety while handling truly dynamic scenarios.

Can I use this during code review to catch type safety issues?

Yes. Activate this Skill during pull request review to automatically identify missing return types, untyped parameters, improper interfaces, and any 'any' usage, ensuring consistent type-safe practices across your team.

Why does TypeScript 'any' cause problems in large codebases?

'any' disables type checking, leading to runtime errors and making refactoring risky. Strict typing enforced by this Skill catches errors early, improves IDE autocompletion, and makes code safer to maintain and modify.

Do I need to refactor existing code to use strict mode?

Gradual adoption is possible by enabling strict flags incrementally in tsconfig.json. This Skill helps identify and fix violations systematically, allowing you to increase type safety without rewriting your entire codebase at once.