Agent skill

Typescript Type Safety

by pr-pm in pr-pm/prpm

A skill your agent uses when encountering TypeScript any types, type errors, or lax type checking - eliminates type holes and enforces strict type safety through proper interfaces, type guards, and…

MITAuto-check passedDevelopment

Install Typescript Type Safety

skills CLI
$ npx skills add pr-pm/prpm --skill typescript-type-safety -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pr-pm/prpm typescript-type-safety --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pr-pm/prpm.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/typescript-type-safety .claude/skills/typescript-type-safety && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
typescript-type-safety
GitHub stars
122
Token cost
~2.1k tokens
SKILL.md length
565 words
Files
1
Skills in repo
35
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when encountering TypeScript any types, type errors, or lax type checking - eliminates type holes and enforces strict type safety through proper interfaces, type guards, and…

  • Works in 5 steps: Explicit interface/type definition → Generic type parameters with constraints → Union types → …
  • Encountering TypeScript any types
  • SKILL.md covers Overview, When to Use, Type Safety Hierarchy and Quick Reference, plus 6 more sections
  • Calls npm

What it does

Typescript Type Safety is an agent skill from pr-pm/prpm. Use when encountering TypeScript any types, type errors, or lax type checking - eliminates type holes and enforces strict type safety through proper interfaces, type guards, and module augmentation

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Type safety. It works with TypeScript. The repository describes itself as: The universal registry for AI coding tools. The licence is MIT.

When your agent uses it

  • Encountering TypeScript any types
  • Lax type checking - eliminates type holes and enforces strict type safety through proper interfaces
  • Module augmentation

Example prompts

  • “/typescript-type-safety”

Requirements

  • Node.js

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Explicit interface/type definition
  2. Generic type parameters with constraints
  3. Union types
  4. unknown (with type guards)
  5. never (for impossible states)

What it can do on your machine

Read from SKILL.md and the folder at commit 5f993e6. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Typescript Type Safety loads about 2.1k tokens when it runs. Until then it costs about 55 tokens; SKILL.md has 565 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~55
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from pr-pm/prpm at commit 5f993e6, republished under its MIT licence (© pr-pm). 565 words, ~2,128 tokens.

