vendure-entity-reviewing

Review Vendure entities for missing VendureEntity inheritance, improper decorators, missing migrations, index violations, and TypeORM anti-patterns. Use when reviewing entity PRs or auditing data models.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "vendure-entity-reviewing" with this command: npx skills add meriley/claude-code-skills/meriley-claude-code-skills-vendure-entity-reviewing

Vendure Entity Reviewing

Purpose

Audit Vendure entities for violations and TypeORM anti-patterns.

Review Workflow

Step 1: Identify Entity Files

# Find entity files
find . -name "*.entity.ts"

# Find migration files
find . -name "*migration*.ts" -o -name "*Migration*.ts"

Step 2: Run Automated Checks

# === CRITICAL VIOLATIONS ===

# Not extending VendureEntity
grep -rn "export class.*Entity" --include="*.entity.ts" | grep -v "extends VendureEntity"

# Missing @Entity decorator
grep -rn "export class.*Entity" --include="*.entity.ts" | grep -v "@Entity"

# Direct repository injection (should use TransactionalConnection)
grep -rn "@InjectRepository" --include="*.service.ts"

# === HIGH PRIORITY ===

# Missing indexes on foreign keys
grep -rn "@ManyToOne\|@OneToMany" --include="*.entity.ts" -B 2 | grep -v "@Index"

# Missing DeepPartial constructor
grep -rn "export class.*extends VendureEntity" --include="*.entity.ts" -A 5 | grep -v "DeepPartial"

# Using 'any' type
grep -rn ": any" --include="*.entity.ts"

# === MEDIUM PRIORITY ===

# Missing nullable specification
grep -rn "@Column()" --include="*.entity.ts" | head -20

# Date stored as string (should be timestamp)
grep -rn "type: 'varchar'.*[dD]ate\|[dD]ate.*type: 'varchar'" --include="*.entity.ts"

Step 3: Manual Review Checklist

Entity Structure

  • Extends VendureEntity
  • @Entity() decorator present
  • DeepPartial<T> constructor
  • Proper column types
  • Nullable specified where needed

Relations

  • @Index on foreign key columns
  • Cascade options appropriate
  • OnDelete behavior specified
  • Eager loading only where necessary

Migrations

  • Migration file exists for new entities
  • Migration has both up() and down()
  • Indexes created in migration
  • Column types match entity

Severity Classification

CRITICAL (Must Fix)

  • Not extending VendureEntity
  • Missing @Entity decorator
  • Direct repository injection
  • No migration for schema change

HIGH (Should Fix)

  • Missing index on foreign key
  • No DeepPartial constructor
  • Using any type
  • Missing onDelete behavior

MEDIUM (Should Fix)

  • Missing nullable specification
  • Date stored as string
  • No column default values

Common Violations

1. Not Extending VendureEntity

Violation:

@Entity()
export class MyEntity {
  // Missing extends!
  @PrimaryGeneratedColumn()
  id: number;
}

Fix:

@Entity()
export class MyEntity extends VendureEntity {
  constructor(input?: DeepPartial<MyEntity>) {
    super(input);
  }
}

2. Missing Index on Foreign Key

Violation:

@ManyToOne(() => Product)
product: Product;

@Column()
productId: number;  // No index!

Fix:

@Index()
@ManyToOne(() => Product)
product: Product;

@Column()
productId: number;

3. Direct Repository Injection

Violation:

@Injectable()
export class MyService {
  constructor(
    @InjectRepository(MyEntity) // WRONG
    private repo: Repository<MyEntity>,
  ) {}
}

Fix:

@Injectable()
export class MyService {
  constructor(
    private connection: TransactionalConnection, // CORRECT
  ) {}

  async find(ctx: RequestContext) {
    return this.connection.getRepository(ctx, MyEntity).find();
  }
}

4. Missing DeepPartial Constructor

Violation:

@Entity()
export class MyEntity extends VendureEntity {
  @Column()
  name: string;
  // No constructor!
}

Fix:

@Entity()
export class MyEntity extends VendureEntity {
  constructor(input?: DeepPartial<MyEntity>) {
    super(input);
  }

  @Column()
  name: string;
}

5. Using Any Type

Violation:

@Column({ type: 'simple-json' })
metadata: any;  // No type safety!

Fix:

interface MyMetadata {
  key: string;
  value: number;
}

@Column({ type: 'simple-json', nullable: true })
metadata: MyMetadata | null;

Quick Detection Commands

# All-in-one entity audit
echo "=== CRITICAL: Not extending VendureEntity ===" && \
grep -rn "export class.*Entity" --include="*.entity.ts" | grep -v "extends VendureEntity" && \
echo "" && \
echo "=== HIGH: Missing @Index ===" && \
grep -rn "@ManyToOne" --include="*.entity.ts" -B 2 | grep -v "@Index" && \
echo "" && \
echo "=== MEDIUM: Using any ===" && \
grep -rn ": any" --include="*.entity.ts"

Migration Review Checklist

When entity changes, verify:

  • Migration file created
  • Table/columns match entity
  • Indexes created for foreign keys
  • down() properly reverses up()
  • No data loss in down()
  • Column types correct (int, varchar, timestamp, etc.)

Review Output Template

## Entity Review: [Entity Name]

### Summary

[Overview of entity quality]

### Critical Issues (Must Fix)

- [ ] [Issue] - `file:line`

### High Priority

- [ ] [Issue] - `file:line`

### Passed Checks

- [x] Extends VendureEntity
- [x] @Entity decorator present
- [x] Migration exists

### Recommendations

- [Suggestions]

Cross-Reference

All rules match patterns in vendure-entity-writing skill.


Related Skills

  • vendure-entity-writing - Entity patterns
  • vendure-plugin-reviewing - Plugin-level review

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

obs-cpp-qt-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

vendure-admin-ui-writing

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

vendure-entity-writing

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

vendure-admin-ui-reviewing

No summary provided by upstream source.

Repository SourceNeeds Review