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.
npx agentmods add skills/ofershap/typescript-best-practices/typescript-best-practicesnpx skills add ofershap/typescript-best-practices --skill typescript-best-practicesgit clone --depth 1 https://github.com/ofershap/typescript-best-practicesWrote 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.
[](https://agentmods.dev/skills/ofershap/typescript-best-practices/typescript-best-practices)<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>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.
| Model | Per session | Once 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 |
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.
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
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.
- 5d ago First seen · 374 lines · 40 tokens per session scan A 4668d920633f
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.
Other skills, from other repositories
typescript-language
Apply modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings.
typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling.
typescript-best-practices
Write idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic.
typescript-idioms
TypeScript strict mode, type narrowing, Zod validation, vitest, ESLint flat config.
hono-idioms
Hono HTTP framework patterns — routing, middleware, Zod validation, RPC client. For TypeScript see typescript-idioms.
typescript-best-practices
Enforces TypeScript best practices and modern patterns.