typeorm

Review TypeORM code to eliminate raw SQL and enforce repository patterns.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/lety-ai/lety-skill-hub --skill typeorm-lety-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typeorm
Source: https://github.com/lety-ai/lety-skill-hub/tree/main/plugins/typeorm/skills/typeorm
Command: npx skills add https://github.com/lety-ai/lety-skill-hub --skill typeorm-lety-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents unsafe or non-idiomatic database access in NestJS applications using TypeORM 0.3.x DataSource by eliminating raw SQL, insecure string-based queries, incorrect relation loading, and improper migration or transaction usage. It reduces runtime bugs, security vulnerabilities (SQL injection), and schema drift caused by ad-hoc DDL changes.

Core Features & Use Cases

  • Code reviews and audits: Detect repository.query/dataSource.query, string WHERE clauses, manual DDL, and unsafe transaction patterns and provide exact fixes.
  • Guided fixes and scaffolding: Produce entities, repository/service methods, and QueryBuilder implementations that follow TypeORM 0.3.x patterns and relation-loading rules.
  • Migration & transaction guidance: Instruct on CLI-based migration generation/run workflows and safe data-source transaction usage for multi-step updates.
  • Use Case: Convert a legacy service that uses raw SQL into a repository + QueryBuilder implementation with parameterized queries and a generated migration.

Quick Start

Use the typeorm skill to review the repository for raw SQL and anti-patterns then produce corrected TypeORM 0.3.x code and migration instructions citing the official docs.

Frequently Asked Questions about typeorm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate raw SQL in NestJS TypeORM repositories?

To eliminate raw SQL in NestJS TypeORM, replace repository.query calls with repository-based CRUD operations and parameterized QueryBuilder conditions, ensuring secure and idiomatic database access without string-based queries.

What's the best way to load relations using TypeORM QueryBuilder in NestJS?

The best way to load relations with TypeORM QueryBuilder is using join-and-select patterns or TypeORM relation options, avoiding manual joins to ensure proper entity mapping and safe relation loading in NestJS.

How do I generate TypeORM migrations via CLI in a NestJS project?

Generate TypeORM migrations via the CLI in NestJS by using the migration generation and run workflows, preventing schema drift caused by ad-hoc DDL changes and ensuring consistent database version control.

Does TypeORM 0.3.x DataSource support safe transaction patterns for multi-step updates?

TypeORM 0.3.x DataSource supports safe transaction patterns by using data-source transactions for multi-step updates, preventing partial writes and ensuring data integrity during complex repository operations.

Why should I use QueryBuilder instead of raw SQL queries in TypeORM?

You should use QueryBuilder instead of raw SQL in TypeORM to prevent SQL injection vulnerabilities, reduce runtime bugs from string-based queries, and enforce parameterized conditions for secure database access.

Can I convert a legacy service using raw SQL into a TypeORM repository implementation?

You can convert a legacy raw SQL service into a TypeORM repository implementation with parameterized QueryBuilder queries, proper relation loading, and CLI-generated migrations following TypeORM 0.3.x patterns.