Skip to content
/type-strictStable

Progressively tightens TypeScript strictness. Eliminates any types, adds missing annotations, and enables stricter compiler options.

TypeScriptQualityΒ· 2 min read

Quick import: Download the .md file and save it to .claude/commands/ (Claude Code), .cursorrules (Cursor), or paste as a system prompt in ChatGPT, Gemini, or any LLM API.

#What it does

The /type-strict skill incrementally improves your TypeScript type safety. Instead of flipping strict: true and drowning in 500 errors, it works file-by-file and rule-by-rule -- fixing the easiest wins first, then progressively tightening until your codebase reaches full strictness.

#How to use

bash
/type-strict

Run at the project root for a full audit, or target a specific file or directory.

bash
/type-strict src/api/

#What it fixes

  • any types -- Replaces any with proper types inferred from usage, or unknown with type guards when the type genuinely varies
  • Missing return types -- Adds explicit return type annotations to exported functions
  • Implicit any parameters -- Annotates callback parameters and function arguments
  • Non-null assertions -- Replaces value! with proper null checks or optional chaining
  • Type assertions -- Converts unsafe as Type casts to type guards or discriminated unions
  • Loose comparisons -- Flags == vs === and truthy checks that hide type issues

#Workflow

  1. Audit -- Scans the codebase and counts type safety violations by category
  2. Prioritize -- Ranks fixes by impact (API boundaries first, internal helpers last)
  3. Fix -- Applies safe, automated fixes for straightforward cases
  4. Flag -- Lists complex cases that need manual review with suggested approaches
  5. Configure -- Recommends tsconfig.json strictness flags to enable next

#Example

bash
> /type-strict
 
## TypeScript Strictness Audit
 
Current strictness: 62% (14 of 23 strict flags enabled)
 
### Quick wins (auto-fixable)
- 23 uses of `any` replaceable with concrete types
- 18 exported functions missing return types
- 7 non-null assertions replaceable with optional chaining
 
### Needs review
- 4 generic `any` in API response handlers (suggest Zod schemas)
- 2 type assertions in test utilities (suggest type guards)
 
### Recommended next tsconfig flags
1. `noUncheckedIndexedAccess` -- catches undefined array/object access
2. `exactOptionalPropertyTypes` -- distinguishes missing vs undefined
 
Apply auto-fixes? (23 files affected)
Orel OhayonΒ·
View all skills