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.
git clone --depth 1 https://github.com/pr-pm/prpmWrote 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/rules/pr-pm/prpm/typescript-type-safety)<a href="https://agentmods.dev/rules/pr-pm/prpm/typescript-type-safety"><img src="https://agentmods.dev/badge/rules/pr-pm/prpm/typescript-type-safety/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/pr-pm/prpm/typescript-type-safety"><img src="https://agentmods.dev/badge/rules/pr-pm/prpm/typescript-type-safety.svg" alt="Reviewed on agentmods" width="80" 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.1 | $0.00035 | $0.01663 |
| Opus 5.5 | $0.00014 | $0.00665 |
| Sonnet 5.5 | $0.00007 | $0.00333 |
| Haiku 4.5 | $0.00003 | $0.00166 |
Grade A, and why
typescript-type-safety 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 1mo 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 — 258 lines — stays where its author put it; the contents beside it link to each section on GitHub.
TypeScript Type Safety
Overview
Zero tolerance for any types. Every any is a runtime bug waiting to happen.
Replace any with proper types using interfaces, unknown with type guards, or generic constraints. Use @ts-expect-error with explanation only when absolutely necessary.
When to Use
Use when you see:
: anyin function parameters or return typesas anytype assertions- TypeScript errors you're tempted to ignore
- External libraries without proper types
- Catch blocks with implicit
any
Don't use for:
- Already properly typed code
- Third-party
.d.tsfiles (contribute upstream instead)
Type Safety Hierarchy
Prefer in this order:
- Explicit interface/type definition
- Generic type parameters with constraints
- Union types
unknown(with type guards)never(for impossible states)
Never use: any
Quick Reference
| Pattern | Bad | Good |
|---|---|---|
| Error handling | catch (error: any) |
catch (error) { if (error instanceof Error) ... } |
| Unknown data | JSON.parse(str) as any |
const data = JSON.parse(str); if (isValid(data)) ... |
| Type assertions | (request as any).user |
(request as AuthRequest).user |
| Double casting | return data as unknown as Type |
Align interfaces instead: make types compatible |
| External libs | const server = fastify() as any |
declare module 'fastify' { ... } |
| Generics | function process(data: any) |
function process<T extends Record<string, unknown>>(data: T) |
Implementation
Error Handling
// ❌ BAD
try {
await operation();
} catch (error: any) {
console.error(error.message);
}
// ✅ GOOD - Use unknown and type guard
try {
await operation();
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
} else {
console.error('Unknown error:', String(error));
}
}
// ✅ BETTER - Helper function
function toError(error: unknown): Error {
if (error instanceof Error) return error;
return new Error(String(error));
}
try {
await operation();
} catch (error) {
const err = toError(error);
console.error(err.message);
}
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.
- 1mo ago First seen · 258 lines · 35 tokens per session scan A 2ca3e5f315c1
typescript-type-safety is a cursor rule published in the GitHub repository pr-pm/prpm (123 stars, last pushed 5d ago), licensed MIT. It adds 35 tokens to every session and 1,663 once invoked, about $0.0001 per session on Opus 5.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-09-03.
Other cursor rules, from other repositories
nextjs-tanstack-query-cursorrules-prompt-file
Cursor rules for Next.js App Router with TanStack Query v5, covering the HydrationBoundary pattern, Server Actions as mutations, and optimistic updates.
jest-unit-testing-cursorrules-prompt-file
Cursor rules for Jest development with unit testing.
nextjs-tanstack-query
Next.js App Router combined with TanStack Query v5 — HydrationBoundary pattern, Server Actions as mutations, optimistic updates, and infinite scroll.
nextjs-supabase-shadcn-pwa-cursorrules-prompt-file
Cursor rules for Nextjs Supabase Shadcn Pwa.
sveltekit-tailwindcss-typescript-cursorrules-promp
Cursor rules for SvelteKit development with Tailwind CSS and TypeScript integration.
chrome-extension-dev-js-typescript-cursorrules-pro
Cursor rules for VSCode extension development with Electron and TypeScript integration.