Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Typescript Pro

ASecurity

Idiomatic TypeScript: strict typing, generics, discriminated unions, project setup, and type-driven design. Use when writing or reviewing TypeScript, or configuring TS projects.

2 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentsjavascripttypescriptrustgojavaexpressdebuggingapidocumentation

Works with

api

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add aicodedecode/awesome-muse-skills --skill typescript-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typescript Pro?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Typescript Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aicodedecode-typescript-pro/badge)](https://www.skillsdirectory.com/skills/aicodedecode-typescript-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: typescript-pro
description: Idiomatic TypeScript: strict typing, generics, discriminated unions, project setup, and type-driven design. Use when writing or reviewing TypeScript, or configuring TS projects.
category: development
---

# TypeScript Pro

## Overview

TypeScript's value isn't "JavaScript with types sprinkled on" — it's **making illegal states
unrepresentable** so whole bug classes disappear at compile time. This skill covers professional
TypeScript: strict configuration, modeling with the type system (unions, narrowing, branded types),
generics done right, and the tooling setup (build, lint, test) that keeps a TS codebase healthy.

The through-line: let the compiler carry the weight. If a bug is expressible as a type error,
express it.

## When to use

- Starting or configuring a TypeScript project (`tsconfig`, build, lint).
- Modeling domain concepts (states, API payloads, configs) with types.
- Reviewing TS for type-safety gaps (`any` leaks, unchecked narrowing).
- Choosing patterns: generics vs overloads, enums vs unions, classes vs functions.
- Debugging type errors or improving inference in a codebase.

## Core concepts

- **Strict mode is non-negotiable.** `strict: true` (plus `noUncheckedIndexedAccess`,
  `exactOptionalPropertyTypes` where tolerable). Non-strict TS is documentation-flavored JS;
  strict TS is a proof assistant for your domain logic. Enable on new projects; ratchet up on old.
- **Model states, not flags.** Discriminated unions over boolean soup:
  `{ status: "loading" } | { status: "ok", data: T } | { status: "error", error: E }` — the
  compiler then *forces* every consumer to handle every case. Booleans like `isLoading`,
  `isError` allow impossible combinations the union forbids.
- **Narrowing is the workflow.** Type guards, `in` checks, discriminants, and assertion functions
  turn `unknown` into precise types. Parse at the boundary (API responses, user input) with a
  validation library (zod/valibot) → typed domain objects inside. `any` is a loan shark: convenient
  now, expensive forever.
- **Generics with constraints.** Generic where the *caller* varies the type; constrain with
  `extends` so misuse fails fast. Prefer inference (`function first<T>(xs: T[])`) over explicit
  type arguments at call sites. Reaching for overloads? Often one generic signature is clearer.
- **`unknown` over `any`, `satisfies` over casts.** `unknown` forces handling; `satisfies` checks a
  value against a type without widening it (keeps literal types for exhaustiveness). Type
  assertions (`as`) are escape hatches — each one deserves a comment explaining why it's safe.
- **Types as API design.** Export the types consumers need; keep internals unexported. A change
  that breaks consumers should break compilation loudly, not silently at runtime.

## Practical workflow

1. **Configure strictly from day one:**
   ```json
   { "compilerOptions": {
       "strict": true, "noUncheckedIndexedAccess": true,
       "exactOptionalPropertyTypes": true, "noImplicitReturns": true,
       "moduleResolution": "bundler", "target": "ES2022" } }
   ```
2. **Define the domain model in types first.** States as unions, IDs as branded types
   (`type UserId = string & { readonly brand: unique symbol }`), configs as exact object types.
3. **Validate at boundaries.** API layer parses `unknown` JSON into domain types (zod schema);
   everything downstream trusts the types. One parsing chokepoint per boundary.
4. **Write functions with precise signatures.** Narrow inputs, specific return types (avoid
   `Promise<any>`); use `readonly` for inputs you don't mutate; prefer `ReadonlyArray` in APIs.
5. **Test types where they matter.** `expectTypeOf` assertions for tricky generics; exhaustiveness
   checks (`const _exhaustive: never = state`) so new union members break compilation, not runtime.
6. **Tooling:** `tsc --noEmit` in CI, ESLint with type-aware rules (or biome), Vitest/Jest for
   tests, and `tsup`/`tsc` for builds. Keep `skipLibCheck: true` for sanity.

Idiomatic snippets:

```ts
// Branded IDs prevent mixing them up
type UserId = string & { readonly __brand: "UserId" };
declare function getUser(id: UserId): Promise<User>;

// Exhaustive handling enforced by the compiler
type State = { s: "idle" } | { s: "loading" } | { s: "done"; data: string } | { s: "failed"; err: Error };
function render(st: State): string {
  switch (st.s) {
    case "idle": return "…";
    case "loading": return "…";
    case "done": return st.data;
    case "failed": throw st.err;
  }
}
```

## Common pitfalls

- **`any` creep.** One `any` poisons everything downstream (operations on `any` are `any`).
  Quarantine with `unknown` + narrowing; lint-ban `any` in new code (`@typescript-eslint/no-explicit-any`).
- **Type assertions as lies.** `data as User` without validation — the compiler believes you and
  runtime disagrees. Assert only what you've verified; parse what you haven't.
- **Enums vs unions.** Numeric enums have surprising runtime behavior; string unions
  (`"a" | "b"`) are simpler, tree-shakeable, and interop-friendly. Prefer unions; use `as const`
  objects when you need a runtime map too.
- **Over-generic code.** Generics with 4 type params for a function called twice. Start concrete;
  generalize on the third use.
- **Ignoring `strictNullChecks` fallout.** Non-strict codebases "migrating" by sprinkling `!`
  (non-null assertions) everywhere — you've kept the bugs and lost the safety. Fix the nullability
  model instead.
- **Interface vs type bikeshedding.** For most code they're interchangeable; pick `type` for
  unions/intersections, `interface` for object shapes meant to be extended/implemented — then move on.
- **Not leveraging inference.** Annotating everything (`const x: string = "hi"`) adds noise without
  safety. Annotate boundaries (function signatures, exports); let inference handle locals.

Attribution

aicodedecodeaicodedecode
View sourceSee grades on GitHubMore from aicodedecode →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →