agentleFS
elidadutra187elidadutra187/claude-skills/skills/abp-dependency-rules/SKILL.md

abp-dependency-rules

Skill0 starsChanged 4 days agoMITView on GitHub

Use when reviewing project structure, adding new project references, or checking if a dependency direction is correct. Covers ABP project layer dependency rules, which projects can reference which, domain/application/infrastructure separation, and cross-layer violations to avoid.

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When you have multiple applications (e.g., Admin + Public API):

    line 119
  2. Distinctive:

    When adding a new feature:

    line 135

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

ABP Dependency Rules

Core Principles (All Templates)

These principles apply regardless of solution structure:

  1. Domain logic never depends on infrastructure (no DbContext in domain/application)
  2. Use abstractions (interfaces) for dependencies
  3. Higher layers depend on lower layers, never the reverse
  4. Data access through repositories, not direct DbContext

Layered Template Structure

Note: This section applies to layered templates (app, module). Single-layer and microservice templates have different structures.

Domain.Shared    → Constants, enums, localization keys
       ↑
    Domain       → Entities, repository interfaces, domain services
       ↑
Application.Contracts → App service interfaces, DTOs
       ↑
  Application    → App service implementations
       ↑
   HttpApi       → REST controllers (optional)
       ↑
     Host        → Final application with DI and middleware

Layered Dependency Direction

ProjectCan ReferenceReferenced By
Domain.SharedNothingAll
DomainDomain.SharedApplication, Data layer
Application.ContractsDomain.SharedApplication, HttpApi, Clients
ApplicationDomain, ContractsHost
EntityFrameworkCore/MongoDBDomainHost only
HttpApiContracts onlyHost

Critical Rules

❌ Never Do

// Application layer accessing DbContext directly
public class BookAppService : ApplicationService
{
    private readonly MyDbContext _dbContext; // ❌ WRONG
}

// Domain depending on application layer
public class BookManager : DomainService
{
    private readonly IBookAppService _appService; // ❌ WRONG
}

// HttpApi depending on Application implementation
public class BookController : AbpController
{
    private readonly BookAppService _bookAppService; // ❌ WRONG - Use interface
}

✅ Always Do

// Application layer using repository abstraction
public class BookAppService : ApplicationService
{
    private readonly IBookRepository _bookRepository; // ✅ CORRECT
}

// Domain service using domain abstractions
public class BookManager : DomainService
{
    private readonly IBookRepository _bookRepository; // ✅ CORRECT
}

// HttpApi depending on contracts only
public class BookController : AbpController
{
    private readonly IBookAppService _bookAppService; // ✅ CORRECT
}

Repository Pattern Enforcement

Interface Location

// In Domain project
public interface IBookRepository : IRepository<Book, Guid>
{
    Task<Book> FindByNameAsync(string name);
}

Implementation Location

// In EntityFrameworkCore project
public class BookRepository : EfCoreRepository<MyDbContext, Book, Guid>, IBookRepository
{
    // Implementation
}

// In MongoDB project
public class BookRepository : MongoDbRepository<MyDbContext, Book, Guid>, IBookRepository
{
    // Implementation
}

Multi-Application Scenarios

When you have multiple applications (e.g., Admin + Public API):

Vertical Separation

MyProject.Admin.Application      - Admin-specific services
MyProject.Public.Application     - Public-specific services
MyProject.Domain                 - Shared domain (both reference this)

Rules

  • Admin and Public application layers MUST NOT reference each other
  • Share domain logic, not application logic
  • Each vertical can have its own DTOs even if similar

Enforcement Checklist (Layered Templates)

When adding a new feature:

  1. Entity changes? → Domain project
  2. Constants/enums? → Domain.Shared project
  3. Repository interface? → Domain project (only if custom queries needed)
  4. Repository implementation? → EntityFrameworkCore/MongoDB project
  5. DTOs and service interface? → Application.Contracts project
  6. Service implementation? → Application project
  7. API endpoint? → HttpApi project (if not using auto API controllers)

Common Violations to Watch

ViolationImpactFix
DbContext in ApplicationBreaks DB independenceUse repository
Entity in DTOExposes internalsMap to DTO
IQueryable in interfaceBreaks abstractionReturn concrete types
Cross-module app service callTight couplingUse events or domain

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.