agentleFS
aaydin-traaydin-tr/swagger-navigator-mcp/.cursor/rules/typescript-standards.mdc

swagger-navigator-mcp / rules

Cursor rule2 starsChanged 17 months agoMITView on GitHub

  • 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 repository2 other files it gives its agents.

The file

We split this typescript-standards.mdc into the rules it gives an agent

12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    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:

    Use strict TypeScript configuration as defined in tsconfig.json

    line 9
  2. Distinctive:

    Prefer explicit type annotations for function parameters and return values

    line 10
  3. Distinctive:

    Use proper error handling with typed exceptions

    line 11
  4. Distinctive:

    Use clear, descriptive names for functions and variables

    line 17
  5. Distinctive:

    Use discriminated unions for complex type scenarios

    line 24
  6. Very specific:

    Avoid any type - use proper type definitions

    line 25
  7. Distinctive:

    Keep functions focused and single-purpose

    line 54
  8. Distinctive:

    Use descriptive parameter names

    line 55
  9. Very specific:

    Use UPPER_SNAKE_CASE for constants

    line 73
  10. Distinctive:

    Use environment variables for runtime configuration

    line 75
  11. Distinctive:

    Avoid magic numbers and strings

    line 76
  12. Distinctive:

    Use JSDoc for public APIs

    line 80

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
typescript-standards.mdc
---
alwaysApply: true
---

# TypeScript Standards

## Code Quality Guidelines

- Use strict TypeScript configuration as defined in [tsconfig.json](mdc:tsconfig.json)
- Prefer explicit type annotations for function parameters and return values
- Use proper error handling with typed exceptions
- Implement comprehensive input validation

## Module Organization

- Export functions and types explicitly
- Use clear, descriptive names for functions and variables
- Group related functionality in logical modules
- Maintain consistent import/export patterns

## Type Safety

- Define interfaces for all data structures in [types/](mdc:src/types/)
- Use discriminated unions for complex type scenarios
- Avoid `any` type - use proper type definitions
- Implement type guards where necessary

## Error Handling

```typescript
// Good: Typed error handling
function loadConfig(): Config {
  try {
    // ... loading logic
  } catch (error) {
    if (error instanceof yaml.YAMLException) {
      throw new Error(`Invalid YAML in configuration file: ${error.message}`);
    }
    throw error;
  }
}

// Good: Input validation
function validatePath(path: string): string {
  if (!path || typeof path !== "string") {
    throw new Error("Invalid path provided");
  }
  return resolve(path);
}
```

## Function Design

- Keep functions focused and single-purpose
- Use descriptive parameter names
- Include JSDoc comments for complex functions
- Return consistent data structures
- Handle edge cases explicitly

## Import/Export Patterns

```typescript
// Good: Explicit exports
export { loadConfig, detectSourceType, enrichConfigWithTypes };

// Good: Type-only imports when applicable
import type { Config, SourceConfig } from "./types/config";
import { readFileSync } from "fs";
```

## Constants and Configuration

- Use UPPER_SNAKE_CASE for constants
- Define configuration constants at module level
- Use environment variables for runtime configuration
- Avoid magic numbers and strings

## Code Documentation

- Use JSDoc for public APIs
- Include examples in documentation
- Document error scenarios
- Explain complex business logic
- Reference related modules and functions

---

# TypeScript Standards

## Code Quality Guidelines

- Use strict TypeScript configuration as defined in [tsconfig.json](mdc:tsconfig.json)
- Prefer explicit type annotations for function parameters and return values
- Use proper error handling with typed exceptions
- Implement comprehensive input validation

## Module Organization

- Export functions and types explicitly
- Use clear, descriptive names for functions and variables
- Group related functionality in logical modules
- Maintain consistent import/export patterns

## Type Safety

- Define interfaces for all data structures in [types/](mdc:src/types/)
- Use discriminated unions for complex type scenarios
- Avoid `any` type - use proper type definitions
- Implement type guards where necessary

## Error Handling

```typescript
// Good: Typed error handling
function loadConfig(): Config {
  try {
    // ... loading logic
  } catch (error) {
    if (error instanceof yaml.YAMLException) {
      throw new Error(`Invalid YAML in configuration file: ${error.message}`);
    }
    throw error;
  }
}

// Good: Input validation
function validatePath(path: string): string {
  if (!path || typeof path !== "string") {
    throw new Error("Invalid path provided");
  }
  return resolve(path);
}
```

## Function Design

- Keep functions focused and single-purpose
- Use descriptive parameter names
- Include JSDoc comments for complex functions
- Return consistent data structures
- Handle edge cases explicitly

## Import/Export Patterns

```typescript
// Good: Explicit exports
export { loadConfig, detectSourceType, enrichConfigWithTypes };

// Good: Type-only imports when applicable
import type { Config, SourceConfig } from "./types/config";
import { readFileSync } from "fs";
```

## Constants and Configuration

- Use UPPER_SNAKE_CASE for constants
- Define configuration constants at module level
- Use environment variables for runtime configuration
- Avoid magic numbers and strings

## Code Documentation

- Use JSDoc for public APIs
- Include examples in documentation
- Document error scenarios
- Explain complex business logic
- Reference related modules and functions

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.