cursor-rules / rules
Cursor rule8 starsChanged 19 months agoMITView on GitHub
TypeScript Development Standards
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 1,533 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 repository17 other files it gives its agents.
- .cursor/rules/aws-bedrock.mdcCursor rule
- .cursor/rules/aws-cloudformation.mdcCursor rule
- .cursor/rules/aws-dynamodb.mdcCursor rule
- .cursor/rules/aws-eventbridge.mdcCursor rule
- .cursor/rules/aws-gamelift.mdcCursor rule
- .cursor/rules/aws-iam.mdcCursor rule
- .cursor/rules/aws-lambda.mdcCursor rule
- .cursor/rules/aws-sagemaker.mdcCursor rule
- .cursor/rules/aws-sam.mdcCursor rule
- .cursor/rules/aws-vpc.mdcCursor rule
- .cursor/rules/base.mdcCursor rule
- .cursor/rules/docs-structure.mdcCursor rule
- .cursor/rules/expo.mdcCursor rule
- .cursor/rules/nextjs.mdcCursor rule
- .cursor/rules/react.mdcCursor rule
- .cursor/rules/react-native.mdcCursor rule
- .cursor/rules/readme-documentation.mdcCursor rule
The file
Show its rules and text
We split this typescript.mdc into the rules it gives an agent
35 rules. About 0 are common, 24 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈24
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Avoid using any type unless absolutely necessary
- Distinctive: line 17
Use type inference where it improves readability
- Distinctive: line 19
Create reusable type definitions for common patterns
- Very specific: line 25
Use PascalCase for interface and type names (e.g., UserProfile)
- Very specific: line 27
Use descriptive names that convey purpose (e.g., ApiResponse rather than just Response)
- Very specific: line 28
Avoid prefixing interfaces with 'I' (prefer User over IUser)
- Distinctive: line 31
Use interfaces for object shapes primarily
- Distinctive: line 32
Use type aliases for unions, intersections, or complex types
- Distinctive: line 33
Prefer interfaces for public APIs to support declaration merging
- Distinctive: line 34
Keep type definitions close to where they are used
- Very specific: line 39
Use unknown instead of any when type is unclear
- Distinctive: line 40
Use union types to represent values that could be of different types
- Distinctive: line 42
Add appropriate type guards when narrowing types
- Very specific: line 43
Use readonly modifiers for immutable properties
- Very specific: line 44
Use as const for literal values when appropriate
- Very specific: line 49
Use optional chaining (?.) to safely access nested properties
- Very specific: line 50
Use nullish coalescing (??) to provide default values
- Distinctive: line 51
Use template literal types for string manipulations
- Distinctive: line 53
Use conditional types for type-level programming
- Distinctive: line 55
Use const assertions for readonly arrays and tuples
- Distinctive: line 58
Create and use custom error types
- Distinctive: line 59
Use discriminated unions for type-safe error handling
- Very specific: line 63
Prefer arrow functions for consistent this binding
- Distinctive: line 64
Use function overloads for functions with complex type relationships
- Distinctive: line 65
Use rest parameters instead of arguments object
- Distinctive: line 70
Use async/await over Promise chains
- Distinctive: line 73
Use Promise.all/allSettled for parallel operations
- Distinctive: line 77
Use path aliases to simplify imports
- Distinctive: line 82
Use ES modules with named exports
- Distinctive: line 88
Document complex types with JSDoc/TSDoc comments
- Distinctive: line 90
Document constraints and invariants that types enforce
- Very specific: line 91
Use @deprecated tags when phasing out types
- Distinctive: line 94
Use type-aware testing frameworks
- Distinctive: line 95
Test type constraints with compile-time tests
- Distinctive: line 96
Ensure tests cover edge cases in type handling
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- description: TypeScript Development Standards globs: alwaysApply: false --- --- Description: TypeScript Development Standards Globs: **/*.ts, **/*.tsx, **/*.mts, **/*.cts --- # TypeScript Development Standards @base.mdc ## Core TypeScript Principles - Leverage TypeScript's static typing to catch errors at compile time - Avoid using `any` type unless absolutely necessary - Use type inference where it improves readability - Define explicit return types for functions - Create reusable type definitions for common patterns - Take advantage of TypeScript's advanced type features when appropriate ## Type Definitions ### Naming - Use PascalCase for interface and type names (e.g., `UserProfile`) - Prefix interfaces for React component props with component name (e.g., `ButtonProps`) - Use descriptive names that convey purpose (e.g., `ApiResponse` rather than just `Response`) - Avoid prefixing interfaces with 'I' (prefer `User` over `IUser`) ### Structure - Use interfaces for object shapes primarily - Use type aliases for unions, intersections, or complex types - Prefer interfaces for public APIs to support declaration merging - Keep type definitions close to where they are used - Export types that are used across multiple files ### Type Safety - Enable strict type checking in `tsconfig.json` - Use `unknown` instead of `any` when type is unclear - Use union types to represent values that could be of different types - Utilize generics for flexible, reusable code - Add appropriate type guards when narrowing types - Use `readonly` modifiers for immutable properties - Use `as const` for literal values when appropriate ## Best Practices ### Modern TypeScript Features - Use optional chaining (`?.`) to safely access nested properties - Use nullish coalescing (`??`) to provide default values - Use template literal types for string manipulations - Apply mapped types to transform existing types - Use conditional types for type-level programming - Leverage utility types (e.g., `Partial<T>`, `Required<T>`, `Pick<T>`, `Omit<T>`) - Use const assertions for readonly arrays and tuples ### Error Handling - Create and use custom error types - Use discriminated unions for type-safe error handling - Implement Result types for functions that can fail ### Functions - Prefer arrow functions for consistent `this` binding - Use function overloads for functions with complex type relationships - Use rest parameters instead of arguments object - Destructure objects in function parameters for clarity - Provide explicit return types for non-trivial functions ### Async Code - Use async/await over Promise chains - Properly type Promise results - Handle errors in async functions with try/catch - Use Promise.all/allSettled for parallel operations ## Environment Configuration - Set appropriate target and lib settings in tsconfig.json - Use path aliases to simplify imports - Enable incremental compilation for larger projects - Configure appropriate module resolution ## Organizing Code - Use ES modules with named exports - Group related types in namespaces or dedicated type files - Organize code with barrel files (index.ts) for cleaner imports - Split complex types into smaller, composed types ## Documentation - Document complex types with JSDoc/TSDoc comments - Include examples for non-obvious type usage - Document constraints and invariants that types enforce - Use `@deprecated` tags when phasing out types ## Testing - Use type-aware testing frameworks - Test type constraints with compile-time tests - Ensure tests cover edge cases in type handling
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
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.

