| name | abp-contract-scaffolding |
| description | Generate ABP Application.Contracts layer scaffolding (interfaces, DTOs, permissions) from technical design. Enables parallel development by abp-developer and qa-engineer. Use when: (1) backend-architect needs to generate contracts, (2) preparing for parallel implementation workflow, (3) creating API contracts before implementation. |
| layer | 2 |
| tech_stack | ["dotnet","csharp","abp"] |
| topics | ["interface","dto","contracts","scaffolding","permissions"] |
| depends_on | ["abp-framework-patterns"] |
| complements | ["technical-design-patterns","api-design-principles"] |
| keywords | ["IAppService","Dto","CreateDto","UpdateDto","GetListInput","Permissions","Contracts"] |
ABP Contract Scaffolding
Generate Application.Contracts layer code to enable parallel development workflows.
Purpose
Contract scaffolding separates interface design from implementation, enabling:
abp-developer to implement against defined interfaces
qa-engineer to write tests against interfaces (before implementation exists)
- True parallel execution in
/add-feature workflow
When to Use
- Backend-architect creating technical design with contract generation
- Preparing for parallel implementation and testing
- Defining API contracts before implementation starts
- Interface-first development approach
Project Structure
{Project}.Application.Contracts/
├── {Feature}/
│ ├── I{Entity}AppService.cs # Service interface
│ ├── {Entity}Dto.cs # Output DTO
│ ├── Create{Entity}Dto.cs # Create input
│ ├── Update{Entity}Dto.cs # Update input
│ └── Get{Entity}sInput.cs # List filter/pagination
└── Permissions/
└── {Entity}Permissions.cs # Permission constants
Templates
1. Service Interface
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
namespace {ProjectName}.{Feature};
public interface I{Entity}AppService : IApplicationService
{
Task<PagedResultDto<{Entity}Dto>> GetListAsync(Get{Entity}sInput input);
Task<{Entity}Dto> GetAsync(Guid id);
Task<{Entity}Dto> CreateAsync(Create{Entity}Dto input);
Task<{Entity}Dto> UpdateAsync(Guid id, Update{Entity}Dto input);
Task DeleteAsync(Guid id);
}
2. Output DTO
using System;
using Volo.Abp.Application.Dtos;
namespace {ProjectName}.{Feature};
public class {Entity}Dto : FullAuditedEntityDto<Guid>
{
public {Type} {PropertyName} { get; set; }
}
3. Create Input DTO
using System;
namespace {ProjectName}.{Feature};
public class Create{Entity}Dto
{
public string {PropertyName} { get; set; } = string.Empty;
}
4. Update Input DTO
using System;
namespace {ProjectName}.{Feature};
public class Update{Entity}Dto
{
public string {PropertyName} { get; set; } = string.Empty;
}
5. List Filter Input DTO
using Volo.Abp.Application.Dtos;
namespace {ProjectName}.{Feature};
public class Get{Entity}sInput : PagedAndSortedResultRequestDto
{
public string? Filter { get; set; }
public bool? IsActive { get; set; }
}
6. Permission Constants
namespace {ProjectName}.Permissions;
public static class {Entity}Permissions
{
public const string GroupName = "{ProjectName}.{Entities}";
public const string Default = GroupName;
public const string Create = GroupName + ".Create";
public const string Edit = GroupName + ".Edit";
public const string Delete = GroupName + ".Delete";
}
Common Patterns
Activation/Deactivation Pattern
When entity supports activation lifecycle:
Task<{Entity}Dto> ActivateAsync(Guid id);
Task<{Entity}Dto> DeactivateAsync(Guid id);
public const string Activate = GroupName + ".Activate";
public const string Deactivate = GroupName + ".Deactivate";
public bool? IsActive { get; set; }
Hierarchical Entity Pattern
When entity has parent-child relationships:
public Guid? ParentId { get; set; }
public string? ParentName { get; set; }
public List<{Entity}Dto> Children { get; set; } = new();
Task<List<{Entity}Dto>> GetChildrenAsync(Guid parentId);
Task MoveAsync(Guid id, Guid? newParentId);
public Guid? ParentId { get; set; }
public bool IncludeChildren { get; set; }
Lookup/Reference Pattern
For dropdown lists and references:
public class {Entity}LookupDto
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
}
Task<List<{Entity}LookupDto>> GetLookupAsync();
Bulk Operations Pattern
When bulk operations are needed:
Task<int> DeleteManyAsync(List<Guid> ids);
Task<List<{Entity}Dto>> CreateManyAsync(List<Create{Entity}Dto> inputs);
public const string DeleteMany = GroupName + ".DeleteMany";
Generation Checklist
When generating contracts, verify:
Integration with /add-feature
This skill is used by backend-architect agent in Phase 1 of /add-feature:
Phase 1: backend-architect generates:
├── docs/features/{feature}/technical-design.md
├── Application.Contracts/{Feature}/I{Entity}AppService.cs
├── Application.Contracts/{Feature}/{Entity}Dto.cs
├── Application.Contracts/{Feature}/Create{Entity}Dto.cs
├── Application.Contracts/{Feature}/Update{Entity}Dto.cs
├── Application.Contracts/{Feature}/Get{Entity}sInput.cs
└── Application.Contracts/Permissions/{Entity}Permissions.cs
Phase 2 (parallel):
├── abp-developer: Implements against interface
└── qa-engineer: Writes tests against interface
Naming Conventions
| Component | Pattern | Example |
|---|
| Interface | I{Entity}AppService | IBookAppService |
| Output DTO | {Entity}Dto | BookDto |
| Create DTO | Create{Entity}Dto | CreateBookDto |
| Update DTO | Update{Entity}Dto | UpdateBookDto |
| Filter DTO | Get{Entity}sInput | GetBooksInput |
| Lookup DTO | {Entity}LookupDto | BookLookupDto |
| Permissions | {Entity}Permissions | BookPermissions |
Related Skills
abp-framework-patterns - Full ABP patterns including implementation
technical-design-patterns - Technical design document templates
api-design-principles - REST API design best practices