一键导入
data-model
Generate comprehensive data model documentation with ERD, DTOs, and data flow diagrams
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate comprehensive data model documentation with ERD, DTOs, and data flow diagrams
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Analyze recent changes and add test coverage for HEAD commit
Write failing unit tests for feature requirements (TDD style)
Deep analysis mode - thorough multi-phase investigation with expert consultation
Analyze test coverage gaps and report findings
Analyze service capacity, load patterns, and scaling requirements
Code review mode - comprehensive review with security, performance, and maintainability focus
| name | data-model |
| description | Generate comprehensive data model documentation with ERD, DTOs, and data flow diagrams |
Current Time: !date
PostgreSQL: !psql --version
Create comprehensive Entity Relationship Diagrams (ERDs) and data documentation for the current project.
Generate complete data model documentation including:
Save all documentation to: ./docs/architecture/data-model.md (relative to current project directory)
Important: Auto-create the ./docs/architecture/ directory if it doesn't exist.
Before generating documentation, perform comprehensive project analysis:
Database Technology Detection
prisma/schema.prisma)*.entity.ts, decorators like @Entity)models/*.js, sequelize.define)*.model.ts, mongoose.Schema)*.sql, migrations/*.sql)models.py)Base.metadata)Backend Framework Detection
next.config.js, API routes in app/api/ or pages/api/)package.json for express, look for app.js or server.js)requirements.txt, main.py with @app decorators)settings.py, urls.py)@Module, @Controller decorators)Frontend State Management Detection
createSlice, configureStore)create from zustand)createContext, useContext)useQuery, useMutation)makeObservable, @observable)atom from jotai)Service Layer Patterns
*.repository.ts)*.service.ts)*.controller.ts)*.usecase.ts)Create a comprehensive single-file documentation at ./docs/architecture/data-model.md with the following structure:
Generated on: [DATE] Project: [PROJECT_NAME] Tech Stack: [AUTO-DETECTED STACK]
[Brief description of the database architecture]
erDiagram
%% Generate complete ERD with:
%% - All tables/entities
%% - Column definitions with types
%% - Relationships (one-to-one, one-to-many, many-to-many)
%% - Foreign keys
%% - Cardinality
USER ||--o{ ORDER : places
USER {
uuid id PK
string email UK
string password_hash
timestamp created_at
timestamp updated_at
}
ORDER ||--|{ ORDER_ITEM : contains
ORDER {
uuid id PK
uuid user_id FK
string status
decimal total_amount
timestamp created_at
}
%% ... continue for all entities
id (UUID, PRIMARY KEY) - Unique identifieremail (VARCHAR(255), UNIQUE, NOT NULL) - User email addresscreated_at (TIMESTAMP, DEFAULT NOW()) - Creation timestampidx_email on email (unique)idx_created_at on created_at[Repeat for all tables]
[Description of service layer architecture]
CreateUserDTO
interface CreateUserDTO {
email: string; // Valid email format
password: string; // Min 8 chars, 1 uppercase, 1 number
firstName?: string;
lastName?: string;
}
Validation Rules:
email: Required, valid email formatpassword: Required, min 8 characters, must contain uppercase, numberfirstName: Optional, max 50 characterslastName: Optional, max 50 characters[Continue for all DTOs]
UserResponseDTO
interface UserResponseDTO {
id: string;
email: string;
firstName: string | null;
lastName: string | null;
createdAt: string; // ISO 8601 format
updatedAt: string;
}
[Continue for all response DTOs]
User Domain Model
class User {
private id: string;
private email: string;
private passwordHash: string;
// Business logic methods
public verifyPassword(plaintext: string): boolean;
public updateEmail(newEmail: string): void;
}
Business Rules:
[Continue for all domain models]
[Description of frontend data architecture]
UserProfile Component
interface UserProfileProps {
user: {
id: string;
email: string;
firstName: string | null;
lastName: string | null;
};
onUpdate: (data: Partial<UpdateUserDTO>) => Promise<void>;
isLoading: boolean;
}
[Continue for major components]
User State (Redux/Zustand/etc.)
interface UserState {
currentUser: User | null;
isAuthenticated: boolean;
isLoading: boolean;
error: string | null;
}
Actions:
loginUser(credentials) - Authenticate userlogoutUser() - Clear sessionupdateUserProfile(data) - Update user data[Continue for all state slices]
User Registration Form
interface RegistrationFormSchema {
email: string;
password: string;
confirmPassword: string;
firstName?: string;
lastName?: string;
agreeToTerms: boolean;
}
Validation:
Complete data flow from database through API to UI and back.
flowchart TD
DB[(Database)]
REPO[Repository Layer]
SERVICE[Service Layer]
CONTROLLER[Controller/API]
STATE[State Management]
UI[UI Components]
DB -->|Raw Data| REPO
REPO -->|Domain Models| SERVICE
SERVICE -->|DTOs| CONTROLLER
CONTROLLER -->|JSON Response| STATE
STATE -->|Props| UI
UI -->|User Action| STATE
STATE -->|API Call| CONTROLLER
CONTROLLER -->|Validate & Process| SERVICE
SERVICE -->|Business Logic| REPO
REPO -->|SQL/ORM| DB
style DB fill:#f9f,stroke:#333,stroke-width:2px
style UI fill:#bbf,stroke:#333,stroke-width:2px
1. User submits registration form (UI)
// Component
const handleSubmit = async (formData: RegistrationFormSchema) => {
await registerUser(formData);
};
2. API call dispatched (State Management)
// Action/Mutation
const registerUser = async (data: CreateUserDTO) => {
const response = await fetch("/api/users/register", {
method: "POST",
body: JSON.stringify(data),
});
return response.json();
};
3. API endpoint receives request (Controller)
// POST /api/users/register
async function handleRegister(req: Request) {
const dto = validateDTO(CreateUserDTO, req.body);
const user = await userService.createUser(dto);
return UserResponseDTO.from(user);
}
4. Business logic executed (Service)
// UserService
async createUser(dto: CreateUserDTO): Promise<User> {
// Hash password
const passwordHash = await bcrypt.hash(dto.password, 10);
// Create user via repository
const user = await userRepository.create({
email: dto.email,
passwordHash,
firstName: dto.firstName,
lastName: dto.lastName
});
return user;
}
5. Database operation (Repository)
// UserRepository
async create(data: CreateUserData): Promise<User> {
return await db.user.create({
data: {
id: uuid(),
email: data.email,
passwordHash: data.passwordHash,
firstName: data.firstName,
lastName: data.lastName,
createdAt: new Date(),
updatedAt: new Date()
}
});
}
Data Transformations:
[Repeat for other critical flows: Authentication, CRUD operations, etc.]
prisma/schema.prisma file*.entity.ts files@Entity, @Column, @ManyToOne, etc.models/ directorysequelize.define() calls*.model.ts or *.schema.ts filesmongoose.Schema() definitionsmodels.py filesapp/api/) and Pages Router (pages/api/)./docs/architecture/ directory if it doesn't exist./docs/architecture/data-model.md✅ Single comprehensive file created at ./docs/architecture/data-model.md
✅ All database entities documented with Mermaid ERD
✅ All service layer models documented (DTOs, domain models)
✅ All UI data structures documented (props, state)
✅ End-to-end data flow documented with diagrams
✅ Validation rules included for all data structures
✅ Technology stack auto-detected and documented
✅ File is well-organized and easy to navigate
$ARGUMENTS