abp-application-layer
Skill0 starsChanged 4 days agoMITView on GitHub
Use when creating or reviewing application services, DTOs, or working in the Application or Application.Contracts projects. Covers Application Services, DTOs, CRUD service, object mapping (Mapperly/AutoMapper), validation, and error handling.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- abpframework/abpedited, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- abpframework/abp★ 14k98% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository67 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- abp-angularSkill
- abp-app-nolayersSkill
- abp-authorizationSkill
- abp-blazorSkill
- abp-cliSkill
- abp-coreSkill
- abp-dddSkill
- abp-dependency-rulesSkill
- abp-development-flowSkill
- abp-ef-coreSkill
- abp-infrastructureSkill
- abp-microserviceSkill
- abp-moduleSkill
- abp-mongodbSkill
- abp-multi-tenancySkill
- abp-mvcSkill
- abp-testingSkill
- aspnet-core-apiSkill
- brainstormingSkill
- building-mcp-serversSkill
- caveman-commitSkill
- caveman-compressSkill
- caveman-reviewSkill
- cavemanSkill
- chrome-devtoolsSkill
- create-agent-harnessSkill
- defuddleSkill
- design-patternsSkill
- dispatching-parallel-agentsSkill
- efcore-patternsSkill
- ef-coreSkill
- entity-framework-coreSkill
- executing-plansSkill
- find-skillsSkill
- finishing-a-development-branchSkill
- fluentui-blazorSkill
- github-issuesSkill
- harness-repo-structureSkill
- json-canvasSkill
- memory-mergerSkill
- microsoft-agent-frameworkSkill
- microsoft-code-referenceSkill
- microsoft-docsSkill
- microsoft-skill-creatorSkill
- migrate-aspnetboilerplate-to-abpSkill
- modern-csharp-coding-standardsSkill
- performance-optimizationSkill
- postgresql-code-reviewSkill
- postgresql-optimizationSkill
- premium-frontend-uiSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- rtk-token-killerSkill
- security-jwtSkill
- sonarqube-fixSkill
- sql-code-reviewSkill
- sql-optimizationSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 8 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Entity name in method: use GetAsync not GetBookAsync
- Distinctive: line 15
Calling other app services in the same module: use domain services or repositories directly
- Distinctive: line 17
Business logic in app service: put it in domain entities or domain services
- Very specific: line 78
Don't repeat entity name in method names (GetAsync not GetBookAsync)
- Distinctive: line 81
Use custom repositories when you need custom queries, generic repository is fine for simple CRUD
- Very specific: line 82
Call UpdateAsync explicitly (don't assume change tracking)
- Distinctive: line 83
Don't call other app services in same module
- Very specific: line 84
Don't use IFormFile/Stream - pass byte[] from controllers
- Very specific: line 85
Use base class properties (Clock, CurrentUser, GuidGenerator, L) instead of injecting these services
- Distinctive: line 118
Before adding custom validation, decide if it's a domain rule or application rule:
- Distinctive: line 119
Domain rule: Put validation in entity constructor or domain service (enforces business invariants)
- Distinctive: line 120
Application rule: Use DTO validation (input format, required fields)
- Very specific: line 122
Only use IValidatableObject for application-level validation that can't be expressed with data annotations:
- Very specific: line 192
Use [RemoteService(false)] to disable auto API generation for specific methods
- Distinctive: line 196
Prefer the mapping provider already used in the solution (check existing mapping files / loaded modules).
- Very specific: line 240
If the solution uses AutoMapper, mappings are typically defined in Profile classes and registered via ABP's AutoMapper integration.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ABP Application Layer Patterns
Docs: https://abp.io/docs/latest/framework/architecture/domain-driven-design/application-services
Anti-Patterns to Avoid
- Entity name in method: use
GetAsyncnotGetBookAsync - ID inside UpdateDto: pass
idas a separate parameter, not inside the DTO - Calling other app services in the same module: use domain services or repositories directly
- Using
IFormFile/Streamin app service: acceptbyte[]from controllers instead - Business logic in app service: put it in domain entities or domain services
Application Service Structure
Interface (Application.Contracts)
public interface IBookAppService : IApplicationService
{
Task<BookDto> GetAsync(Guid id);
Task<PagedResultDto<BookListItemDto>> GetListAsync(GetBookListInput input);
Task<BookDto> CreateAsync(CreateBookDto input);
Task<BookDto> UpdateAsync(Guid id, UpdateBookDto input);
Task DeleteAsync(Guid id);
}Implementation (Application)
public class BookAppService : ApplicationService, IBookAppService
{
private readonly IBookRepository _bookRepository;
private readonly BookManager _bookManager;
private readonly BookMapper _bookMapper;
public BookAppService(
IBookRepository bookRepository,
BookManager bookManager,
BookMapper bookMapper)
{
_bookRepository = bookRepository;
_bookManager = bookManager;
_bookMapper = bookMapper;
}
public async Task<BookDto> GetAsync(Guid id)
{
var book = await _bookRepository.GetAsync(id);
return _bookMapper.MapToDto(book);
}
[Authorize(BookStorePermissions.Books.Create)]
public async Task<BookDto> CreateAsync(CreateBookDto input)
{
var book = await _bookManager.CreateAsync(input.Name, input.Price);
await _bookRepository.InsertAsync(book);
return _bookMapper.MapToDto(book);
}
[Authorize(BookStorePermissions.Books.Edit)]
public async Task<BookDto> UpdateAsync(Guid id, UpdateBookDto input)
{
var book = await _bookRepository.GetAsync(id);
await _bookManager.ChangeNameAsync(book, input.Name);
book.SetPrice(input.Price);
await _bookRepository.UpdateAsync(book);
return _bookMapper.MapToDto(book);
}
}Application Service Best Practices
- Don't repeat entity name in method names (
GetAsyncnotGetBookAsync) - Accept/return DTOs only, never entities
- ID not inside UpdateDto - pass separately
- Use custom repositories when you need custom queries, generic repository is fine for simple CRUD
- Call
UpdateAsyncexplicitly (don't assume change tracking) - Don't call other app services in same module
- Don't use
IFormFile/Stream- passbyte[]from controllers - Use base class properties (
Clock,CurrentUser,GuidGenerator,L) instead of injecting these services
DTO Naming Conventions
| Purpose | Convention | Example |
| Query input | Get{Entity}Input | GetBookInput |
| List query input | Get{Entity}ListInput | GetBookListInput |
| Create input | Create{Entity}Dto | CreateBookDto |
| Update input | Update{Entity}Dto | UpdateBookDto |
| Single entity output | {Entity}Dto | BookDto |
| List item output | {Entity}ListItemDto | BookListItemDto |
DTO Location
- Define DTOs in
*.Application.Contractsproject - This allows sharing with clients (Blazor, HttpApi.Client)
Validation
Data Annotations
public class CreateBookDto
{
[Required]
[StringLength(100, MinimumLength = 3)]
public string Name { get; set; }
[Range(0, 999.99)]
public decimal Price { get; set; }
}Custom Validation with IValidatableObject
Before adding custom validation, decide if it's a domain rule or application rule:
- Domain rule: Put validation in entity constructor or domain service (enforces business invariants)
- Application rule: Use DTO validation (input format, required fields)
Only use IValidatableObject for application-level validation that can't be expressed with data annotations:
public class CreateBookDto : IValidatableObject
{
public string Name { get; set; }
public string Description { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Name == Description)
{
yield return new ValidationResult(
"Name and Description cannot be the same!",
new[] { nameof(Name), nameof(Description) }
);
}
}
}FluentValidation
public class CreateBookDtoValidator : AbstractValidator<CreateBookDto>
{
public CreateBookDtoValidator()
{
RuleFor(x => x.Name).NotEmpty().Length(3, 100);
RuleFor(x => x.Price).GreaterThan(0);
}
}Error Handling
Business Exceptions
throw new BusinessException("BookStore:010001")
.WithData("BookName", name);Entity Not Found
var book = await _bookRepository.FindAsync(id);
if (book == null)
{
throw new EntityNotFoundException(typeof(Book), id);
}User-Friendly Exceptions
throw new UserFriendlyException(L["BookNotAvailable"]);HTTP Status Code Mapping
Status code mapping is configurable in ABP (do not rely on a fixed mapping in business logic).
| Exception | Typical HTTP Status |
AbpValidationException | 400 |
AbpAuthorizationException | 401/403 |
EntityNotFoundException | 404 |
BusinessException | 403 (but configurable) |
| Other exceptions | 500 |
Auto API Controllers
ABP automatically generates API controllers for application services:
- Interface must inherit
IApplicationService(which already has[RemoteService]attribute) - HTTP methods determined by method name prefix (Get, Create, Update, Delete)
- Use
[RemoteService(false)]to disable auto API generation for specific methods
Object Mapping (Mapperly / AutoMapper)
ABP supports both Mapperly and AutoMapper integrations. But the default mapping library is Mapperly. You need to first check the project's active mapping library.
- Prefer the mapping provider already used in the solution (check existing mapping files / loaded modules).
- In mixed solutions, explicitly setting the default provider may be required (see
docs/en/release-info/migration-guides/AutoMapper-To-Mapperly.md).
Mapperly (compile-time)
Define mappers as partial classes:
[Mapper]
public partial class BookMapper
{
public partial BookDto MapToDto(Book book);
public partial List<BookDto> MapToDtoList(List<Book> books);
}Register in module:
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddSingleton<BookMapper>();
}Usage in application service:
public class BookAppService : ApplicationService
{
private readonly BookMapper _bookMapper;
public BookAppService(BookMapper bookMapper)
{
_bookMapper = bookMapper;
}
public BookDto GetBook(Book book)
{
return _bookMapper.MapToDto(book);
}
}Note: Mapperly generates mapping code at compile-time, providing better performance than runtime mappers.
AutoMapper (runtime)
If the solution uses AutoMapper, mappings are typically defined in Profile classes and registered via ABP's AutoMapper integration.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

