skills/dev-utils-skills/mybatis-plus-generator/SKILL.md
Generates MyBatis-Plus code (Entity, Mapper, Service, ServiceImpl, Controller, DTO, VO, BO) from database tables. Supports MVC and DDD architectures, Java and Kotlin, with standard CRUD and custom methods. Use ONLY when the user explicitly mentions MyBatis-Plus or mybatis-plus-generator; do NOT trigger for JPA, Hibernate, or other ORMs.
npx skillsauth add teachingai/agent-skills mybatis-plus-generatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions MyBatis-Plus or mybatis-plus-generator.
ALWAYS use this skill when the user mentions:
Trigger phrases include:
DO NOT trigger this skill for:
Supported architectures:
Supported languages:
Supported component types:
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions MyBatis-Plus or mybatis-plus-generator. Do NOT trigger for generic code generation requests without MyBatis-Plus context.
This skill follows a systematic 8-step workflow:
CRITICAL: Before generating any code, you MUST collect the following configuration:
Database Information:
Global Configuration:
src/main/java)io.swagger.annotations.*)io.swagger.v3.oas.annotations.*)Package Configuration:
com.example.app)entity)mapper)service)service.impl)controller)dto)vo)bo)Strategy Configuration:
IMPORTANT: API Documentation Type Selection:
When user enables API documentation, you MUST ask:
请选择 API 文档类型:
- [ ] Swagger 2
- 使用注解:@ApiModel, @ApiModelProperty, @Api, @ApiOperation
- 依赖:springfox-swagger2, springfox-swagger-ui
- 适用于:Spring Boot 2.x 项目
- [ ] OpenAPI 3
- 使用注解:@Schema, @Tag, @Operation, @Parameter
- 依赖:springdoc-openapi-ui
- 适用于:Spring Boot 2.2+ 和 Spring Boot 3.x 项目
Wait for user confirmation before proceeding.
Output: A configuration summary showing all collected information, including API documentation type.
CRITICAL: You MUST ask the user about the architecture type to determine which objects to generate.
Present architecture options:
请选择项目架构类型:
- [ ] 传统 MVC (Model-View-Controller)
- 生成:Entity, Mapper, Service, ServiceImpl, Controller
- [ ] DDD (领域驱动设计)
- 生成:Entity, Mapper, Service, ServiceImpl, Controller, DTO, VO, BO
- [ ] 分层架构 (Layered Architecture)
- 生成:Entity, Mapper, Service, ServiceImpl, Controller
- [ ] 整洁架构 (Clean Architecture)
- 生成:Entity, Repository, UseCase, Controller, DTO
- [ ] 自定义架构
- 请指定需要生成的对象类型
Wait for user confirmation before proceeding.
IMPORTANT: Directory Mapping Based on Architecture
After determining the architecture type, you MUST identify the correct output directories for each generated object.
CRITICAL Steps:
com.example.order)reference/architecture-directory-quick-reference.md for lookup tablereference/architecture-directory-mapping-guide.md for complete mapping rulesCommon Path Examples:
For user table with base package com.example.order:
com/example/order/entity/User.java, Controller → com/example/order/controller/UserController.javacom/example/order/domain/model/aggregate/user/User.java, Controller → com/example/order/interfaces/web/controller/UserController.javacom/example/order/domain/model/entity/User.java, Controller → com/example/order/infrastructure/adapter/inbound/web/controller/UserController.javacom/example/order/domain/entity/User.java, Controller → com/example/order/infrastructure/web/controller/UserController.javacom/example/order/domain/model/entity/User.java, Controller → com/example/order/adapter/web/controller/UserController.javaCRITICAL: Always confirm the exact directory structure with the user if the project structure is unclear. Ask: "请确认项目的目录结构,以便我将生成的代码放在正确的位置。"
CRITICAL: Ask user for functional requirements to understand what methods need to be generated.
Ask the user:
请描述此次生成代码的功能需求:
例如:
- 用户管理:需要根据邮箱查询用户、根据用户名查询用户、用户登录验证
- 订单管理:需要订单统计、订单分页查询、订单状态更新
- 商品管理:需要商品搜索、商品分类查询、库存管理
请详细描述每个表需要哪些功能,我会根据需求自动分析需要生成的方法。
After user provides requirements:
Analyze requirements to identify:
For each table, identify:
Output: A requirements analysis showing:
CRITICAL: Ask user about programming language.
请选择编程语言:
- [ ] Java
- [ ] Kotlin
Wait for user confirmation before proceeding.
Note: Templates in templates/ directory support both Java and Kotlin. Use appropriate templates based on user's choice.
CRITICAL: After collecting all information, create a detailed todo list.
For each table, generate a structured todo list:
## Todo List: MyBatis-Plus Code Generation
### Table: user
#### Entity 层
- [ ] User.java - 实体类
- [ ] 类注释
- [ ] 字段定义(id, username, email, password, status, createTime, updateTime)
- [ ] 字段注释
#### Mapper 层
- [ ] UserMapper.java - 数据访问接口
- [ ] 类注释
- [ ] 基础 CRUD 方法(继承 BaseMapper)
#### Service 层
- [ ] UserService.java - 服务接口
- [ ] 类注释
- [ ] saveUser() - 保存用户
- [ ] findById() - 根据ID查询
- [ ] updateUser() - 更新用户
- [ ] deleteById() - 删除用户
- [ ] findByEmail() - 根据邮箱查询(自定义方法)
- [ ] findByUsername() - 根据用户名查询(自定义方法)
#### ServiceImpl 层
- [ ] UserServiceImpl.java - 服务实现类
- [ ] 类注释
- [ ] 实现所有 Service 接口方法
- [ ] 方法注释和实现骨架
#### Controller 层
- [ ] UserController.java - 控制器
- [ ] 类注释
- [ ] createUser() - 创建用户
- [ ] getUserById() - 查询用户
- [ ] updateUser() - 更新用户
- [ ] deleteUser() - 删除用户
- [ ] getUserByEmail() - 根据邮箱查询(自定义接口)
#### DTO 层(如果架构需要)
- [ ] UserCreateDTO.java - 创建用户DTO
- [ ] UserUpdateDTO.java - 更新用户DTO
- [ ] UserQueryDTO.java - 查询用户DTO
#### VO 层(如果架构需要)
- [ ] UserVO.java - 用户视图对象
### Table: order
...
Important:
CRITICAL: Generate code files with intelligent comments based on table structure and requirements.
Order of generation:
For each object:
templates/ directory based on object type and languageAfter generating each object:
[x]Code Generation Standards: See reference/code-generation-standards.md for detailed requirements on comments, templates, and code quality.
CRITICAL: Provide real-time progress updates during code generation.
Update progress after:
Progress Format: See reference/progress-and-statistics-formats.md for detailed progress update format and examples.
CRITICAL: After all code generation completes, output comprehensive statistics.
Statistics Format: See reference/progress-and-statistics-formats.md for detailed statistics format including:
IMPORTANT: Generated code must include intelligent, context-aware comments, not just template placeholders.
Key Requirements:
Detailed Standards: See reference/code-generation-standards.md for:
CRITICAL: Use these reference documents for detailed guidance:
reference/architecture-directory-mapping-guide.md - Complete directory mapping guide for all architectures (CRITICAL)reference/architecture-directory-quick-reference.md - Quick lookup table for directory mappingsreference/code-generation-standards.md - Detailed comment standards, template usage, and code quality requirementsreference/template-variables.md - Complete list of template variablesreference/swagger-annotations-guide.md - Swagger 2 vs OpenAPI 3 annotation comparisonreference/progress-and-statistics-formats.md - Progress update and statistics output formatsreference/mybatis-plus-generator-guide.md - MyBatis-Plus Generator usage guideSee the examples/ directory for complete examples:
examples/mvc-architecture-example.md - MVC architecture generation exampleexamples/ddd-architecture-example.md - DDD architecture generation exampleexamples/full-workflow-example.md - Complete workflow exampleexamples/architecture-directory-mapping.md - Directory mapping examples for different architecturesexamples/swagger-annotations-example.md - Swagger 2 vs OpenAPI 3 annotation examplesTemplates are located in templates/ directory, using FreeMarker syntax (.ftl files), strictly following MyBatis-Plus official templates.
Java Templates:
entity.java.ftl - Entity class templatemapper.java.ftl - Mapper interface templateservice.java.ftl - Service interface templateserviceImpl.java.ftl - Service implementation templatecontroller.java.ftl - Controller templatedto.java.ftl - DTO templatevo.java.ftl - VO templatebo.java.ftl - BO templateKotlin Templates:
entity.kt.ftl - Entity data class templatemapper.kt.ftl - Mapper interface templateservice.kt.ftl - Service interface templateserviceImpl.kt.ftl - Service implementation templatecontroller.kt.ftl - Controller templatedto.kt.ftl - DTO templatevo.kt.ftl - VO templatebo.kt.ftl - BO templateAll DDD templates are located in templates/ root directory, supporting both Java and Kotlin:
Domain Layer:
aggregate-root.java.ftl / aggregate-root.kt.ftl - Aggregate root templaterepository.java.ftl / repository.kt.ftl - Repository interface template (domain layer)domain-service.java.ftl / domain-service.kt.ftl - Domain service templatevalue-object.java.ftl / value-object.kt.ftl - Value object templatedomain-event.java.ftl / domain-event.kt.ftl - Domain event templateApplication Layer:
application-service.java.ftl / application-service.kt.ftl - Application service templateInterface Layer:
assembler.java.ftl / assembler.kt.ftl - DTO assembler templateTemplate Features:
Reference: See MyBatis-Plus official templates at:
English keywords: mybatis-plus, mybatis-plus-generator, mybatis-plus code generator, mybatis-plus code generation, generate mybatis-plus code, mybatis-plus entity generator, mybatis-plus mapper generator, mybatis-plus service generator, mybatis-plus controller generator, mybatis-plus crud generation, mybatis-plus from table, mybatis-plus code from database
Chinese keywords (中文关键词): MyBatis-Plus, mybatis-plus-generator, MyBatis-Plus 代码生成器, MyBatis-Plus 代码生成, 生成 MyBatis-Plus 代码, MyBatis-Plus 实体类生成, MyBatis-Plus Mapper 生成, MyBatis-Plus Service 生成, MyBatis-Plus Controller 生成, MyBatis-Plus CRUD 生成, MyBatis-Plus 根据表生成代码, MyBatis-Plus 数据库转代码, MyBatis-Plus 表转 Java, 使用 MyBatis-Plus 生成代码
IMPORTANT: All keywords must include "MyBatis-Plus" or "mybatis-plus" to avoid false triggers. Generic terms like "代码生成器" (code generator) or "根据表生成代码" (generate code from table) without "MyBatis-Plus" should NOT trigger this skill.
development
Guidance for Next.js using the official docs at nextjs.org/docs. Use when the user needs Next.js concepts, configuration, routing, data fetching, or API reference details.
tools
Provides comprehensive guidance for Flask framework including routing, templates, forms, database integration, extensions, and deployment. Use when the user asks about Flask, needs to create web applications, implement routes, or build Python web services.
development
Provides comprehensive guidance for FastAPI framework including routing, request validation, dependency injection, async operations, OpenAPI documentation, and database integration. Use when the user asks about FastAPI, needs to create REST APIs, or build high-performance Python web services.
development
Provides comprehensive guidance for Django framework including models, views, templates, forms, admin, REST framework, and deployment. Use when the user asks about Django, needs to create web applications, implement models and views, or build Django REST APIs.