Notre avis
Génère du code CRUD complet (entités, DTOs, services, contrôleurs) pour le framework Adnc à partir de définitions SQL DDL.
Points forts
- Automatise la création de couches entières (repository, application, API)
- Respecte les conventions et la structure du projet Adnc
- Gère les commentaires SQL pour la documentation des propriétés
- Prend en charge les clés uniques et les colonnes spéciales (isdeleted, rowversion)
Limites
- Nécessite une DDL complète et précise, ne peut pas déduire le schéma à partir de données partielles
- Ne génère pas de logique métier personnalisée au-delà du CRUD standard
- Dépend d'un préfixe d'espace de noms fourni manuellement
Lorsque vous devez ajouter rapidement des fonctionnalités CRUD pour une ou plusieurs nouvelles tables dans un projet Adnc.
Pour des transformations de schéma complexes ou lorsque le DDL est incomplet ou non fiable.
Analyse de sécurité
SûrThe skill contains no executable commands, no obfuscation, no attempts to exfiltrate data, and no instructions to disable safety features. It provides code generation guidance only and advises caution about tool approvals.
Aucun point d'attention détecté
Exemples
Use the /adnc-skill-ddl-codegen skill to generate Adnc CRUD code for this DDL.
Namespace prefix: Adnc.Demo.Admin
CREATE TABLE sys_customer (
id bigint NOT NULL,
customer_code varchar(32) NOT NULL COMMENT 'Customer code',
customer_name varchar(128) NOT NULL COMMENT 'Customer name',
isdeleted bit NOT NULL DEFAULT 0 COMMENT 'Deletion flag',
rowversion rowversion NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uk_customer_code (customer_code)
);Generate Adnc CRUD code for these tables with the /adnc-skill-ddl-codegen skill.
Namespace prefix: Adnc.Demo.Admin
CREATE TABLE sys_order (
id bigint NOT NULL,
customer_id bigint NOT NULL COMMENT 'Customer ID',
total decimal(18,2) NOT NULL COMMENT 'Total amount',
status tinyint NOT NULL COMMENT 'Order status',
created_at datetime NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE sys_order_item (
id bigint NOT NULL,
order_id bigint NOT NULL COMMENT 'Order ID',
product_name varchar(100) NOT NULL COMMENT 'Product name',
quantity int NOT NULL COMMENT 'Quantity',
unit_price decimal(18,2) NOT NULL COMMENT 'Unit price',
PRIMARY KEY (id)
);name: adnc-skill-ddl-codegen description: Generates Adnc Repository, Application, and Api CRUD code from SQL DDL or CREATE TABLE statements for this repository. Use when asked to add entities, entity configs, EntityInfo mappings, DTOs, validators, service interfaces, services, controllers, MapperProfile mappings, or PermissionConsts entries based on one or more tables. license: MIT compatibility: Designed for GitHub Copilot CLI or similar coding agents with read/write access to this repository and a user-provided DDL file or snippet. metadata: repo: adnc-skill-ddl-codegen module: adnc-admin layer-scope: repository-application-api
Adnc DDL code generation
Use this skill when the task is to generate adnc module code from one or more table DDL definitions.
Skill packaging and loading
When distributed as a standard Copilot skill, place this skill in a dedicated skill directory such as:
.github\skills\adnc-skill-ddl-codegen\SKILL.mdfor a repository-scoped skill%USERPROFILE%\.copilot\skills\adnc-skill-ddl-codegen\SKILL.mdfor a personal skill on Windows
Keep the skill directory name aligned with the name field: adnc-skill-ddl-codegen.
After adding or updating the skill, reload and verify it in Copilot CLI:
- Run
/skills reload - Run
/skills info adnc-skill-ddl-codegen
This skill package may also include supporting files in the same directory, such as:
assets\templates.mdreferences\ddl-mapping.mdreferences\project-conventions.mdreferences\src\...
Safety and tool approval
This skill is instruction-heavy and does not require bundled shell scripts to do its main job.
- Do not add
allowed-tools: shellorallowed-tools: bashunless you have reviewed every referenced script and explicitly want to pre-approve command execution. - Prefer leaving high-risk tools unapproved so the user still confirms command execution interactively.
- Treat
references\srcas read-only examples and never as a write target.
Typical triggers:
- "根据 DDL 生成 Adnc 代码"
- "为新表生成 entity / dto / service / controller"
- "Add CRUD code for a new table"
- "Update EntityInfo, MapperProfile, and PermissionConsts for new tables"
- "Use the /adnc-skill-ddl-codegen skill to generate Adnc CRUD code"
Trigger examples
Use prompts shaped like these when you want Copilot to load this skill explicitly:
Use the /adnc-skill-ddl-codegen skill to generate Adnc CRUD code for this DDL.
Namespace prefix: Adnc.Demo.Admin
CREATE TABLE sys_customer (
id bigint NOT NULL,
customer_code varchar(32) NOT NULL COMMENT 'Customer code',
customer_name varchar(128) NOT NULL COMMENT 'Customer name',
isdeleted bit NOT NULL DEFAULT 0 COMMENT 'Deletion flag',
rowversion rowversion NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY uk_customer_code (customer_code)
);
Generate Adnc CRUD code for these tables with the /adnc-skill-ddl-codegen skill.
Namespace prefix: Adnc.Demo.Admin
<CREATE TABLE ...>
Use the /adnc-skill-ddl-codegen skill and generate relation-table CRUD for this DDL.
Namespace prefix: Adnc.Demo.Admin
<CREATE TABLE ...>
Required inputs
- A target table list or a DDL file/snippet containing
CREATE TABLEdefinitions. - The namespace prefix to use for generated code, entered manually by the user, for example
Adnc.Demo.Admin. - The DDL source must be selected or provided manually by the user. Do not fall back to repository files as an implicit schema source.
- If the available SQL does not contain enough schema information for the target table, stop and ask for the real DDL instead of guessing from partial SQL or seed data.
Preferred DDL content for the fastest path:
- column
COMMENTvalues for entity property<summary>generation - explicit
UNIQUEkeys or unique indexes for service uniqueness checks - explicit
isdeletedandrowversioncolumns when those behaviors are required
Fast-path defaults
Use these defaults to minimize generation time:
- Read the required reference files once per request, then generate directly. Do not re-read the same reference files unless the current output reveals a concrete conflict.
- For normal business tables, generate the full CRUD file set immediately without asking for extra confirmation.
- For pure relation tables such as
*_relation, skip full CRUD by default. Only generate the full CRUD surface when the user explicitly asks for relation-table CRUD. - Update
EntityInfo.cs,MapperProfile.cs,PermissionConsts.cs, andEntityConsts.csin the same pass as the per-entity files. Do not treat shared file updates as optional follow-up work. - Ask follow-up questions only when one of these blockers is true:
- the DDL is incomplete
- the namespace prefix is missing
- the user explicitly asks for relation-table CRUD
- a real naming conflict or ambiguity cannot be resolved from the documented rules
- Keep the final response minimal: after successful generation, reply with exactly
生成成功.
Always read these files first
Read references\.editorconfig and the mirrored implementation files listed in references/project-conventions.md.
Read references/ddl-mapping.md before generating any code from SQL.
Read assets/templates.md when writing the actual files.
The skill ships with mirrored project snapshots under references\src. Use those copies for conventions and examples instead of depending on the live repository layout.
Workflow
- Identify the target tables and decide whether each is a normal business table or a pure relation table.
- Read the current repository patterns once before editing anything.
- Convert each target table into an entity name and output file set under
.\src. - Generate repository files first:
.\src\Repository\Entities\{Entity}.cs.\src\Repository\Entities\Config\{Entity}Config.cs.\src\Repository\EntityInfo.cs.\src\Repository\EntityConsts.cswhen new max-length constants are needed
- Generate application files:
.\src\Application\Contracts\Interfaces\I{Entity}Service.cs.\src\Application\Services\{Entity}Service.cs.\src\Application\Contracts\Dtos\{Entity}\{Entity}CreationDto.cs.\src\Application\Contracts\Dtos\{Entity}\{Entity}UpdationDto.cs.\src\Application\Contracts\Dtos\{Entity}\{Entity}SearchPagedDto.cs.\src\Application\Contracts\Dtos\{Entity}\{Entity}Dto.cs.\src\Application\Contracts\Dtos\{Entity}\Validators\{Entity}CreationDtoValidator.cs.\src\Application\Contracts\Dtos\{Entity}\Validators\{Entity}UpdationDtoValidator.cs.\src\Application\MapperProfile.cs
- Generate API files:
.\src\Api\Controllers\{Entity}Controller.cs.\src\Api\PermissionConsts.cs
- Validate naming, namespaces, XML docs, DDL comment usage, and analyzer-sensitive formatting.
- After creating the code files, do not run
git addor stage the generated files. Finish by replying with exactly生成成功.
The file paths above are rooted at .\src in the current workspace. They are not namespace templates, and generated code must not be written to references\src.
Output contract
For each normal business table, generate all of the following unless the user explicitly narrows scope:
- one entity file
- one entity configuration file
- one service interface
- one service implementation
- four DTO files
- two validator files
- one controller
- shared file updates for
EntityInfo.cs,MapperProfile.cs, andPermissionConsts.cs - write all generated and updated code files under
.\src - do not add generated files to git; the completion message should be exactly
生成成功
Repository-specific rules
Naming and structure
- Follow file-scoped namespaces.
- Keep
usingdirectives outside the namespace. - Never assume the namespace prefix. Require the user to provide it explicitly and apply that prefix consistently to Repository, Application, and Api namespaces.
- Namespace suffixes must be
{{NamespacePrefix}}.Repository,{{NamespacePrefix}}.Application, and{{NamespacePrefix}}.Api. Do not generate{{NamespacePrefix}}.Admin.Repository,{{NamespacePrefix}}.Admin.Application, or{{NamespacePrefix}}.Admin.Api. - Prefer one generated class per file, even if some existing files co-locate closely related types.
- Convert snake_case table and column names to PascalCase property and type names.
- Repository local variables should use camelCase names such as
customerRepoandtransactionLogRepo.
Entity rules
- Default base class:
EfFullAuditEntity. - If the table includes
isdeleted, implementISoftDeleteand keep theIsDeletedproperty on the entity. - If the table includes
rowversion, implementIConcurrencyon the entity and keep theRowVersionproperty on the entity. - Do not regenerate audit/base properties already covered by the framework unless they must remain explicit in the entity:
IdCreateByCreateTimeModifyByModifyTime
- Keep
RowVersionout of create and update DTOs even when the entity keeps it for concurrency. - String properties should use
stringplus= string.Empty;. - Nullable value types should stay nullable, for example
DateTime?,int?,decimal?. - For entity properties under
.\src\Repository\Entities, the<summary>text must come from the DDL columnCOMMENTvalue. - If a DDL column comment is empty or missing, use the original SQL column name as the property
<summary>text. - Do not replace entity property
<summary>text with guessed English wording when a DDL column comment is available.
DTO rules
CreationDtoinheritsInputDto.UpdationDtoinherits{Entity}CreationDto.{Entity}SearchPagedDtoinheritsSearchPagedDto.{Entity}Dtoinherits{Entity}CreationDtoand addslong Id.- Exclude these fields from
CreationDto,UpdationDto, and{Entity}Dtoinheritance source generation:IdCreateByCreateTimeModifyByModifyTimeIsDeletedRowVersion
- Add extra search properties to
{Entity}SearchPagedDtoonly when the DDL or user requirement makes the filter obvious. Otherwise keep it empty.
Validator rules
- Put validators under
Contracts\Dtos\{Entity}\Validators. - Add length rules from DDL string lengths or constants added to
EntityConsts.cs. - Add
NotEmpty()only for required business fields. UpdationDtoValidatorshouldInclude(new {Entity}CreationDtoValidator());.
Service rules
- Interface must inherit
IAppService. - Service class must inherit
AbstractAppServiceand implementI{Entity}Service. - Use
IEfRepository<{Entity}>. - Use
IdGenerater.GetNextId()for inserts. - Use
input.TrimStringFields();in create, update, and paged-search methods when string fields are present. - Use
Problem(HttpStatusCode.NotFound, "... does not exist")for missing entities. - Use
Problem(HttpStatusCode.BadRequest, "... already exists")for unique-conflict checks inferred from unique keys or indexes. - Use
Mapper.Map<{Entity}>(input, IdGenerater.GetNextId())for create andMapper.Map(input, entity)for update. - Use
ExpressionCreator.New<{Entity}>().AndIf(...)for paged query filters. - Return
new PageModelDto<{Entity}Dto>(input)when the total count is zero. - Keep controllers thin and keep business logic in services.
- Do not add caching attributes or extra service methods unless the feature matches an existing cache-backed pattern in this repo.
Controller rules
- Controller must inherit
AdncControllerBase. - Route pattern should be REST-like and consistent with existing controllers.
- Add actions for
CreateAsync,UpdateAsync,DeleteAsync,GetPagedAsync, andGetAsync. - Use
CreatedResult(...)for create andResult(...)for update and delete. - Use
[AdncAuthorize(PermissionConsts.{Entity}.Create)], etc. - The get-by-id action should authorize both
GetandUpdate, matching current repo patterns.
Shared file rules
EntityInfo.cs: add the exact table mapping withToTable("actual_table_name").MapperProfile.cs: add{Entity}CreationDto -> {Entity},{Entity}UpdationDto -> {Entity}, and{Entity} -> {Entity}Dto.PermissionConsts.cs: add a nested static class withCreate,Update,Delete,Search, andGet.EntityConsts.cs: add a new const class only when the table introduces new bounded string fields that need max-length reuse.- When shared files already exist, update them directly in the same generation pass instead of pausing for extra confirmation.
Gotchas
- Do not infer a full schema from partial SQL, seed data, or table names when the target table DDL is missing.
- Do not default the namespace prefix to
Adnc.Demo.Admin. If the user did not supply the prefix, stop and ask for it. - This repo already has relation entities such as
RoleMenuRelationandRoleUserRelationwithout generated CRUD controllers and services. For pure join tables, skip full CRUD by default unless the user explicitly requests it. - Existing code sometimes uses the shared
SearchPagedDtodirectly, but this skill must still create{Entity}SearchPagedDtobecause the requested output explicitly requires it. - Keep XML comments in English to match the surrounding codebase, except entity property
<summary>text in.\src\Repository\Entities, which must preserve the DDL column comment verbatim and otherwise fall back to the raw column name. - Follow
references\.editorconfigexactly: file-scoped namespaces, braces,var, and sorted usings. - Do not run
git add, do not stage generated files, and do not summarize file lists in the final reply; return exactly生成成功after generation succeeds.
Validation checklist
Before finishing:
- Confirm every target table produced the expected file set.
- Confirm every new namespace matches its folder.
- Confirm
EntityInfo.cs,MapperProfile.cs, andPermissionConsts.cswere updated. - Confirm excluded audit fields were not added to the create/update DTOs.
- Confirm string max lengths are enforced in config and validators.
- Confirm entities with a
rowversioncolumn implementIConcurrencyand keep aRowVersionproperty. - Confirm every entity property
<summary>comes from the DDL column comment, or the raw column name when the comment is empty. - Run
dotnet build src\Adnc.Demo.slnwhen code files changed.
Expert Next.js App Router
Developpement
Un skill qui transforme Claude en expert Next.js App Router.
Générateur de README
Developpement
Crée des README.md professionnels et complets pour vos projets.
Rédacteur de Documentation API
Developpement
Génère de la documentation API complète au format OpenAPI/Swagger.