type_layer_rules

A set of rules for writing TypeScript type definitions and interfaces, which describe the shape of data in a program. It covers shared types, API requests and responses, and component properties in a frontend project.

In plain words
What is it for?
Use it when adding or reviewing frontend types, API contracts, authentication or configuration models, status values, reusable type patterns, and component property definitions.
Why use it?
It keeps data descriptions consistent and helps catch mismatches between parts of the application before they cause runtime problems.

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/modelengine-group/nexent/type_layer_rules
Clone the repo
git clone --depth 1 https://github.com/ModelEngine-Group/nexent

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 471 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.00471
Opus 5 $0.00000 $0.00235
Sonnet 5 $0.00000 $0.00094
Haiku 4.5 $0.00000 $0.00047

Measured 2d ago against content hash f17c8854f754, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

type_layer_rules 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 2d 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/frontend/type_layer_rules.mdc · 68 lines

What it actually says

Purpose and Scope

  • Type layer contains TypeScript definitions for frontend/types/**/*.ts
  • Responsibilities: Define type-safe interfaces, API types, reusable utilities, ensure consistency
  • MANDATORY: All types must be exported and use TypeScript

Type Organization

  • types/auth.ts - Authentication-related types
  • types/chat.ts - Chat and conversation types
  • types/config.ts - Configuration types
  • types/api.ts - API-related types
  • Use descriptive names matching the domain they represent

Type Definition Standards

  • Use interfaces for object shapes and API contracts
  • Use type aliases for unions, primitives, and computed types
  • Use enums for fixed sets of string/number values
  • Use generic types for reusable type patterns
  • Export all types for use in other modules

API Type Definitions

  • Define separate interfaces for request and response data
  • Use consistent naming conventions (e.g., UserRequest, UserResponse)
  • Include optional fields with proper typing
  • Use union types for status fields and enums
  • Provide JSDoc comments for complex types

Component Props Types

  • Define interfaces for all component props
  • Use descriptive property names
  • Include proper optional/required field indicators
  • Use generic types for reusable component patterns
  • Export types for use in component files
  • CRITICAL: All logging must use logger.ts - never use console.log

Utility Types

  • Create utility types for common patterns
  • Use mapped types for transformations
  • Implement conditional types for complex logic
  • Provide type guards for runtime validation

Example

// frontend/types/auth.ts
export interface User {
  id: string;
  email: string;
  name: string;
  avatar?: string;
  role: UserRole;
  createdAt: string;
  updatedAt: string;
}

// Utility types
export type UserUpdateData = Partial<Pick<User, 'name' | 'avatar'>>;
export type UserCreateData = Omit<User, 'id' | 'createdAt' | 'updatedAt'>;
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. 2d ago First seen · 68 lines · 0 tokens per session scan A f17c8854f754

Subscribe to this mod's changes

type_layer_rules is a cursor rule published in the GitHub repository ModelEngine-Group/nexent (5,841 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 471 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-30.