-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Create AI Development Rules Markdowns #24680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a comprehensive collection of AI development rules (in Cursor .mdc format) for ABP Framework projects. The rules provide AI assistants with ABP-specific context to help generate code that follows ABP conventions and best practices.
Changes:
- Added 19 markdown rule files covering DDD patterns, application layer, UI frameworks, data access, testing, and template-specific guidance
- Created organized folder structure (common, ui, data, testing, template-specific)
- Included comprehensive README explaining the purpose, structure, and contribution guidelines
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| ai-rules/README.md | Main documentation explaining the AI rules system, file structure, and contribution guidelines |
| ai-rules/common/abp-core.mdc | Core ABP conventions including module system, DI, and base classes (always applied) |
| ai-rules/common/ddd-patterns.mdc | DDD patterns for entities, aggregate roots, repositories, and domain services |
| ai-rules/common/application-layer.mdc | Application service patterns, DTOs, validation, and error handling |
| ai-rules/common/authorization.mdc | Permission system and authorization patterns |
| ai-rules/common/multi-tenancy.mdc | Multi-tenant entities, data isolation, and tenant switching |
| ai-rules/common/infrastructure.mdc | Settings, features, caching, events, and background jobs |
| ai-rules/common/dependency-rules.mdc | Layer dependency rules and project structure guardrails |
| ai-rules/common/development-flow.mdc | Complete workflow for adding new entities and features |
| ai-rules/common/cli-commands.mdc | Reference for ABP CLI commands |
| ai-rules/ui/blazor.mdc | Blazor UI component patterns and best practices |
| ai-rules/ui/angular.mdc | Angular UI patterns including service proxies and components |
| ai-rules/ui/mvc.mdc | MVC/Razor Pages patterns and ABP tag helpers |
| ai-rules/data/ef-core.mdc | Entity Framework Core DbContext, migrations, and repositories |
| ai-rules/data/mongodb.mdc | MongoDB patterns and repository implementations |
| ai-rules/testing/patterns.mdc | Unit and integration testing patterns using xUnit and Shouldly |
| ai-rules/template-specific/app-nolayers.mdc | Single-layer application template patterns |
| ai-rules/template-specific/module.mdc | Reusable module development patterns with extensibility focus |
| ai-rules/template-specific/microservice.mdc | Microservice template patterns including inter-service communication |
| public DbSet<Book> Books { get; set; } | ||
| public DbSet<Author> Authors { get; set; } | ||
|
|
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says "Not setters" for DbSet properties, but the code immediately below shows properties without setters. This is correct for EF Core, but the comment is confusing. Consider clarifying the comment to say "Aggregate roots only" or removing it entirely since the pattern is self-explanatory.
|
|
||
| | Don't Use | Use Instead | | ||
| |-----------|-------------| | ||
| | Minimal APIs | ABP Controllers or Auto API Controllers | |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guidance to "Never use Minimal APIs" contradicts modern ASP.NET Core best practices and may be too restrictive. ABP can work with Minimal APIs in certain scenarios. Consider softening this to "Prefer ABP Controllers or Auto API Controllers for consistency with ABP patterns" rather than a blanket prohibition.
| | Minimal APIs | ABP Controllers or Auto API Controllers | | |
| | Minimal APIs for core/business HTTP APIs | Prefer ABP Controllers or Auto API Controllers for consistency with ABP patterns (Minimal APIs are acceptable for limited scenarios, e.g. health checks or very simple endpoints). | |
| @@ -0,0 +1,270 @@ | |||
| --- | |||
| description: "ABP testing patterns - unit tests and integration tests" | |||
| globs: "test/**/*.cs,tests/**/*.cs,**/*Tests*/**/*.cs,**/*Test*.cs" | |||
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The glob pattern includes "/Test.cs" which will match files like "TestData.cs" or "TestConfiguration.cs" that are not test files. Consider using more specific patterns like "/*Tests.cs,**/*Test.cs" to avoid false positives.
| globs: "test/**/*.cs,tests/**/*.cs,**/*Tests*/**/*.cs,**/*Test*.cs" | |
| globs: "test/**/*.cs,tests/**/*.cs,**/*Tests*/**/*.cs,**/*Tests.cs,**/*Test.cs" |
| public IMongoCollection<Book> Books => Collection<Book>(); | ||
| public IMongoCollection<Author> Authors => Collection<Author>(); | ||
|
|
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example shows DbSet properties without setters, but the comment says "No setters, aggregate roots only". However, in EF Core, DbSet properties typically have both get and set. The pattern shown is valid for interface definitions but may be confusing for DbContext implementations. Consider clarifying that this is for the interface pattern specifically.
| public string OrderNumber { get; private set; } | ||
| public Guid CustomerId { get; private set; } | ||
| public OrderStatus Status { get; private set; } | ||
| public ICollection<OrderLine> Lines { get; private set; } |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property name "Lines" is misleading for a collection property. ABP and C# conventions typically use plural noun naming for collections without the "Collection" suffix, so "Lines" is actually correct and conventional. However, the code shows it as type ICollection which is less common - typically you'd see List or IReadOnlyCollection for better encapsulation. Consider showing it as public IReadOnlyCollection<OrderLine> Lines { get; private set; } or private readonly List<OrderLine> _lines = new(); public IReadOnlyCollection<OrderLine> Lines => _lines.AsReadOnly(); for better domain model encapsulation.
| private List<BookDto> Books { get; set; } | ||
|
|
||
| protected override async Task OnInitializedAsync() | ||
| { | ||
| var result = await BookAppService.GetListAsync(new PagedAndSortedResultRequestDto()); | ||
| Books = result.Items.ToList(); |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example shows Books = result.Items.ToList(); where ToList() creates an unnecessary copy. The Items property already returns a collection, so this should be Books = result.Items; or the Books property type should match what Items returns.
| private List<BookDto> Books { get; set; } | |
| protected override async Task OnInitializedAsync() | |
| { | |
| var result = await BookAppService.GetListAsync(new PagedAndSortedResultRequestDto()); | |
| Books = result.Items.ToList(); | |
| private IReadOnlyList<BookDto> Books { get; set; } | |
| protected override async Task OnInitializedAsync() | |
| { | |
| var result = await BookAppService.GetListAsync(new PagedAndSortedResultRequestDto()); | |
| Books = result.Items; |
|
|
||
| public Book(Guid id, string name, decimal price, Guid authorId) : base(id) | ||
| { | ||
| Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example uses Check.NotNullOrWhiteSpace(name, nameof(name)) as a return value, but the Check class validation methods are void and throw exceptions on failure. The correct pattern is to either use Check as a statement (not assigned) or use it within the property assignment. This code will not compile.
|
|
||
| **Books.razor.cs:** | ||
| ```csharp | ||
| public partial class Books : BooksBase |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code example shows a partial class named "Books" inheriting from "BooksBase", but the file structure suggests this should be "BooksPage" or similar to avoid naming conflicts. Having a component class and base class both named "Books" (one partial) can be confusing. Consider using a clearer naming pattern like "BooksPage : BooksBase" or showing this as an abstract example.
|
|
||
| This folder serves as a central repository for ABP-specific AI rules. The community can contribute, improve, and maintain these rules collaboratively. | ||
|
|
||
| When you create a new ABP solution, these rules are included in your project based on your configuration. This provides AI assistants with ABP-specific context, helping them generate code that follows ABP conventions. |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README states these rules are included "based on your configuration" when creating a new ABP solution, but it's unclear what configuration options control which rules are included. Consider adding clarification about how developers can customize which rules are included in their projects, or if this is automatic based on template selection.
| When you create a new ABP solution, these rules are included in your project based on your configuration. This provides AI assistants with ABP-specific context, helping them generate code that follows ABP conventions. | |
| When you create a new ABP solution (for example, using the ABP CLI or ABP Suite), the `ai-rules` folder and a subset of these rule files are included in your project automatically. The exact set of rules that is copied depends on the template and options you choose (e.g., app vs. module vs. microservice, selected UI framework, data provider, etc.). You can further customize which rules are used by adding or removing `.mdc` files in your solution, or by adjusting their frontmatter (such as `alwaysApply` or `glob`) to control when they are applied. This provides AI assistants with ABP-specific context, helping them generate code that follows ABP conventions. |
| @@ -0,0 +1,143 @@ | |||
| # ABP AI Rules | |||
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves #7957