TypeScript guide

Keep useful inference and make invalid states hard to express.

pnpm dlx skills add SarthakMishra/skills --skill ts-guide

Use /ts-guide in Claude Code or $ts-guide in Codex. Read the skill.

Use it when a type loses information, allows impossible states or forces every caller to cast. Bring the implementation and examples of code that calls it, so the agent can check both sides.

Example prompts

/ts-guide Make the event name determine which payload this API accepts. Preserve inference for callers and test invalid calls.
$ts-guide Replace this bag of optional fields with states that narrow correctly. Keep the existing valid callers working.

How it works

The agent preserves inference through helpers, wrappers and generic APIs. It connects related inputs and outputs so, for example, an event name determines its payload type. It also models states so TypeScript rejects combinations that should never occur.

Changes include type checks for valid and invalid calls, including union and conditional-type edge cases. Reviews explain what the types allow or lose and whether the issue belongs to TypeScript or the framework.

This skill covers type design beyond introductory syntax. Data received at runtime still needs validation.

Works well with

  • React guide for component APIs and deciding where state belongs.
  • Code smell for removing casts and duplicated type definitions across a feature.