Download SKILL.mdSave it as .claude/skills/typescript-type-safety/SKILL.md (or your agent's skills folder).
name
typescript-type-safety
description
Use when encountering TypeScript any types, type errors, or lax type checking - eliminates type holes and enforces strict type safety through proper interfaces, type guards, and module augmentation

TypeScript Type Safety

Overview

Zero tolerance for any types. Every any is a runtime bug waiting to happen.

Replace any with proper types using interfaces, unknown with type guards, or generic constraints. Use @ts-expect-error with explanation only when absolutely necessary.

When to Use

Use when you see:

  • : any in function parameters or return types
  • as any type assertions
  • TypeScript errors you're tempted to ignore
  • External libraries without proper types
  • Catch blocks with implicit any

Don't use for:

  • Already properly typed code
  • Third-party .d.ts files (contribute upstream instead)

Type Safety Hierarchy

Prefer in this order:

  1. Explicit interface/type definition
  2. Generic type parameters with constraints
  3. Union types
  4. unknown (with type guards)
  5. never (for impossible states)

Never use: any

Quick Reference

PatternBadGood
Error handlingcatch (error: any)catch (error) { if (error instanceof Error) ... }
Unknown dataJSON.parse(str) as anyconst data = JSON.parse(str); if (isValid(data)) ...
Type assertions(request as any).user(request as AuthRequest).user
Double castingreturn data as unknown as TypeAlign interfaces instead: make types compatible
External libsconst server = fastify() as anydeclare module 'fastify' { ... }
Genericsfunction process(data: any)function process<T extends Record<string, unknown>>(data: T)

Implementation

Error Handling
typescript
// ❌ BAD
try {
  await operation();
} catch (error: any) {
  console.error(error.message);
}

// ✅ GOOD - Use unknown and type guard
try {
  await operation();
} catch (error) {
  if (error instanceof Error) {
    console.error(error.message);
  } else {
    console.error('Unknown error:', String(error));
  }
}

// ✅ BETTER - Helper function
function toError(error: unknown): Error {
  if (error instanceof Error) return error;
  return new Error(String(error));
}

try {
  await operation();
} catch (error) {
  const err = toError(error);
  console.error(err.message);
}
Unknown Data Validation
typescript
// ❌ BAD
const data = await response.json() as any;
console.log(data.user.name);

// ✅ GOOD - Type guard
interface UserResponse {
  user: {
    name: string;
    email: string;
  };
}

function isUserResponse(data: unknown): data is UserResponse {
  return (
    typeof data === 'object' &&
    data !== null &&
    'user' in data &&
    typeof data.user === 'object' &&
    data.user !== null &&
    'name' in data.user &&
    typeof data.user.name === 'string'
  );
}

const data = await response.json();
if (isUserResponse(data)) {
  console.log(data.user.name); // Type-safe
}
Module Augmentation
typescript
// ❌ BAD
const user = (request as any).user;
const db = (server as any).pg;

// ✅ GOOD - Augment third-party types
import { FastifyRequest, FastifyInstance } from 'fastify';

interface AuthUser {
  user_id: string;
  username: string;
  email: string;
}

declare module 'fastify' {
  interface FastifyRequest {
    user?: AuthUser;
  }

  interface FastifyInstance {
    pg: PostgresPlugin;
  }
}

// Now type-safe everywhere
const user = request.user; // AuthUser | undefined
const db = server.pg;      // PostgresPlugin
Generic Constraints
typescript
// ❌ BAD
function merge(a: any, b: any): any {
  return { ...a, ...b };
}

// ✅ GOOD - Constrained generic
function merge<
  T extends Record<string, unknown>,
  U extends Record<string, unknown>
>(a: T, b: U): T & U {
  return { ...a, ...b };
}
Type Alignment (Avoid Double Casts)
typescript
// ❌ BAD - Double cast indicates misaligned types
interface SearchPackage {
  id: string;
  type: string;  // Too loose
}

interface RegistryPackage {
  id: string;
  type: PackageType;  // Specific enum
}

return data.packages as unknown as RegistryPackage[];  // Hiding incompatibility

// ✅ GOOD - Align types from the source
interface SearchPackage {
  id: string;
  type: PackageType;  // Use same specific type
}

interface RegistryPackage {
  id: string;
  type: PackageType;  // Now compatible
}

return data.packages;  // No cast needed - types match

Rule: If you need as unknown as Type, your interfaces are misaligned. Fix the root cause, don't hide it with double casts.

ESM Import Extensions

Always use .js extension for relative imports in ESM projects.

Node.js ESM requires explicit file extensions. TypeScript compiles .ts → .js, so imports must reference the output extension.

typescript
// ❌ BAD - Will fail at runtime in ESM
import { helper } from './utils';
import { CLIError } from '../utils/cli-error';
import type { Package } from './types/package';

// ✅ GOOD - Explicit .js extensions
import { helper } from './utils.js';
import { CLIError } from '../utils/cli-error.js';
import type { Package } from './types/package.js';

Why this is a TypeScript/type safety issue:

  • TypeScript doesn't catch missing extensions at compile time
  • Errors only appear at runtime: ERR_MODULE_NOT_FOUND
  • CI builds fail but local development works (cached modules)
  • This is one of the most common "works locally, fails in CI" issues

TSConfig for ESM:

json
{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    // OR
    "module": "ESNext",
    "moduleResolution": "bundler"
  }
}

Common Import Mistakes:

PatternIssueFix
import { x } from './file'Missing extensionimport { x } from './file.js'
import { x } from './dir'Missing indeximport { x } from './dir/index.js'
import pkg from 'pkg/subpath'Package exportCheck package.json exports field

