mcpField
N
nestjs-clean-typescript

nestjs-clean-typescript

github.com/mindrallyDevelopment287948 installsUpdated 3w ago
Repository

About nestjs-clean-typescript

A set of guidelines for developers building NestJS APIs with TypeScript, focused on strong typing, clean code, and architectural practices. It includes NestJS-specific recommendations for modules, persistence, validation, and tests.

Key features

  1. 01Explicit types and naming conventions
  2. 02Short functions and immutable data
  3. 03Domain-based NestJS modules
  4. 04MikroORM persistence guidance
  5. 05DTO validation with class-validator
  6. 06Jest unit and end-to-end testing

Use cases

  1. 01Structuring a NestJS API by domain
  2. 02Applying consistent TypeScript conventions
  3. 03Validating API DTOs
  4. 04Planning unit and end-to-end tests

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mindrally/skills --skill nestjs-clean-typescript

After installing, type/nestjs-clean-typescriptin Claude Code to confirm it loaded.

Details

From the project README

NestJS Clean TypeScript

Guidelines by Alberto Basalo for developing clean NestJS APIs using TypeScript. These rules emphasize strong typing, clean code principles, and architectural best practices.

TypeScript General Principles

  • Always declare the type of each variable and function (parameters and return value)
  • Avoid using any; create necessary types instead
  • Use JSDoc for public classes and methods
  • One export per file

Naming Conventions

  • PascalCase for classes
  • camelCase for variables and functions
  • kebab-case for files and directories
  • UPPERCASE for environment variables
  • Boolean variables use prefixes: isX, hasX, canX

Function Design

  • Write short functions with a single purpose. Less than 20 instructions
  • Use early returns to avoid nesting
  • Apply RO-RO pattern: pass objects for multiple parameters, return objects for results

Data and Classes

  • Prefer immutability for data with readonly and as const
  • Follow SOLID principles
  • Classes should have:
    • Less than 200 instructions
    • Fewer than 10 public methods
    • Fewer than 10 properties

NestJS Specific Guidelines

  • Use modular architecture with one module per domain/route
  • Use MikroORM entities for persistence
  • One service per entity
  • DTOs validated with class-validator
  • Global filters, middlewares, guards, and interceptors in core module

Testing

  • Use Jest framework
  • Follow Arrange-Act-Assert convention
  • Write unit tests for each public function
  • Include end-to-end tests per API module

Comments

Markdown supported