agentleFS
maleus-aimaleus-ai/claude-code-setup/.cursor/rules/typescript/RULE.md

typescript

Cursor rule1 starsChanged 10 months agoMITView on GitHub

Contains rules that MUST ALWAYS be applied to EVERY TypeScript file. Covers method definitions, constants, imports, and type safety. CRITICAL INSTRUCTION You MUST ALWAYS use this skill before editing/writing any file matching "**/*.ts".

66 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use msw, rust and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • thongdn-itSkill

    msw

    MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.

    Also in 3 projects that use this

  • MicrosoftSkill

    rust

    Use this guide when working on Rust changes in the FAST monorepo.

    Also in 9 projects that use this

  • SupabaseSkill

    react-hook-form

    Correct React Hook Form usage anywhere in the monorepo — data flow, subscriptions,

    Also in 3 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 10 projects that use this

  • leonaaardobSkill

    drizzle

    Complete Drizzle ORM documentation in markdown format. Use when working with Drizzle ORM - covers schema definition, queries, migrations, database connections (PostgreSQL, MySQL, SQLite), integrations (Neon, Supabase, PlanetScale, Cloudflare D1, Turso), column types, relations, transactions, and framework usage (Next.js, SvelteKit, Astro).

    Also in 3 projects that use this

  • thongdn-itSkill

    tailwind

    Tailwind CSS v4 performance optimization and best practices guidelines (formerly tailwindcss-v4-style). This skill should be used when writing, reviewing, or refactoring Tailwind CSS v4 code to ensure optimal build performance, minimal CSS output, and correct usage of v4 features. Triggers on tasks involving Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.

    Also in 5 projects that use this

  • +1 more from thongdn-it
  • Other versions66 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 66

    1. lobehub/lobe-chat★ 84ksame name
    2. lobehub/lobehub★ 84ksame name
    3. recharts/recharts★ 28ksame name
    4. ccusage/ccusage★ 19ksame name
    5. ryoppippi/ccusage★ 19ksame name
    6. scalar/scalar★ 16ksame name
    7. prowler-cloud/prowler★ 15ksame name
    8. microsoft/fast★ 9.7ksame name
    9. epicenter-md/epicenter★ 4.8ksame name
    10. EpicenterHQ/epicenter★ 4.8ksame name

    56 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,181 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

The file

We split this RULE.md into the rules it gives an agent

6 rules. 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 52 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When you receive unknown, you MUST narrow it before use:

    line 20
  2. Distinctive:

    Always use object as method parameter to have named keys:

    line 57
  3. Distinctive:

    Always use constants for magic numbers:

    line 77
  4. Very specific:

    Always use the node: prefix for stdlib imports:

    line 90
  5. Very specific:

    If you import only a type, use the type modifier:

    line 104
  6. Distinctive:

    Always use exhaustive type checking for union types in switch statements:

    line 116

“Common” is measured: kept by at least 6 in 10 of the 52 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
RULE.md

TypeScript Coding Rules

Type Safety (CRITICAL)

This is the most important section. Type safety is non-negotiable.

Never use any

The any type completely bypasses TypeScript's type system. You MUST NOT use it under any circumstances.

Avoid unknown without narrowing

When you receive unknown, you MUST narrow it before use:

// ❌ BAD: Using unknown without narrowing
function handle(input: unknown) {
  return input.toString(); // Error or unsafe
}

// ✅ GOOD: Narrow with type guards
function handle(input: unknown): string {
  if (typeof input === "string") {
    return input;
  }
  if (typeof input === "number") {
    return String(input);
  }
  throw new Error("Unsupported type");
}

Never use non-null assertions (!)

The ! operator is FORBIDDEN. Always use proper type guards or optional chaining.

// ❌ WRONG
const name = user!.name;

// ✅ CORRECT
if (!user) {
  throw new Error("User is required");
}
const name = user.name;

Method Definition

Always use object as method parameter to have named keys:

// ❌ BAD
function createUser(name: string, age: number, email: string) {}

// ✅ GOOD
function createUser({
  name,
  age,
  email,
}: {
  name: string;
  age: number;
  email: string;
}) {}

Number Constants

Always use constants for magic numbers:

// ❌ BAD
bcrypt.hash(password, 10);

// ✅ GOOD
const SALT_ROUNDS = 10;
bcrypt.hash(password, SALT_ROUNDS);

Node Stdlib Imports

Always use the node: prefix for stdlib imports:

// ❌ BAD
import assert from "assert";
import fs from "fs/promises";

// ✅ GOOD
import assert from "node:assert";
import fs from "node:fs/promises";

Type Imports

If you import only a type, use the type modifier:

// ✅ GOOD
import type { UserRole } from "./users";

// or
import { User, type UserRole } from "./users";

Exhaustive Type Checking

Always use exhaustive type checking for union types in switch statements:

type Status = "pending" | "approved" | "rejected";

function handleStatus(status: Status): string {
  switch (status) {
    case "pending":
      return "Processing...";
    case "approved":
      return "Approved!";
    case "rejected":
      return "Rejected.";
    default:
      // Ensure all cases are handled
      status satisfies never;
      throw new Error(`Unhandled status: ${status}`);
  }
}

This pattern ensures that if a new value is added to the union type, TypeScript will show a compile-time error until all cases are handled.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.