← 返回 Skills 市场
charlie-morrison

Typeorm Schema Optimizer

作者 charlie-morrison · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
50
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install typeorm-schema-optimizer
功能描述
Optimize TypeORM entities for performance, query efficiency, migration safety, and relationship design — analyze decorators, indexes, eager loading, and conn...
使用说明 (SKILL.md)

TypeORM Schema Optimizer

Analyze TypeORM entities for performance issues, query inefficiencies, missing indexes, relationship design problems, and migration risks. Use when reviewing TypeORM schemas, optimizing slow queries, or preparing for production scale.

Usage

"Optimize my TypeORM entities"
"Check for N+1 queries in my TypeORM code"
"Audit TypeORM indexes and relations"
"Review migration safety for TypeORM changes"

How It Works

1. Entity Discovery

# Find all TypeORM entities
grep -rn "@Entity\|@ViewEntity\|@ChildEntity" src/ | head -20
# Find repositories
grep -rn "extends Repository\|@InjectRepository\|getRepository" src/ | head -20
# Check TypeORM config
cat ormconfig.json 2>/dev/null || cat data-source.ts 2>/dev/null

2. Schema Analysis

Column optimization:

  • Column types match actual data requirements
  • Unnecessary nullable: true on required fields
  • Missing length on string columns (default is VARCHAR(255) — wasteful or too short?)
  • Enum columns using string instead of native enum type
  • JSON columns where structured columns would be more queryable
  • Missing default values for common patterns

Index analysis:

  • Columns used in WHERE clauses without indexes
  • Composite indexes for multi-column queries
  • Covering indexes for SELECT-heavy queries
  • Unique constraints for business rules
  • Partial indexes for filtered queries
  • Index on foreign key columns (TypeORM doesn't auto-create)

Relationship design:

  • eager: true on relationships (loads every time, often unnecessary)
  • Missing cascade options where needed
  • Circular eager loading (infinite loops)
  • @ManyToMany without join table customization
  • Missing onDelete behavior (default is no action)
  • Polymorphic relationships using discriminators correctly

3. Query Performance

  • N+1 detection in repository methods
  • Missing leftJoinAndSelect where data is accessed post-query
  • find with deep relations instead of query builder
  • Missing pagination on list queries
  • Raw queries bypassing TypeORM benefits
  • Transaction usage for multi-step writes

4. Connection & Pool

  • Connection pool size appropriate for workload
  • Idle connection timeout configured
  • Read replicas configured for read-heavy workloads
  • Connection error handling and retry logic
  • Logging level appropriate for environment

5. Migration Safety

  • Entity changes that generate destructive migrations
  • Column type changes that lose data
  • Index changes that lock tables
  • Relationship changes that break foreign keys

Output

## TypeORM Schema Analysis

**Entities:** 18 | **Relations:** 24 | **Indexes:** 12

### 🔴 Critical (3)
1. **Eager loading loop** — User → Posts (eager) → Author (eager) → Posts...
   → Remove `eager: true` from at least one side

2. **Missing index on FK** — Order.userId has no index
   With 500K orders, joins on userId cause full table scans
   → Add `@Index()` on `userId` column

3. **N+1 in getOrders()** — orders.service.ts:34
   Loads orders then iterates to access `order.items` individually
   → Use `relations: ['items']` or query builder with join

### 🟡 Improvements (4)
4. 6 entities with `eager: true` — performance risk at scale
5. VARCHAR(255) on `status` fields — use enum type (4 possible values)
6. Missing `onDelete: 'CASCADE'` on child entities
7. No read replica configured (DB CPU at 80%)

### ✅ Good Practices
- Proper use of table inheritance for payment types
- Transaction wrapping for order creation flow
- Soft delete with `@DeleteDateColumn`
安全使用建议
This appears safe for its stated purpose as long as you are comfortable with the agent reading TypeORM source and configuration files. Before use, consider redacting database credentials from ormconfig.json or data-source.ts and approve any shell commands the agent proposes.
功能分析
Type: OpenClaw Skill Name: typeorm-schema-optimizer Version: 1.0.0 The skill bundle is a legitimate tool for analyzing TypeORM schemas for performance and design issues. The commands in SKILL.md are limited to read-only operations (grep, cat) on project source files and configuration files (ormconfig.json, data-source.ts) to identify entities and repositories, which is consistent with its stated purpose.
能力标签
cryptocan-make-purchases
能力评估
Purpose & Capability
The SKILL.md purpose and instructions align around reviewing TypeORM entities, indexes, relations, migrations, and connection settings. The provided capability signals mention crypto and can-make-purchases, but no artifact text or code supports actual cryptographic or purchase behavior.
Instruction Scope
The skill suggests local shell commands such as grep and cat to inspect TypeORM source and configuration. These are read-only and purpose-aligned, but users should be aware the agent may read project files.
Install Mechanism
There is no install spec and no code files; the package is instruction-only, so there is no executable dependency, installer script, or helper code to review.
Credentials
Reading TypeORM source files and configuration is proportionate to the stated optimization and audit purpose. The artifacts do not show network calls, writes, deletes, migrations being run, or database mutations.
Persistence & Privilege
The skill does not request credentials, persistence, background execution, or privileged access, but it may inspect TypeORM config files that sometimes contain database connection details.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install typeorm-schema-optimizer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /typeorm-schema-optimizer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of typeorm-schema-optimizer. - Analyzes TypeORM entities for performance, query inefficiencies, migration safety, and relationship design issues. - Checks decorators, indexes (including missing indexes on foreign keys), eager loading, and connection pooling. - Detects common query pitfalls like N+1, inefficient joins, and raw queries. - Flags migration risks such as destructive changes or index modifications that lock tables. - Reviews connection pool configuration, logging, and replica setup. - Provides actionable output with critical findings, suggested improvements, and highlights of good practice.
元数据
Slug typeorm-schema-optimizer
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Typeorm Schema Optimizer 是什么?

Optimize TypeORM entities for performance, query efficiency, migration safety, and relationship design — analyze decorators, indexes, eager loading, and conn... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 50 次。

如何安装 Typeorm Schema Optimizer?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install typeorm-schema-optimizer」即可一键安装,无需额外配置。

Typeorm Schema Optimizer 是免费的吗?

是的,Typeorm Schema Optimizer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Typeorm Schema Optimizer 支持哪些平台?

Typeorm Schema Optimizer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Typeorm Schema Optimizer?

由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。

💬 留言讨论