agentsclimarketplace

Typescript best practices

Skill agent-packs/registry/skills/typescript-best-practices

Write type-safe TypeScript using strict settings, precise types, and disciplined migration patterns. Use when writing TS, reviewing types, or migrating from JavaScript.From its SKILL.md

Install
npx -y skills add agent-packs/registry --skill typescript-best-practices

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as Apache-2.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

3.2 KB, 665 tokens by cl100k_base, as published. Nobody here has run it

TypeScript Best Practices

Types are documentation that the compiler checks. Write types that reveal intent, not types that silence the compiler.

Compiler Settings

Always use "strict": true in tsconfig.json. Additionally enable:

  • "noUncheckedIndexedAccess": true — array and object index access returns T | undefined.
  • "exactOptionalPropertyTypes": true{ a?: string } means absent, not string | undefined.
  • "noImplicitReturns": true and "noFallthroughCasesInSwitch": true.
  • "moduleResolution": "bundler" (or "node16" / "nodenext") for modern module semantics.

Type Precision

  • Prefer unknown over any for values of unknown shape; narrow with type guards before use.
  • Use const assertions (as const) to preserve literal types in arrays and objects.
  • Model discriminated unions over class hierarchies for state machines and response variants.
  • Avoid ! non-null assertions; prefer explicit narrowing or nullish coalescing (??).
  • Use satisfies to validate a value against a type without widening the inferred type.
  • Prefer readonly arrays and properties in function signatures; mutate via explicit copies.

Functions and Generics

  • Annotate return types explicitly on all exported functions to prevent accidental widening.
  • Constrain generics minimally: <T extends string> not <T> when you only need string operations.
  • Prefer function overloads over union parameter types when the return type changes with input shape.
  • Use Parameters<typeof fn>, ReturnType<typeof fn>, and Awaited<T> over duplicating types.

Narrowing and Type Guards

  • Use typeof, instanceof, in, and discriminant property checks — not as casts.
  • Write user-defined type guards (value is Type) only when built-in narrowing cannot express the check.
  • Use exhaustiveness checks: default: { const _: never = x; throw new Error('unhandled case'); }.
  • Never use as unknown as TargetType as a shortcut — it hides real type errors.

JavaScript Migration

  1. Add "allowJs": true and "checkJs": true — fix reported errors without renaming files.
  2. Rename files leaf-first: modules with no imports of other JS files first, then work up the dependency graph.
  3. Generate .d.ts stubs for third-party modules missing types before adding them to the graph.
  4. Replace @ts-ignore with @ts-expect-error plus a reason comment; delete when fixed.
  5. Enable strict only after the codebase is fully .ts — tackle one error category at a time.

Code Review Checklist

  • No any in new or changed code — use unknown + narrowing or a named type.
  • All exported API surfaces have explicit return type annotations.
  • Discriminated unions cover all cases with exhaustiveness checks.
  • "strict": true in tsconfig; no new skipLibCheck suppressions.
  • No as casts that skip validation; use type guards instead.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,452. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.