typescript

typescript is a cursor rule for Cursor from kok-o/koko-contextos-agents. It costs 0 tokens per session (1,207 once invoked), scanned A, original, MIT.

A set of rules for writing safer and more consistent TypeScript, a programming language that adds type checking to JavaScript. It covers strict compiler settings, type design, error handling, and exported functions.

In plain words
What is it for?
Use it when creating or reviewing TypeScript code, especially shared functions, object types, constants, error handling, and compiler configuration.
Why use it?
It prevents common type and null-handling mistakes by requiring the code to handle uncertain values explicitly. It also makes public code easier for other developers to use safely.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when creating or reviewing TypeScript code, especially shared functions, object types, constants, error handling, and compiler configuration.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/kok-o/koko-contextos-agents/typescript
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.

Clone the repo
git clone --depth 1 https://github.com/kok-o/koko-contextos-agents

Made for: Cursor.

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

README.md
[![agentmods](https://agentmods.dev/badge/rules/kok-o/koko-contextos-agents/typescript/github.svg)](https://agentmods.dev/rules/kok-o/koko-contextos-agents/typescript)
Your own site
<a href="https://agentmods.dev/rules/kok-o/koko-contextos-agents/typescript"><img src="https://agentmods.dev/badge/rules/kok-o/koko-contextos-agents/typescript/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.

agentmods 80×15 button for typescript

Your own site · 80×15
<a href="https://agentmods.dev/rules/kok-o/koko-contextos-agents/typescript"><img src="https://agentmods.dev/badge/rules/kok-o/koko-contextos-agents/typescript.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,207 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.01207
Opus 5.5 $0.00000 $0.00483
Sonnet 5.5 $0.00000 $0.00241
Haiku 4.5 $0.00000 $0.00121

Measured 3mo ago against content hash f5e224d4fdea, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

typescript 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 3mo 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.

.cursor/rules/typescript.mdc · 181 lines

How it starts

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

Skill: TypeScript

TypeScript

Overview

A brief summary of what the skill does and its core philosophy.

When to Use

Context for when this skill is applicable.

Negative Constraints (What NOT to Do)

  1. NEVER use any: Use unknown with type guards, discriminated unions, or Zod schemas.
  2. NEVER use type assertions (as Type or as unknown as Type) to bypass safety: Fix the underlying type signature or use runtime narrowing (instanceof, typeof, in).
  3. NEVER use non-null assertions (foo!.bar): Handle null and undefined with optional chaining (?.) or explicit error guards.
  4. NEVER export mutable global arrays or object constants: Always mark constant objects and arrays with as const and readonly.
  5. NEVER omit explicit return types on exported functions: Exported public APIs must declare explicit return types to protect consumers.

Rules & Patterns

Strict Mode

Always use strict TypeScript configuration:

{
  "compilerOptions": {
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true
  }
}

Types

  • Prefer interface for object shapes, type for unions/intersections
  • No any — use unknown if type is truly unknown, then narrow
  • Explicit return types for exported functions
  • Const assertions — as const for literal types
// Good
interface User {
  id: string;
  name: string;
  role: 'admin' | 'user';
}

// Unions
type Result<T> = { ok: true; data: T } | { ok: false; error: string };

Utility Types

  • Partial<T> — all properties optional
  • Required<T> — all properties required
  • Pick<T, K> — select specific properties
  • Omit<T, K> — remove specific properties
  • Record<K, V> — key-value map

Type Guards

function isUser(value: unknown): value is User {
  return typeof value === 'object' && value !== null && 'id' in value;
}

Generic Patterns

Read the full file on GitHub · 181 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. 3mo ago First seen · 181 lines · 0 tokens per session scan A f5e224d4fdea

Subscribe to this mod's changes

typescript is a cursor rule published in the GitHub repository kok-o/koko-contextos-agents (2 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,207 tokens. 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.

Related

typescript compared with cursor rules from other repositories

typescript next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
typescriptkok-o/koko-contextos-agentsCursor rule22mo agoMITA0Cursor
typescript-type-safetypr-pm/prpmCursor rule1251mo agoMITA35Cursor
hatch3r-typescript-patternshatch3r/hatch3rCursor rule262mo agoMITA0Cursor
best-practicesofershap/typescript-best-practicesCursor rule99mo agoMITA174Cursor
general-typescript-ruleyujiosaka/knowhubCursor rule411y agoMITA0Cursor
typescript-styleDXHeroes/mcp-devtoolsCursor rule131y agoMITA410Cursor
javascript-vulnerable-outdated-componentsabderrahimghazali/cursor-rulesCursor rule21y agoMITA3,368Cursor