typescript-best-practices

typescript-best-practices is a skill for Claude Code, Codex from ofershap/typescript-best-practices. It costs 40 tokens per session (2,254 once invoked), scanned A, original, MIT.

A set of guidelines for writing safer, more precise TypeScript 5.x code, including strict compiler checks and type-safe patterns.

In plain words
What is it for?
Use it when creating or reviewing TypeScript code, especially configuration, data models, and code that needs strong compile-time checks.
Why use it?
It helps prevent common mistakes such as unsafe types, unchecked data access, and outdated TypeScript techniques.

Skill for Claude CodeCodex

Part of the typescript-best-practices plugin — 1 skill, 1 command shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ofershap/typescript-best-practices/typescript-best-practices
Any agent
npx skills add ofershap/typescript-best-practices --skill typescript-best-practices
Clone the repo
git clone --depth 1 https://github.com/ofershap/typescript-best-practices

Made for: Claude Code, Codex.

Or install typescript-best-practices, the plugin that ships this one along with the rest of its 1 skill, 1 command.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for typescript-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/ofershap/typescript-best-practices/typescript-best-practices.svg)](https://agentmods.dev/skills/ofershap/typescript-best-practices/typescript-best-practices)
Your own site
<a href="https://agentmods.dev/skills/ofershap/typescript-best-practices/typescript-best-practices"><img src="https://agentmods.dev/badge/skills/ofershap/typescript-best-practices/typescript-best-practices.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,254 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00040 $0.02254
Opus 5 $0.00020 $0.01127
Sonnet 5 $0.00008 $0.00451
Haiku 4.5 $0.00004 $0.00225

Measured 5d ago against content hash 4668d920633f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

typescript-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/typescript-best-practices/SKILL.md · 374 lines

How it starts

The opening of the file, as written. The whole thing — 374 lines — stays where its author put it; the contents beside it link to each section on GitHub.

When to use

Use this skill when working with TypeScript code. AI agents frequently generate outdated patterns - using any instead of unknown, type assertions instead of satisfies, optional fields instead of discriminated unions, and missing strict mode options. This skill enforces modern TypeScript 5.x patterns.

Critical Rules

1. Enable Strict Mode with All Checks

Wrong (agents do this):

{
  "compilerOptions": {
    "strict": false,
    "target": "ES2020"
  }
}

Correct:

{
  "compilerOptions": {
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "noImplicitOverride": true,
    "target": "ES2022"
  }
}

Why: Strict mode catches entire categories of bugs. noUncheckedIndexedAccess prevents unsafe array/object access. Agents often skip these for "convenience."

2. Use satisfies Instead of Type Assertions

Wrong (agents do this):

const config = {
  port: 3000,
  host: "localhost",
} as Config;

config.port.toFixed(); // No error even if port could be string

Correct:

const config = {
  port: 3000,
  host: "localhost",
} satisfies Config;

config.port.toFixed(); // TypeScript knows port is number

Why: satisfies validates the type without widening it. as silences the compiler and can hide bugs. Use satisfies for validation, as only when you genuinely know more than the compiler.

3. Use Discriminated Unions Over Optional Fields

Wrong (agents do this):

interface ApiResponse {
  data?: User;
  error?: string;
  loading?: boolean;
}

Correct:

type ApiResponse =
  | { status: "loading" }
  | { status: "success"; data: User }
  | { status: "error"; error: string };

Why: Optional fields allow impossible states (data AND error both present). Discriminated unions make each state explicit and exhaustively checkable.

4. Use const Assertions for Literal Types

Read the full file on GitHub · 374 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 374 lines · 40 tokens per session scan A 4668d920633f

Subscribe to this mod's changes

typescript-best-practices is a skill published in the GitHub repository ofershap/typescript-best-practices (9 stars, last pushed 6mo ago), licensed MIT. It adds 40 tokens to every session and 2,254 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.