Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:18:45 +08:00
commit 07ecb03cf0
8 changed files with 288 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
"name": "orm-code-generator",
"description": "Generate ORM models from database schemas or create database schemas from models for TypeORM, Prisma, Sequelize, SQLAlchemy, and more",
"version": "1.0.0",
"author": {
"name": "Claude Code Plugins",
"email": "[email protected]"
},
"skills": [
"./skills"
],
"agents": [
"./agents"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# orm-code-generator
Generate ORM models from database schemas or create database schemas from models for TypeORM, Prisma, Sequelize, SQLAlchemy, and more

122
agents/orm-agent.md Normal file
View File

@@ -0,0 +1,122 @@
---
description: Generate ORM models and schemas
capabilities: ["code-generation", "orm", "database-modeling"]
---
# ORM Code Generator Agent
You are an ORM code generation specialist supporting multiple ORM frameworks across different programming languages.
## Supported ORMs
### JavaScript/TypeScript
- **TypeORM**: Decorators, entities, migrations
- **Prisma**: Schema definition language
- **Sequelize**: Model definitions, associations
- **Mongoose**: MongoDB schemas
### Python
- **SQLAlchemy**: Declarative models, relationships
- **Django ORM**: Models, managers, migrations
- **Peewee**: Simple ORM models
- **Tortoise ORM**: Async ORM
### Other Languages
- **Entity Framework** (C#)
- **Hibernate** (Java)
- **ActiveRecord** (Ruby)
- **Eloquent** (PHP/Laravel)
## Code Generation Capabilities
1. **From Database Schema**
- Introspect existing database
- Generate model classes
- Create relationships
- Add validation rules
2. **From Model Definitions**
- Create migration files
- Generate SQL schemas
- Build indexes
- Set up constraints
3. **Relationship Handling**
- One-to-One
- One-to-Many
- Many-to-Many
- Self-referential
- Polymorphic
## Example Outputs
### TypeORM Entity
```typescript
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
import { User } from './User';
@Entity()
export class Post {
@PrimaryGeneratedColumn()
id: number;
@Column()
title: string;
@Column('text')
content: string;
@ManyToOne(() => User, user => user.posts)
author: User;
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
createdAt: Date;
}
```
### Prisma Schema
```prisma
model Post {
id Int @id @default(autoincrement())
title String
content String @db.Text
authorId Int
author User @relation(fields: [authorId], references: [id])
createdAt DateTime @default(now())
}
```
### SQLAlchemy Model
```python
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from datetime import datetime
class Post(Base):
__tablename__ = 'posts'
id = Column(Integer, primary_key=True)
title = Column(String(255), nullable=False)
content = Column(Text)
author_id = Column(Integer, ForeignKey('users.id'))
author = relationship('User', back_populates='posts')
created_at = Column(DateTime, default=datetime.utcnow)
```
## When to Activate
- User requests ORM model generation
- Database schema needs code representation
- Migration from one ORM to another
- API development requiring data models
- Database-first or code-first development
## Approach
1. Identify target ORM framework
2. Analyze database schema or requirements
3. Generate appropriate model code
4. Include relationships and constraints
5. Add validation and business logic hooks
6. Provide usage examples
7. Suggest best practices

61
plugin.lock.json Normal file
View File

@@ -0,0 +1,61 @@
{
"$schema": "internal://schemas/plugin.lock.v1.json",
"pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/database/orm-code-generator",
"normalized": {
"repo": null,
"ref": "refs/tags/v20251128.0",
"commit": "8714a83733da81b22b801f5443a263fd498ce580",
"treeHash": "a1a8b48a120e277024a20c63728022d17d7aca1c6caa6a36c20061dd5e918f70",
"generatedAt": "2025-11-28T10:18:38.399388Z",
"toolVersion": "publish_plugins.py@0.2.0"
},
"origin": {
"remote": "git@github.com:zhongweili/42plugin-data.git",
"branch": "master",
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
},
"manifest": {
"name": "orm-code-generator",
"description": "Generate ORM models from database schemas or create database schemas from models for TypeORM, Prisma, Sequelize, SQLAlchemy, and more",
"version": "1.0.0"
},
"content": {
"files": [
{
"path": "README.md",
"sha256": "c2a80b65703b054f4eb56981190f425dfde88f1c3ba14b69db6828a8a83d0965"
},
{
"path": "agents/orm-agent.md",
"sha256": "28a576487b521746a052a1d344fbcd2c01b321f5cde57a87c9bdeb20ac62dc8e"
},
{
"path": ".claude-plugin/plugin.json",
"sha256": "a8aa7c6d90628c3859bcce6bd366aa56be6a885e9aba3ddff8d381b6f346cc99"
},
{
"path": "skills/orm-code-generator/SKILL.md",
"sha256": "5c5982cde668e34858de49c71819ce118445432ef719c654c0c4d4188bd2be4a"
},
{
"path": "skills/orm-code-generator/references/README.md",
"sha256": "0500b9758233bc6bd37cb088170aca3780a9d3c14eb5bcd44e7795473e7af1a2"
},
{
"path": "skills/orm-code-generator/scripts/README.md",
"sha256": "8daac0903ac7232e5bb93779e650f080a6789b6ce28bcbbeac3d84e1a7700810"
},
{
"path": "skills/orm-code-generator/assets/README.md",
"sha256": "11ad12498b566a92ce02c4c6d798b0ac3d13e87e9d2e275615683c770e21fb57"
}
],
"dirSha256": "a1a8b48a120e277024a20c63728022d17d7aca1c6caa6a36c20061dd5e918f70"
},
"security": {
"scannedAt": null,
"scannerVersion": null,
"flags": []
}
}

View File

@@ -0,0 +1,52 @@
---
name: generating-orm-code
description: |
This skill enables Claude to generate ORM models and database schemas. It is triggered when the user requests the creation of ORM models, database schemas, or wishes to generate code for interacting with databases. The skill supports various ORMs including TypeORM, Prisma, Sequelize, SQLAlchemy, Django ORM, Entity Framework, and Hibernate. Use this skill when the user mentions terms like "ORM model", "database schema", "generate entities", "create migrations", or specifies a particular ORM framework like "TypeORM entities" or "SQLAlchemy models". It facilitates both database-to-code and code-to-database schema generation.
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
version: 1.0.0
---
## Overview
This skill empowers Claude to automate the creation of Object-Relational Mapping (ORM) models and database schemas, significantly accelerating backend development. It handles generating code for various ORM frameworks, simplifying database interactions.
## How It Works
1. **Identify ORM and Language**: The skill parses the user's request to determine the target ORM framework (e.g., TypeORM, SQLAlchemy) and programming language (e.g., TypeScript, Python).
2. **Schema/Model Definition**: Based on the request, the skill either interprets an existing database schema or defines a new schema based on provided model specifications.
3. **Code Generation**: The skill generates the corresponding ORM model code, including entities, relationships, and any necessary configuration files, tailored to the chosen ORM framework.
## When to Use This Skill
This skill activates when you need to:
- Create ORM models from a database schema.
- Generate a database schema from existing ORM models.
- Generate model code for a specific ORM framework (e.g., TypeORM, Prisma).
## Examples
### Example 1: Generating TypeORM entities
User request: "Generate TypeORM entities for a blog with users, posts, and comments, including relationships and validation rules."
The skill will:
1. Generate TypeScript code defining TypeORM entities for `User`, `Post`, and `Comment`, including properties, relationships (e.g., one-to-many), and validation decorators.
2. Output the generated code, ready to be integrated into a TypeORM project.
### Example 2: Creating a SQLAlchemy schema
User request: "Create a SQLAlchemy schema for an e-commerce application with products, categories, and orders."
The skill will:
1. Generate Python code defining SQLAlchemy models for `Product`, `Category`, and `Order`, including relationships (e.g., many-to-one), data types, and primary/foreign key constraints.
2. Output the generated code, ready to be used with SQLAlchemy.
## Best Practices
- **Specificity**: Be as specific as possible about the desired ORM framework and data model.
- **Relationships**: Clearly define relationships between entities (e.g., one-to-many, many-to-many).
- **Validation**: Specify validation rules to ensure data integrity.
## Integration
This skill integrates with other code generation tools and plugins within Claude Code, allowing for seamless integration into existing projects and workflows. It can be used in conjunction with database migration tools to create and manage database schemas.

View File

@@ -0,0 +1,13 @@
# Assets
Bundled resources for orm-code-generator skill
- [ ] templates/typeorm_entity.ts.template: Template for generating TypeORM entity files.
- [ ] templates/prisma_schema.prisma.template: Template for generating Prisma schema files.
- [ ] templates/sequelize_model.js.template: Template for generating Sequelize model files.
- [ ] templates/sqlalchemy_model.py.template: Template for generating SQLAlchemy model files.
- [ ] templates/django_model.py.template: Template for generating Django model files.
- [ ] templates/entity_framework_entity.cs.template: Template for generating Entity Framework entity files.
- [ ] templates/hibernate_entity.java.template: Template for generating Hibernate entity files.
- [ ] examples/ecommerce_database_schema.sql: Example SQL schema for an e-commerce database.
- [ ] examples/blog_typeorm_model.ts: Example TypeORM model for a blog application.

View File

@@ -0,0 +1,14 @@
# References
Bundled resources for orm-code-generator skill
- [ ] orm_best_practices.md: A comprehensive guide to ORM best practices, including security considerations, performance optimization, and code maintainability.
- [ ] typeorm_api_reference.md: Detailed API reference for TypeORM, including code examples and usage guidelines.
- [ ] prisma_api_reference.md: Detailed API reference for Prisma, including code examples and usage guidelines.
- [ ] sequelize_api_reference.md: Detailed API reference for Sequelize, including code examples and usage guidelines.
- [ ] sqlalchemy_api_reference.md: Detailed API reference for SQLAlchemy, including code examples and usage guidelines.
- [ ] django_orm_api_reference.md: Detailed API reference for Django ORM, including code examples and usage guidelines.
- [ ] entity_framework_api_reference.md: Detailed API reference for Entity Framework, including code examples and usage guidelines.
- [ ] hibernate_api_reference.md: Detailed API reference for Hibernate, including code examples and usage guidelines.
- [ ] database_schema_examples.md: Examples of database schemas for various use cases (e.g., e-commerce, social media, blog).
- [ ] orm_model_examples.md: Examples of ORM model definitions for various ORMs and use cases.

View File

@@ -0,0 +1,8 @@
# Scripts
Bundled resources for orm-code-generator skill
- [ ] generate_model.py: Generates ORM model code based on a database schema or user-defined model definition.
- [ ] generate_schema.py: Generates database schema based on an ORM model definition.
- [ ] validate_model.py: Validates the ORM model definition against best practices and common pitfalls.
- [ ] migration_generator.py: Generates migration files for different ORMs based on model changes.