Agent skill
architecture
Enforce architectural patterns and layer boundaries
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/architecture-baphled-dotopencode
SKILL.md
Skill: architecture
What I do
I enforce clean architecture: layer separation (domain → service → repository → handler), dependency direction (inward only), and boundary rules that keep the codebase maintainable as it grows.
When to use me
- Designing new packages, intents, or modules
- Reviewing code for layer boundary violations
- Deciding where new logic belongs (domain vs service vs handler)
- Structuring Go projects with clean dependency flow
- Diagnosing tight coupling or circular dependencies
Core principles
- Dependencies point inward — Domain knows nothing about HTTP, databases, or frameworks
- Layer isolation — Each layer has a single responsibility; no layer skipping
- Interface boundaries — Layers communicate through interfaces defined by the consumer
- Domain is king — Business rules live in domain; everything else is infrastructure
- Package by feature — Group by capability (
user/,order/), not by type (models/,handlers/)
Patterns & examples
Layer responsibilities:
| Layer | Responsibility | Depends on | Example |
|---|---|---|---|
| Domain | Business rules, entities, value objects | Nothing | User, Email, validation |
| Service | Orchestration, use cases | Domain | RegisterUser, PlaceOrder |
| Repository | Data persistence (interface) | Domain | UserRepository interface |
| Handler | HTTP/CLI transport | Service | POST /users handler |
| Infrastructure | Framework adapters | Domain interfaces | GORM repo, SMTP sender |
Dependency flow in Go:
// domain/ — no imports from other layers
type User struct {
ID string
Email string
Name string
}
type UserRepository interface {
Save(ctx context.Context, user *User) error
FindByEmail(ctx context.Context, email string) (*User, error)
}
// service/ — depends only on domain
type UserService struct {
repo domain.UserRepository // interface, not concrete
}
func (s *UserService) Register(ctx context.Context, email, name string) error {
user := &domain.User{Email: email, Name: name}
return s.repo.Save(ctx, user)
}
// handler/ — depends on service
func (h *Handler) RegisterUser(w http.ResponseWriter, r *http.Request) {
// Decode request, call service, encode response
err := h.svc.Register(r.Context(), req.Email, req.Name)
}
// infrastructure/ — implements domain interfaces
type GORMUserRepo struct{ db *gorm.DB }
func (r *GORMUserRepo) Save(ctx context.Context, u *domain.User) error { ... }
Package structure (feature-based):
intent/
├── user/
│ ├── domain/ # entities, value objects, interfaces
│ ├── service/ # use cases
│ ├── repository/ # data access implementation
│ └── handler/ # HTTP handlers
├── order/
│ ├── domain/
│ ├── service/
│ └── ...
Boundary validation checklist:
- Domain imports: only stdlib (
fmt,errors,time) - Service imports: domain only
- Handler imports: service only (never domain directly for persistence)
- Repository imports: domain (for interfaces/entities) + infrastructure (GORM, etc.)
Anti-patterns to avoid
- ❌ Handler calling repository directly — Skips business logic; service layer exists for a reason
- ❌ Domain importing infrastructure — Domain must not know about GORM, HTTP, or external services
- ❌ Circular dependencies — Package A imports B, B imports A; restructure with interfaces
- ❌ God package — Single
models/package with everything; package by feature instead - ❌ Leaking implementation — Returning GORM models from service layer; map to domain types
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Domain-Architecture/Architecture.md
Related skills
domain-modeling- Designing entities and value objects in the domain layerservice-layer- Orchestrating use cases in the service layerdesign-patterns- Patterns that support architectural boundariesclean-code- Code quality within each layermodular-design- Unit-level composability and testability within each layer
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?