Linting for Import Extensions:

bash
# Find imports missing .js extension
grep -rn "from '\.\.\?/[^']*[^j][^s]'" --include="*.ts" src/

# ESLint rule (if using eslint)
# "import/extensions": ["error", "always", { "ignorePackages": true }]
Show full SKILL.md (224 more words)Show less

Common Mistakes

MistakeWhy It FailsFix
Using any for third-party libsLoses all type safetyUse module augmentation or @types/* package
as any for complex typesHides real type errorsCreate proper interface or use unknown
as unknown as Type double castsMisaligned interfacesAlign types at source - same enums/unions
Skipping catch block typesUnsafe error accessUse unknown with type guards or toError helper
Generic functions without constraintsAllows invalid operationsAdd extends constraint
Ignoring ts-ignore accumulationTech debt compoundsFix root cause, use @ts-expect-error with comment
Missing .js import extensionsESM runtime failuresAlways use .js for relative imports

TSConfig Strict Settings

Enable all strict options for maximum type safety:

json
{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictBindCallApply": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true
  }
}

Type Audit Workflow

  1. Find: grep -r ": any\|as any" --include="*.ts" src/
  2. Categorize: Group by pattern (errors, requests, external libs)
  3. Define: Create interfaces/types for each category
  4. Replace: Systematic replacement with proper types
  5. Validate: npm run build must succeed
  6. Test: All tests must pass

Real-World Impact

Before type safety:

  • Runtime errors from undefined properties
  • Silent failures from type mismatches
  • Hours debugging production issues
  • Difficult refactoring

After type safety:

  • Errors caught at compile time
  • IntelliSense shows all available properties
  • Confident refactoring with compiler help
  • Self-documenting code

Remember: Type safety isn't about making TypeScript happy - it's about preventing runtime bugs. Every any you eliminate is a production bug you prevent.

© pr-pm, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/typescript-type-safety of pr-pm/prpm.

Open the folder on GitHubat commit 5f993e6

Compare with similar skills

Typescript Type Safety next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Typescript Type Safety compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Typescript Type Safety this skillpr-pm/prpm122—~2.1kAutomated safety check: PassMIT
Typescript Advanced Typesrolling-scopes/rsschool-app10k24 repos~4.2kAutomated safety check: PassMPL-2.0
Wagmi Feature Developmentwevm/wagmi6.8k—~3.8kAutomated safety check: PassMIT
Convert Internal Package to TypeScriptTryGhost/Ghost55k—~1.2kAutomated safety check: PassMIT
Add NodeBridge Handlerneovateai/neovate-code1.6k—~1kAutomated safety check: PassMIT
AST Visitor Pattern for Unionsprisma/orm48k—~830Automated safety check: PassApache-2.0

Similar skills

  • Typescript Advanced Types

    rolling-scopes/rsschool-app

    Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications.

    10k GitHub starsUsed in 24 repos~4.2k tokens
    DevelopmentAuto-check passed
  • Walks through adding a Wagmi feature across its layers: a Viem-based core action, TanStack Query options, and React and Vue bindings.

    6.8k GitHub stars~3.8k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Moves a legacy internal Ghost package from JavaScript and CommonJS to TypeScript and ESM in three focused commits that keep git file history intact.

    55k GitHub stars~1.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Add NodeBridge Handler

    neovateai/neovate-code

    Walks through adding a message handler to NodeBridge in Neovate Code, from the implementation and its types to an optional test entry and a run with Bun.

    1.6k GitHub stars~1k tokensUpdated 6 mo ago
    DevelopmentAuto-check passed
  • Official

    Replaces a plain TypeScript union plus switch statements with frozen subclasses and a visitor interface when several places dispatch on the same variants.

    48k GitHub stars~830 tokensUpdated today
    DevelopmentAuto-check passed
  • Bumpy Add Change

    zap-studio/monorepo

    Create a bumpy bump file describing which packages changed and how, for version bumping and changelog generation.

    172 GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check: notes

More from pr-pm/prpm

All 35 skills in this repo
  • Reference for writing Claude Code agent files: location, frontmatter fields, validation limits, tool and model choices, and the required content format.

    122 GitHub starsUsed in 3 repos~4k tokens
    Auto-check passed
  • Covers how to build, configure and publish Claude Code hooks: event types, exit codes, JSON I/O, and PRPM packaging.

    122 GitHub starsUsed in 2 repos~3.9k tokens
    Auto-check: notes
  • Shows how to write .claude/rules/ files correctly: paths frontmatter instead of globs, quoted glob patterns, global rules and conversion of Cursor rules.

    122 GitHub starsUsed in 2 repos~551 tokens
    Auto-check passed
  • Reference for writing portable Agent Skills packages, covering SKILL.md frontmatter limits, name rules, directory layout and where Codex CLI, GitHub Copilot and Amp look for skills.

    122 GitHub starsUsed in 1 repo~1.5k tokens
    Auto-check passed
  • A skill your agent uses when building custom Kiro AI agents or when user asks for agent configurations - provides JSON structure, tool configuration, prompt patterns, and security best practices for…

    122 GitHub starsUsed in 1 repo~1.9k tokens
    Auto-check passed
  • A skill your agent uses when creating OpenCode agents - provides markdown format with YAML frontmatter, mode/tools/permission configuration, and best practices for specialized AI assistants

    122 GitHub starsUsed in 1 repo~2k tokens
    Auto-check passed

Works with

Categories

Questions about Typescript Type Safety

What does Typescript Type Safety do?

A skill your agent uses when encountering TypeScript any types, type errors, or lax type checking - eliminates type holes and enforces strict type safety through proper interfaces, type guards, and…. Typescript Type Safety is an agent skill from pr-pm/prpm.

When should I use Typescript Type Safety?

Typescript Type Safety fits situations like: encountering TypeScript any types; lax type checking - eliminates type holes and enforces strict type safety through proper interfaces; module augmentation.

How do I install Typescript Type Safety in Claude Code?

Run `npx skills add pr-pm/prpm --skill typescript-type-safety -a claude-code`. Or copy the skill folder (.claude/skills/typescript-type-safety in pr-pm/prpm) into .claude/skills/typescript-type-safety in your project. Claude Code loads it when a task matches its description.

How do I install Typescript Type Safety in Codex?

Run `npx skills add pr-pm/prpm --skill typescript-type-safety -a codex`. Or copy the skill folder (.claude/skills/typescript-type-safety in pr-pm/prpm) into .agents/skills/typescript-type-safety in your project. Codex loads it when a task matches its description.

Can I use Typescript Type Safety in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pr-pm/prpm --skill typescript-type-safety -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/typescript-type-safety, .gemini/skills/typescript-type-safety, .github/skills/typescript-type-safety and .opencode/skills/typescript-type-safety in your project.

What does Typescript Type Safety need to run?

Going by SKILL.md and its folder, Typescript Type Safety needs the command-line tools its instructions call (npm). Our summary lists: Node.js.

Does Typescript Type Safety access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Typescript Type Safety safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Typescript Type Safety use?

Typescript Type Safety is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Typescript Type Safety use?

About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Typescript Type Safety?

Skills that share tags, products or a category with Typescript Type Safety: Typescript Advanced Types (rolling-scopes/rsschool-app, 10k stars), Wagmi Feature Development (wevm/wagmi, 6.8k stars), Convert Internal Package to TypeScript (TryGhost/Ghost, 55k stars) and Add NodeBridge Handler (neovateai/neovate-code, 1.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Typescript Type Safety?

pr-pm (a GitHub organization) maintains it in pr-pm/prpm, which has 122 GitHub stars. The repository holds 35 skills in this directory. The repository was last updated on October 6, 2026.

Source: pr-pm/prpm on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.