Skip to main content
skill CX Codex

typescript-best-practices — Claude Code skill: TypeScript rules

A skill that hands the agent a rulebook for .ts and .tsx files: discriminated unions, branded types, validation at the boundary.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add cursor/plugins --skill typescript-best-practices -a claude-code
Open on GitHub

What typescript-best-practices does

The skill fires whenever the agent opens or edits a .ts or .tsx file. Its table of rules covers modeling variants with a literal kind discriminant, branding primitives via & { readonly __brand: "X" }, and keeping outside data in unknown rather than any.

A second group deals with narrowing. The order runs from a discriminant switch down to as, user-defined type guards have to actually verify what they claim, and default arms carry const _exhaustive: never = x; so a new variant breaks the build. Schemas come before hand-written guards, with the type inferred from the schema, z.infer being the example given. Every as is treated as a runtime crash waiting to happen — cast only after validation.

Two principle skills are named as prerequisites: **type-system-discipline** and **boundary-discipline**, applied first. Pattern examples live in references/patterns.md. Install runs through npx skills add with a per-platform flag; GitHub Copilot takes a different command, gh skill install.

What it helps with

  • model state variants so impossible combinations fail to compile
  • swap scattered as casts for boundary validation and named domain types
  • infer a type from a runtime schema instead of hand-writing a property guard
  • add an exhaustiveness check that catches a new variant at build time
  • move shipped code off console.log onto a structured logger

Example prompts for the agent

  • Review this .ts file against the skill rules and drop every as
  • Rewrite this optional-field bag as a discriminated union on kind
  • Add an exhaustiveness check to the switch over API response variants

How to install typescript-best-practices

1Skills CLI (Vercel)

npx skills add cursor/plugins --skill typescript-best-practices -a claude-code

2Manually: put the files in place

~/.claude/skills/typescript-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/typescript-best-practices/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about typescript-best-practices

How do I install typescript-best-practices in Claude Code?

Run npx skills add cursor/plugins --skill typescript-best-practices -a claude-code. The skill lands at ~/.claude/skills/typescript-best-practices/SKILL.md.

What does typescript-best-practices do?

It gives the agent a set of TypeScript rules: discriminated unions, branded types, unknown over any, boundary validation, exhaustiveness checks. It activates when a .ts or .tsx file is read or edited.

Which other platforms can install this skill?

Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode each have their own flag or command. GitHub Copilot uses gh skill install cursor/plugins typescript-best-practices.

Similar skills

All skills for Programming languages →

From the same set45

unslop This skill removes common AI writing patterns, filler, and vague phrasing while keeping the meaning and intended tone. Use it when polishing text. CX Codex +1 28,000installs thermo-nuclear-code-quality-review Runs a strict maintainability audit of code changes, abstractions, large files, and branching complexity. Use it when a routine review needs deeper structural scrutiny. CX Codex +1 22,200installs deslop Inspects branch diffs against main to remove AI-generated code clutter and inconsistent styling. Ideal for polishing branch changes before pull request review. CX Codex +1 9,300installs how Explores codebase architecture and runtime execution paths before you edit code. Helps determine module ownership, layering, and placement for new features. CX Codex +1 6,000installs why The skill investigates why code took its current shape by checking Git history and available MCP sources, then returns cited findings about decisions and tradeoffs. CX Codex +1 5,700installs blast-radius A skill that finds what a change breaks elsewhere in the project and proves the one safety fact by executing code, not by describing it. CX Codex +1 5,700installs make-pr-easy-to-review This skill prepares pull requests for review by cleaning noisy history, refining the PR description, and adding reviewer guidance without changing code behavior. CX Codex +1 3,100installs fix-merge-conflicts Resolves merge conflicts in a branch, then checks the build and tests before wrapping up. Use it when several conflicted files need focused fixes without a refactor. CX Codex +1 2,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor