_code-rules-TypeScript-summary

A concise set of rules for writing and editing TypeScript, a programming language that adds types to JavaScript. It covers code structure, formatting, naming, imports, validation, errors and asynchronous work.

In plain words
What is it for?
Use it when creating or changing .ts files and shared TypeScript modules.
Why use it?
It gives developers one consistent standard for shared TypeScript code and helps catch unclear structure, weak typing and mixed responsibilities during review.

Cursor rule for Cursor

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 rules/brainy-builds/ts-inspect-cli/_code-rules-typescript-summary
Clone the repo
git clone --depth 1 https://github.com/Brainy-Builds/ts-inspect-cli

Made for: Cursor.

Per session 4,354 This file is loaded in full into every session.
When invoked 4,354 The same file — it is already loaded in full.
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.04354 $0.04354
Opus 5 $0.02177 $0.02177
Sonnet 5 $0.00871 $0.00871
Haiku 4.5 $0.00435 $0.00435

Measured yesterday against content hash 8bafc1948039, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

_code-rules-TypeScript-summary 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 yesterday.

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/_code-rules-TypeScript-summary.mdc · 176 lines

How it starts

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

This file is an always-applied concise summary of ./.cursor/rules/_code-rules-TypeScript.mdc. Every rule below is binding; when a point is ambiguous or an edge case arises, read the original ./.cursor/rules/_code-rules-TypeScript.mdc for the full rationale, canonical code examples, and boundary clarifications.

PRINCIPLES

  • DRY - one authoritative location for every piece of knowledge.
  • SoC - each module and function owns exactly one concern.
  • Modularity - small, named, independently testable units connected by stable typed interfaces.
  • Readability - names and structure carry meaning; comments fill only gaps code cannot convey.
  • Iterability - changes to one concern must not cascade into unrelated code.

FORMATTING

  • Indent with 1 tab (\t) per level; never spaces.
  • Double quotes ("…") for all string literals; template literals only for interpolation or multiline strings; never single quotes.
  • Terminate every statement with a semicolon (;).
  • Use only a plain hyphen-minus (-); never an en dash or em dash.
  • Maximum 100 physical lines per named function/method (blank lines count; JSDoc above does not). Split responsibilities into smaller named functions when the limit would be exceeded.

TRAILING COMMAS & SEPARATORS

  • Multiline array literals, object literals, and call-site argument lists: trailing comma after the last item.
  • Formal parameter lists (non-empty): always a trailing comma after the last parameter, even on a single physical line (e.g. function foo(bar: Baz,)).
  • Empty parameter lists: no comma inside ().
  • Use commas to separate runtime lists (parameters, arguments, destructuring bindings, array/object elements, tuple element types). Generic lists <T, U> and import type { Foo, Bar } keep commas wherever TS/ECMAScript syntax requires them.
  • Use semicolons to separate members inside interface bodies and inline object-type shapes. Do not use ; between tuple element types.

NAMING CONVENTIONS

  • camelCase: variables, functions, parameters (leading _ allowed for unused; no trailing _).
  • UPPER_CASE: every hardcoded configuration literal assigned to a const (timeouts, limits, HTTP methods, status codes, path segments, feature flags, multipliers). Shared styling classes also use UPPER_CASE. Runtime-varying data (request fields, parsed JSON, loop indices, intermediates) stays camelCase unless it is a true compile-time-style constant.
  • PascalCase: classes, interfaces, type aliases.
  • No I prefix on interfaces (UserAccount, not IUserAccount).
  • snake_case bindings only when mirroring an external schema (REST/JSON, DB rows, vendor SDKs). Keep snake_case local and aligned with upstream field names only where renaming would obscure protocol or storage reality.

NO MAGIC NUMBERS

  • Never use a bare numeric literal directly in an expression. Assign it to a named UPPER_CASE const first, then reference the binding.
  • Exception: obvious pure-bookkeeping indices such as index + 1.
  • Domain-specific bare numbers (timeouts, HTTP codes, limits, geodetic bounds) must always be named first.

MULTILINE FORMATTING

  • Arrays / objects: one element or property per physical line.
  • Compound boolean predicates (&&, ||): one operand/sub-condition per physical line everywhere they appear - if, while, do…while, for-condition, ternary condition, const/let boolean bindings, return, throw.
  • for-loop headers: one clause per physical line (initializer / condition / update).
  • Non-empty function signatures: async (if any), function, and name on one line followed by (; one parameter per physical line (each ends with a trailing comma); close with ): ReturnType { on its own line. Empty parameter lists stay compact: function f().
  • Inline object type annotations ({ … }): expand across multiple lines - { alone, each member: Type; on its own line, } alone before =, ), :, as, or the following token. Prefer a type/interface under ./src/types/** when the shape repeats.

VARIABLES

  • Never var.
  • const by default; let only when a binding must be reassigned.
  • Destructuring: const when no binding in the pattern is reassigned; let when any binding needs reassignment. You cannot mark one binding const and another let in the same pattern - split into multiple declarations when only some fields must stay mutable.
  • let/const are block-scoped with a temporal dead zone; prefer them over var to avoid accidental reads before initialization and leakage across branches.

Read the full file on GitHub · 176 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. yesterday First seen · 176 lines · 4,354 tokens per session scan A 8bafc1948039

Subscribe to this mod's changes

_code-rules-TypeScript-summary is a cursor rule published in the GitHub repository Brainy-Builds/ts-inspect-cli (2 stars, last pushed 12d ago), licensed MIT. It adds 4,354 tokens to every session, about $0.0218 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.